Skip to Content
Docs

Stream one draft turn

POST
/api/drafter/stream

Run one draft turn and stream it as server-sent events (data: <json>). Events: turn (first, {"id"}: the id POST /api/drafter/turns/<id>/cancel stops, the request's turn_id when it sent a valid one; absent when the server can't stop turns), status, read (what a read tool showed the model, {"kind": "questions", "items"}), message, questions, proposal, error, and end (always last). Refusals (disabled, no_model, rate_limited, quota, bad_request) arrive as an error event in a 200 stream; a bad_request carries reason: history (the conversation is refused: start a new one), too_long (the prompt is over the read cap, with limit), empty (the message is empty once cleaned) or invalid. Nothing is saved.

Not available to personal access tokens; call it from a signed-in session.

Authorization

bearer
headerAuthorizationBearer <token>

A session token or a personal access token. Leave it empty when the instance runs without authentication (AUTH_TYPE unset).

Request Body

application/json
  1. body
context?

The recipe's screen state: the agent form's current values (agent), the prompt being written or improved (prompt), or {agent_id} (topics)

messages*array<>

The conversation so far, oldest first: {role: user | assistant, content}. An assistant message is the JSON of an earlier questions or proposal event. Ends with a user message.

recipe*string

What is drafted: agent (the agent form), prompt (a prompt), topics (Insights topics)

turn_id?string

The id the client picks for this turn (32 lowercase hex characters), so it can stop the turn before the turn event arrives. Optional: without one, or with one that isn't a turn id, the server picks it.

Response Body

text/event-stream of draft events

Example Request
curl -X POST 'http://localhost:7091/api/drafter/stream' \  -H 'Content-Type: application/json' \  -d '{  "messages": [    {}  ],  "recipe": "string"}'
Example Response
Empty