stream: true on observe-and-respond (or respond), attach inline images in files, render downloadable citations, and load thread history.
Step 1: open a stream with an optional image
In v2, you do not need a separate image-upload route. Pass up to 10 images directly infiles (base64-encoded data or an existing file_id), and set "stream": true on POST/v2/agents//threads//observe-and-respond (or POST…/respond when you do not want the agent to learn from user messages).
Send an Idempotency-Key header so retrying after a connection drop never duplicates work or billing.
Step 2: handle server-sent events
The response streamstext/event-stream events:
SSE stream
complete event data payload:
complete event payload
Every stream ends with exactly one
complete or one error event.
Step 3: render citations
Each item incitations names a file the answer drew on:
- Proxy
hrefthrough your backend with your API key so users can download or preview the source file without ever seeing your key. verified: truemeans the model inspected an image attached on this turn;verified: falsemeans the answer drew on memories learned earlier from a document.
Step 4: handle errors
Before the stream begins, errors arrive as standard HTTP statuses:400or422 invalid_request: missingcontentorspeaker, or invalid image format.402 payment_required: organization balance is zero.404 thread_not_foundornot_found: invalid thread id or unknownfile_idinfiles.409 agent_not_ready: poll GET/v2/agents/untilready.413 payload_too_large: image exceeds 10 MiB, more than 10 images, or total base64 payload exceeds the request cap.429 rate_limit_exceeded: more than 20 calls/min or 2 concurrent answers per subject. WaitRetry-Afterseconds.503 answer_model_unavailable: retry with the sameIdempotency-Key.
error event carrying the same code and request_id.
Step 5: load conversation history
messages. To paginate older turns, the owner calls GET/v2/agents//memories?thread_id=.