Skip to main content
Read the shell’s output as server-sent events. The stream starts with recent output, then follows live output. Several clients can read the same shell, and you can disconnect and attach again.

Events

Each SSE frame carries one JSON object with a type field. Terminal output is bytes, including escape sequences, and a chunk can split a UTF-8 character, so data is base64.
gravixlayer runtime pty attach prints those bytes already decoded. Decode base64 only when you read the SSE stream yourself. The Python SDK decodes data back to bytes. If you need text, decode with errors="replace" and accumulate across chunks:

Recent output

Each shell keeps up to 256 KB of recent output. Attaching replays that buffer first. If the shell has printed more than 256 KB since you last attached, the oldest output is gone and the replay starts partway through. For a complete transcript, keep a reader attached, or redirect the program’s output to a file in the runtime and read that file.

Endpoint

GET /v1/agents/runtime/{runtime_id}/pty/{session_id}/stream