Endpoint
answers.write
Streaming mode (default)
Streaming is the default behavior when you omit thestream field or set it to true. The response is text/event-stream.
Request fields
string
required
The question you want the worker to answer. 1 to 8000 characters.
string
Your own thread key. Reuse it to continue a conversation. 1 to 200 characters.
object
{ id, name? }. Name the person so the worker can surface facts about them.string
Which worker answers. Defaults to
main. 1 to 200 characters.boolean
Defaults to
true. Keep it true for streaming mode.array
Pass
["sources"] to receive the facts the answer was built from.Example request
Event sequence
The stream sends five possible event names and no others. Every stream ends withdone.
Example stream
Queued mode
Setstream: false to queue the question and receive an answer_id immediately. Poll GET /v1/answers/:answer_id until the status is completed or failed.
Extra fields for queued mode
boolean
required
Must be
false.string
Retry key. Send the same key with the same body to get the same
answer_id without creating a second run.Example request
Queued response
Idempotency rules
- Repeating the same
Idempotency-Keywith the exact same body returns the original response: sameanswer_id, no second run. - Reusing the same key with a different request returns
409 idempotency_key_reused. - Always generate a fresh key for each new question.
Read an answer
status is completed or failed.
Query parameters
string
Pass
sources to include the grounding facts. sources is the only supported value.Example request
Example response
Polling guidance
Answers take seconds to minutes. Poll every 1 to 2 seconds, not every 50 milliseconds. The rate limit is shared with your other calls. Whilestatus is not completed, output_text is "".
Status lifecycle
failed answer carries an error object with the same shape as the stream’s answer.failed event.