session_id to POST /v1/agents/run yourself, the sessions API lets you create, inspect, replay, and interrupt it explicitly.
Creating a session provisions no sandbox and costs nothing. The sandbox is provisioned on the first event, and billing follows events — not the existence of a session.
Create a session
Environment id. Resolved at every run, so editing the environment takes effect on the next event.
curl
Send an event (SSE)
Text model id for this turn. Missing or blank returns
Missing required field: model. Token billing uses this name, not the Expert’s selected model. Image and video billing ignore this field.Up to 20 file ids returned by Files.
curl
X-Session-Id response header is the coordinate of this turn. Closing the SSE connection does not stop generation.
After the connection drops
A run is addressed by session id. SSE is a subscription. The id comes from theX-Session-Id header on POST /v1/agents/run or on this endpoint, before the body finishes.
Closing the connection does not cancel the turn. The model keeps generating, and tool calls and billing continue. To stop, call interrupt below.
To keep reading tokens as they are produced:
curl
text/event-stream with the same events as sending an event. When the turn has finished, the response is 204 with an empty body. Read the persisted log instead.
Posting the same body to POST /v1/agents/run, or posting the same content to this session’s POST .../events, resubscribes. It does not start another turn and does not insert another user message. A different body while the turn is still running returns 409:
tool_confirmations resumes the same turn and is not rejected as a different body.
/v1/chat/completions is outside this contract. It is synchronous: disconnecting cancels that request.
Replay history
?live=1 from the previous section.
curl
after cursor replays from the beginning rather than returning an empty page — empty would be indistinguishable from “caught up”. limit maxes out at 200.
Interrupt a run
curl
Other operations
Errors
Next steps
Environments
Define sandbox runtime and dependencies
Manage Agents
Create and publish Experts via API

