Chat

Stream a chat turn

GET
/api/v2/chat/{session_id}/stream

The conversation's events as server-sent events: an id: line and a data: line of JSON for each, ending with done. Open the stream_url the turn returned, which starts at that turn. If the connection drops, reconnect with the last id: you saw as Last-Event-ID, or as after.

The events are the Chat API's: response carries the answer. An error says which kind of failure it was — the model's quota, a refusal, a rate limit, an outage, or no usable answer — and never passes on the provider's words. Read it with fetch and the Authorization header; a browser EventSource cannot send the header.

apiKey
headerAuthorizationBearer <token>

An API key, sk-syn- and 32 characters. On SynapseOrch Cloud an owner or admin makes it under Settings → Developer; on a self-hosted install, under Settings → API Keys.

session_id*string

The conversation, from the turn's answer.

after?|

An event id to start after — the ?after= the turn's stream_url carries.

turn?|null
Last-Event-ID?|

The last event id you saw, to pick up where a dropped connection left off.

Response Body

A stream of server-sent events.

response?stringtext/event-stream
curl -X GET "https://api.synapseorch.com/api/v2/chat/chat_01a1205c3e8f7a2b9d4c6e1f0a3b5d7c/stream" \  -H "Authorization: Bearer sk-syn-..."
id: 1790249607455-0data: {"type": "session", "session_id": "chat_01a1205c3e8f7a2b9d4c6e1f0a3b5d7c", "agent_id": "agent_01a10b7e2c4d6f8a0b1c3d5e7f9a2b4c", "agent_name": "Order desk"}id: 1790249607460-0data: {"type": "thinking", "message": "Analyzing your request..."}id: 1790249609112-0data: {"type": "response", "content": "New accounts pay net-30 after the first order, which is paid on invoice.", "intent": "chat", "session_id": "chat_01a1205c3e8f7a2b9d4c6e1f0a3b5d7c"}id: 1790249609113-0data: {"type": "done"}