GET /v2/ai/sandboxes/{sandbox_id}/logs returns the output (stdout and stderr) of the sandbox’s main process. Exec output isn’t included; read it through the exec attach.
stream=stdout or stream=stderr keeps only that stream’s lines, and the gaps that touch it, with either value of follow.
Entries
Each entry is aline or a gap, and carries a position:
Lines are in the order they were stored, which closely follows the order the sandbox printed them; lines a few seconds apart can interleave. Output reaches the API a few seconds after the sandbox prints it.
Output that isn’t available appears in place as a
gap, never silently skipped:
stream, from_ts, to_ts, and records are null when unknown; a null stream means the gap touches both streams.
Only pass positions the API returned. Any other value is 422.
Read Pages
Paging uses a cursor, because the log keeps growing.page[size] is 1–100 (default 20). Pass meta.next_page_after as page[after] for the next page; omit page[after] to start at the beginning of the retained log.
meta.next_page_after is null once the end of what is stored so far is reached. To poll a running sandbox, keep the last entry’s position and read again later.
The CLI reads every page for you: the sandbox’s stdout lines go to your stdout and its stderr lines to your stderr, with gaps shown in place. --json prints one entry per line, with its position, and --after starts after a position.
Follow Live
-f, the CLI resumes a dropped stream where it left off and returns once the sandbox has ended and every line was printed, saying whether the log is complete. The stream itself:
A comment line (
: heartbeat) arrives every 30 seconds. A sandbox that hasn’t ended, queued sandboxes included, never gets end.
Connections can be cut, for example by the edge proxy after about 600 seconds. Reconnect with the Last-Event-ID header (or page[after]) set to the last id received to continue without gaps or duplicates. When both are given, page[after] wins.
End of Log
end carries the log’s final status:
The sandbox itself shows the same outcome in
logs_incomplete and logs_incomplete_reason:
Log Bucket
Logs are stored in a Telnyx Cloud Storage bucket in your account. The sandbox’slog_bucket field names it, and is null until the bucket is known.
- Default. Without
log_bucket, the sandbox uses a bucket created for you in your account, with a 30-day lifecycle rule. An account’s first sandbox can wait for that bucket to be created before it waits for capacity. - Your own bucket.
log_bucketon create names a bucket of yours. It must exist, belong to your organization, be in the Cloud Storage region GPU Sandboxes stores logs in, and be writable; otherwise the create fails with422 log_bucket_not_allowed. Retention is whatever lifecycle rules the bucket has.
Object Layout
The logs can be read with any S3-compatible tool undersandboxes/{sandbox_id}/ in the bucket. Objects are zstd-compressed NDJSON, one record per line:
Removing or changing these objects shows up as
expired gaps in the API.
Limits
- Each organization can have a limited number of log streams open at once. Beyond it, a request fails with
429 too_many_log_readers; close a stream or retry later. - Output is subject to a per-sandbox size cap. Output beyond it is reported as a
size_cap_reachedgap.