POST /conversations/instances/{instance_slug}/conversations/{conversation_id}/turns
GET /conversations/instances/{instance_slug}/conversations/{conversation_id}/turns/{turn_id}/stream?end_user=...&after=...
Credential: a scoped key with conversations:use. An organization API key is refused (why). Both routes are server to server.
How it works
- You generate a
turn_id(a UUID) and postmessagewith it andAccept: application/json. The platform resolves the instance’s latest published version, stores the user message, and answers202with the admitted turn and its stream. - You open the turn stream. Every frame carries the
turn_idand aseq, a number that starts at 1 and only grows. The stream replays every frame after youraftercursor, then follows the turn live. - The model runs rounds. Platform tools run on the server and loop back to the model. A call to one of your client tools arrives as a
tool_useframe: your server accepts it, runs it, and posts its result to the call’s result route while the turn keeps running. - A call that needs approval pauses the turn with a
turn_pausedframe. You postconfirmationson the turns route with the sameturn_id, and the frames continue on the same stream. - The turn ends with exactly one
turn_endorerrorframe.
turn_id or without Accept: application/json, answers 400 stream_turn_required.
Request
Send exactly one ofmessage or confirmations.
Sending the retired
depth field returns 400 invalid_request with “depth is no longer supported; every assistant turn uses gpt-6-sol.” Unknown fields other than depth are ignored. Client tool results are never posted to this route: post each one to its call’s result route (see Client tools). A turns POST that carries tool_results answers 409.
Admission
The turns POST answers202 once the user message is stored and the turn is queued:
turn_id and the same message answers 200 with the same body. The same turn_id with a different message, or an id already used in another conversation, answers 409 turn_id_conflict. When the platform is at capacity it answers 503 turn_capacity with Retry-After: 2 before anything is stored; send the same request again.
The stream
GET .../turns/{turn_id}/stream takes these query parameters:
Each frame is:
type (equal to the event name), turn_id and seq (equal to the id: line). An idle stream sends a : ka comment every 15 seconds. The server ends the response with a : end comment once the turn is at rest and every write it started has a final result, or 60 seconds after rest. If the connection drops at any point, open the stream again with after set to the last seq you applied: nothing is lost and nothing repeats. A replay after a stop may skip numbers that were withdrawn, so never treat a gap as loss.
A turn whose stream has expired (24 hours after rest) answers 410 stream_expired; read the conversation instead, which is durable. At most 10 streams per end user can be open at once; beyond that the route answers 429 too_many_streams.
Frames
Every turn ends with exactly one
turn_end or one error frame. Only outcome frames for writes that were still running can follow it.
Example frames:
Usage
turn_end.usage has input_tokens, output_tokens, total_tokens, cached_input_tokens, cache_creation_input_tokens, and cache_read_input_tokens. It covers the whole turn, a confirmation pause included. cached_input_tokens is the part of input_tokens the provider served from its cache. Configured assistants run on an OpenAI model, so the two cache_* fields, which only Anthropic models fill, are 0.
Turn states
This is the one state model for a turn. Other pages link here.
After an
error frame, retry the failed turn with retry_of, or post a distinct message without it. If a pause is still open, a new message returns 409 pending_turn, described below.
Retry a failed turn
A retry is another attempt of the same logical turn. Sendretry_of with the failed attempt’s turn ID, a fresh turn_id, and the same message and attachment_ids. The failed attempt’s ID is the turn_id you sent for it (also turn.id in its admission answer). Do not use user_message_id.
Text comparison uses the stored message’s trimmed text. Preserve the attachment order; omitting attachment_ids and sending an empty array both mean no attachments.
failed. The API reuses its user message and admits the new attempt under your new turn ID. It also preserves the message’s original page context; a new page_context value does not replace it. Context manifests report the attempt number, starting at 1 for the original submission. If that attempt fails too, use its ID as the next retry_of.
An invalid ID, a non-failed or older attempt, a different branch, or changed text or attachments returns 409 retry_conflict. retry_of cannot accompany an edit, stop_active_turn, or confirmations. A disconnect alone does not establish failure; read the turn status first, since turns survive disconnects.
Omit retry_of for a distinct submission. Identical text without this field remains a new user message. Existing duplicate messages from older retries remain in history.
A new message while a turn is paused returns 409 pending_turn. Its details name the paused calls:
confirmations with the paused turn’s turn_id. A confirmations post when nothing is paused returns 409 turn_state_conflict. A confirmation pause never expires.
Stop reasons
When the model uses every one of
limits.max_tool_rounds, it gets one more round with no tools to write its answer.
Which config a turn runs
A newmessage runs the latest published version of the instance; the instance must have one (409 instance_not_published). A confirmations post continues on the version the turn started on, even if a newer version was published during the pause. Every stored message carries the config_version_hash it ran under.
Errors before and after admission
- Before admission, a failure is a normal HTTP error on the turns POST with the JSON envelope
{code, message, details?}. Nothing was stored. - After admission, the turns POST has already answered
202. A failure arrives on the stream as a terminalerrorframe withcode,message, and, forprovider_error,reason. Assistant text already streamed may be incomplete.
error frame, not as an HTTP status. Its code is provider_error with a reason from a closed list (rate_limited, context_overflow, model_unavailable, invalid_request, provider_auth, provider_fault), or provider_unavailable when the provider circuit is open after repeated failures. A model call that fails with a transient error (a provider rate limit or 5xx, or a network failure) is attempted up to three times in total, waiting at most 5 seconds between attempts, as long as the provider has streamed nothing for that call. Once the provider has streamed output for that call, the failure is final. The guardrail classifier runs after admission too, so its failure (guardrail_evaluation_failed) arrives as an error frame and the user message stays stored.
Disconnects and timeouts
- The turn runs on the platform’s workers, not in your request. Closing the stream never stops it; open the stream again with
afterto continue, or fetch the conversation to see the result. - A turn may run for up to 10 minutes.
- One turn runs per conversation at a time.
- Turn requests have their own rate limit bucket per org, separate from the default bucket other routes use. Its limit is 300 requests per minute, or the deployment’s default limit when that is higher. A
429 rate_limitedcarriesRetry-After. - If a previous turn was interrupted between a tool call and its result, the platform answers the orphaned calls with errors before the next message turn runs.
Errors
These are the turns POST’s statuses.
A code raised after admission, such as
attachment_changed, guardrail_evaluation_failed, invalid_conversation_history, or internal_error, arrives in an error frame on the stream instead of as a status. The full error envelope is described on Errors.
Client tools and confirmations
Run your own tools and continue a confirmation pause.
Take a turn (API reference)
The generated endpoint contract.