Skip to main content
Read stdout, stderr, and results while code is still running. Output arrives as the code produces it, so a loop that prints once a second yields one event a second.

Parameters

The request body is identical to Run code. Streaming is selected with the stream=true query parameter.

Events

Each SSE frame carries one JSON object with a type field.
Streamed code output uses the field name text, while streamed command output uses data. They are separate endpoints with separate wire contracts.
A result payload carries whichever representations the value produced:

Errors

When the executed code raises, an error frame is emitted before end:
The SDK surfaces this through on_error and on the returned CodeRunResponse. The CLI prints the traceback and exits non-zero.

When to stream

Streaming and a buffered run return the same result. Stream when intermediate output matters, or when you want to stop early. Use the buffered call when you only need the final value.

Endpoint

POST /v1/agents/runtime/{runtime_id}/code/run?stream=true