Skip to main content
POST
Stream a chat completion (Server-Sent Events)

Authorizations

Authorization
string
header
required

Enter your API key with the Bearer prefix — e.g. Bearer sk_live_xxx (production) or Bearer sk_test_xxx (sandbox)

Headers

x-session-id
string<uuid>
required

Conversation id — must be a valid UUID. The same value across requests resumes the same chat; a new value starts a fresh conversation.

Path Parameters

workspaceId
string<uuid>
required

Workspace (MCP server) UUID to route the chat through.

Body

application/json
message
string
required

The user message for this turn. This is the CURRENT message only — prior turns go in history (stateless workspaces) or are loaded from the persisted session (stateful workspaces).

Required string length: 1 - 50000
Example:

"Hello"

context
string

Optional free-text background about the end-user (e.g. an email signature, preferred tone, defaults). When non-empty it is injected into the agent so it can apply it when calling tools. On a stateful workspace it is stored encrypted and sticky for the end-user (keyed by the x-session-id header); on a stateless workspace it is injected for this request only and NEVER stored. Omit or send an empty string to keep any previously stored value; a new non-empty value overwrites it. Max 50000 characters.

Maximum string length: 50000
history
object[]

Caller-supplied PRIOR conversation turns, accepted ONLY when the workspace is in statelessMode. Sending history to a non-stateless workspace returns 400. Excludes the current message (which stays in message). Up to 200 items; each item's message is capped at ~50,000 characters.

Maximum array length: 200
Example:

Response

Server-Sent Events stream of the agent loop's response. Parse event:/data: frames; the stream ends with a done event.

An SSE stream. Each frame is event: <type>\ndata: <json>\n\n.