Skip to main content
The chat endpoint returns a Server-Sent Events (SSE) stream, not JSON. Each response chunk contains a text-delta that the client aggregates into the full assistant message.

Endpoints

Stream a chat turn

The response is Content-Type: text/event-stream. Each event contains a text-delta that must be aggregated client-side:

Required fields

Idempotency

The server accepts an optional Idempotency-Key header. If absent, the server generates one automatically.

Thread CRUD

List threads

Create a thread

If omitted, title defaults to “New conversation”.

Get a thread

Returns the thread metadata and all messages.

Update a thread

Delete a thread

Credit reservation

Chat uses 720,000 µUSD per turn (6 steps at 120,000 µUSD per step). Each step within a turn obtains a per-step credit lease. If a lease is refused mid-turn, the stream terminates with stopped_credits.

Consuming the stream

The recommended approach (used by the MCP client at apps/mcp/src/client.ts) is to aggregate text-delta events into a full message:
1

Connect the stream

Connect the SSE stream to a POST to /api/v1/chat.
2

Aggregate the deltas

For each text-delta event, append text to the current assistant message.
3

Detect completion

On finish, the stream is complete.
4

Persist the history

After the stream, use PATCH /api/v1/threads/{id} or the internal saveChatMessages to persist the full message history.