REST API - Agents
Invoke Agent (Stream)
Execute an agent with real-time Server-Sent Events (SSE). Reusing id continues the same task/thread.
POST
Invoke Agent (Stream)
Invoke an agent with real-time streaming via Server-Sent Events (SSE). Events fire as the agent works, so you can render progress, chunks, tool activity, and the final result in an interactive UI.
For
Use
Path Parameters
Request Body
The request body is identical to Invoke Agent (Sync). Onlyinput is required, with the prompt in input.text.
Task/thread ID for multi-turn conversations. Pass the
id from a previous task response to continue the same conversation. Continued turns keep using that same ID.When
true, files in input.files are not injected into the LLM context window. See Invoke Sync: Processing Files.Extra context appended to the agent’s system prompt for this invocation only. Unlike
instructions_override (which adds behavioral instructions), this supplies supplementary facts or context the agent should consider for this run — e.g. relevant background data, the current state of an external system, or a user’s recent activity.Per-execution LLM provider override. See Invoke Sync: Per-Execution LLM Override.
Per-execution model override. See Invoke Sync: Per-Execution LLM Override.
Per-execution reasoning-effort override (
low | medium | high | xhigh). See Invoke Sync: Per-Execution LLM Override.Query Parameters
Agent version to invoke. Defaults to the live agent.
"draft" is legacy and also runs the live agent, since edits save straight to live.Response Format
ReturnsContent-Type: text/event-stream. Each SSE line is prefixed with data: and contains a JSON object with this top-level shape:
chunk events, data is a string fragment. For task lifecycle events, data is the task object snapshot at that moment.
If you continue a conversation by sending
id: "<previous-task-id>", the stream keeps emitting that same task_id. Use Get Task for the latest turn state and Get Task Thread or Get Task Thread (Full) for the full message history.Event Types
Events are emitted in this order during a typical invocation:Fired immediately. Contains the task object with
status: "pending". This is emitted for both brand-new threads and follow-up turns on an existing task/thread ID.A CLI agent finished a turn. It arrives just before
task_finished. Both agent types end the REST stream with task_finished.Basic Example
--no-buffer (or -N) for real-time output.
Real Event Stream
Here’s what the actual SSE output looks like from a live invocation:Consuming the Stream (Node.js)
Consuming the Stream (Python)
Notes
- Use
curl --no-bufferorcurl -Nfor real-time terminal output - The stream ends after the
task_finishedevent, for every agent type. Close the connection at that point. chunkevents contain raw text fragments; concatenate them for the full responsetool_call_requestandtool_call_resultevents let you show tool usage in your UIthinkandanalyzeevents show the agent’s reasoning (useful for debugging and transparency)- For multi-turn conversations, wait for
task_finishedbefore sending the next message with the sameid - Reusing
idcontinues the same task/thread; it does not mint a new top-level task ID for the follow-up turn - Get Task shows the latest turn state for that ID, while Get Task Thread and Get Task Thread (Full) show the accumulated conversation
See Also
- Invoke Agent (Sync) — blocks until completion
- Invoke Agent (Async) — returns task ID for polling
- Get Thread — retrieve conversation history after streaming
Body
application/json
Response
Successful Response

