# Telnyx Compute: GPU Sandboxes — Full Documentation > Complete page content for GPU Sandboxes (Compute section) of the Telnyx developer docs (https://developers.telnyx.com). > This file: https://developers.telnyx.com/docs/development/llms/compute-gpu-sandboxes-llms-full-txt · Root index: https://developers.telnyx.com/llms.txt ## Overview ### Overview > Source: https://developers.telnyx.com/docs/gpu-sandboxes.md **Invite-only preview.** GPU Sandboxes is available only to accounts enabled for the preview. Check yours with [`GET /v2/ai/sandbox-access`](/docs/gpu-sandboxes/api-conventions#check-access). Every other GPU Sandboxes endpoint answers `403 sandboxes_not_whitelisted` for an account that isn't enabled. GPU Sandboxes rent a whole GPU node for a container image of your choice. For CPU-only sandboxes that run agent code, see [Agent Sandboxes](/docs/edge-compute/sandboxes). A sandbox runs one container image in its own virtual machine on Telnyx bare-metal hardware. Each sandbox currently rents a **whole GPU node**: it gets every GPU on the node, and no other sandbox shares it. Its CPU, memory, and disk are listed with the GPU type. A sandbox can run for a few seconds or indefinitely (`timeout: null`). It is billed per second while running. Use GPU Sandboxes through the Telnyx CLI (`telnyx-edge sandbox-gpu`) or the REST API under `https://api.telnyx.com/v2/ai`, with your Telnyx API key. [Get Started](/docs/gpu-sandboxes/quickstart) shows both. ## What You Can Do | Capability | Endpoint | Guide | | --- | --- | --- | | Check access | [`GET /v2/ai/sandbox-access`](/api-reference/sandbox-access/check-sandboxes-access) | [API conventions](/docs/gpu-sandboxes/api-conventions#check-access) | | List GPU types and prices | [`GET /v2/ai/sandbox-gpu-types`](/api-reference/sandbox-gpu-types/list-gpu-types) | [GPU types and billing](/docs/gpu-sandboxes/resources) | | Create a sandbox | [`POST /v2/ai/sandboxes`](/api-reference/sandboxes/create-a-sandbox) | [Lifecycle](/docs/gpu-sandboxes/lifecycle) | | Find sandboxes | [`GET /v2/ai/sandboxes`](/api-reference/sandboxes/list-sandboxes), [`GET …/{sandbox_id}`](/api-reference/sandboxes/get-a-sandbox) | [Lifecycle](/docs/gpu-sandboxes/lifecycle#listing-and-retention) | | Wait for a sandbox to end | [`GET …/{sandbox_id}/wait`](/api-reference/sandboxes/wait-for-a-sandbox-to-end) | [Lifecycle](/docs/gpu-sandboxes/lifecycle#wait-for-a-sandbox-to-end) | | Terminate a sandbox | [`POST …/{sandbox_id}/terminate`](/api-reference/sandboxes/terminate-a-sandbox) | [Lifecycle](/docs/gpu-sandboxes/lifecycle#stopping) | | Run commands in a running sandbox | [`POST …/{sandbox_id}/execs`](/api-reference/sandbox-execs/run-a-command-in-a-sandbox) | [Execs](/docs/gpu-sandboxes/execs) | | Stream a command's output and write its stdin | WebSocket `…/execs/{exec_id}/attach` | [WebSocket attach](/docs/gpu-sandboxes/attach) | | Read, write, list, and delete files | [`GET`](/api-reference/sandbox-files/read-a-file-or-list-a-directory), [`PUT`](/api-reference/sandbox-files/write-a-file-or-create-a-directory), [`DELETE …/files`](/api-reference/sandbox-files/delete-a-file-or-directory) | [Files](/docs/gpu-sandboxes/files) | | Read or follow the main process's output | [`GET …/logs`](/api-reference/sandbox-logs/read-or-follow-a-sandboxs-logs) | [Logs](/docs/gpu-sandboxes/logs) | | Read CPU, memory and network usage | [`GET …/metrics`](/api-reference/sandbox-metrics/get-a-sandboxs-metrics) | [Metrics](/docs/gpu-sandboxes/metrics) | ## Key Behavior - **Asynchronous start.** `POST /v2/ai/sandboxes` returns at once with `state: queued`. The sandbox then goes through `preparing` (when its GPUs need preparing), `scheduled`, and `starting` (pulling the image) to `running`. When no node is free, it waits in the queue for up to `queue_timeout` seconds. - **Whole-node GPU rental.** A sandbox names a GPU type and a count from the type's `allowed_counts`. Currently each type lists one count, its node's GPU count, so the sandbox gets the whole node. Its CPU, memory, and disk come from the type. - **Processes outlive connections.** Execs keep running when a client disconnects. Reconnect from anywhere and replay output from a byte offset. - **Logs in your own bucket.** The main process's stdout and stderr are stored in a Telnyx Cloud Storage bucket in your account, readable through the API or any S3 tool. - **Restricted network.** A sandbox reaches the public internet only, never Telnyx internal addresses. Outbound access can be limited to a CIDR allowlist or turned off entirely. Sandboxes accept no inbound connections. - **Retry-safe writes.** Every side-effecting endpoint accepts an `Idempotency-Key` header. A retried create returns the same sandbox instead of starting, and billing, a second one. ## Next Steps Create a GPU sandbox, run a command, read a file, and terminate it. States, termination reasons, timeouts, and readiness. Node types, sizing, GPU limits, queueing, and per-second billing. Run commands, wait for exit codes, send signals. --- ## Get Started ### Get Started > Source: https://developers.telnyx.com/docs/gpu-sandboxes/quickstart.md Each tab below does the same thing: it creates a GPU sandbox, runs a command in it, reads the result, and terminates the sandbox. Use the Telnyx CLI from a terminal, or the REST API directly with curl. The sandbox rents a whole GPU node and is billed per second from the moment it is `running` until it is `terminated`. Each example sets the sandbox's timeout to 30 minutes so a stopped script cannot leave it running indefinitely. ## Before You Start - Your account must be enabled for the GPU Sandboxes preview. See [Check access](/docs/gpu-sandboxes/api-conventions#check-access). - Set `TELNYX_API_KEY` to your Telnyx API key. Don't put it in shared logs. ## Run a Sandbox Install the Telnyx CLI, `telnyx-edge`, as described in [Installation](/docs/edge-compute/reference/cli#installation), then store your API key in it: ```bash telnyx-edge auth api-key set "$TELNYX_API_KEY" ``` The examples use `jq`. Run them in order in the same shell. ```bash telnyx-edge sandbox-gpu gpu-types GPU=$(telnyx-edge sandbox-gpu gpu-types --json | jq -er '.[0] | "\(.type):\(.allowed_counts[0])"') echo "$GPU" ``` `gpu-types` lists each GPU type with its GPU count per node, and the CPU, memory, and disk that come with each GPU. `--gpu` takes a type and its count as `TYPE:COUNT`, for example `B300:8`. Currently each type has one count, the number of GPUs on its node, so the second line takes both from the list instead of hard-coding them. ```bash SANDBOX=$(telnyx-edge sandbox-gpu create --name quickstart \ --image ubuntu:24.04 --gpu "$GPU" \ --timeout 1800 --queue-timeout 600 --tag purpose=quickstart \ --wait -- sh -c 'echo sandbox started; exec sleep infinity') echo "$SANDBOX" ``` The command after `--` replaces the image's own: it prints a line, then sleeps so the sandbox stays up for commands. `create` prints the sandbox's ID, and `--wait` returns once the sandbox is `running`. The commands below take the ID or the name. If the sandbox ends before `running`, `telnyx-edge sandbox-gpu get "$SANDBOX"` shows its `termination_reason`: for example `queue_timeout` when no node became free in time, or `image_pull_failed`. ```bash telnyx-edge sandbox-gpu exec "$SANDBOX" -- sh -c 'nvidia-smi | tee /tmp/gpus.txt' ``` `nvidia-smi` lists the GPUs you rented. The driver and `nvidia-smi` are provided in every GPU sandbox, so the plain Ubuntu image needs nothing added; see [GPUs](/docs/gpu-sandboxes/images#gpus). `exec` streams the command's output to your terminal and exits with its exit code. Put the command after `--` so its own flags aren't read as the CLI's. ```bash telnyx-edge sandbox-gpu files get "$SANDBOX" /tmp/gpus.txt - telnyx-edge sandbox-gpu files ls "$SANDBOX" /tmp ``` `-` writes the file to stdout. Without it, the file is saved under its own name in the current directory. ```bash telnyx-edge sandbox-gpu logs "$SANDBOX" ``` The logs hold the main process's output, `sandbox started`, but not the exec's. Add `-f` to keep following new output. ```bash telnyx-edge sandbox-gpu terminate "$SANDBOX" --yes --wait ``` The main process gets `SIGTERM`, then `SIGKILL` if it is still running after a grace period. `--yes` skips the confirmation prompt, and `--wait` returns once the sandbox is `terminated`. Run the blocks below in order in the same **Bash** shell with `curl`, `jq`, and `uuidgen` installed. Every ID below comes from your own responses. ```bash set -euo pipefail : "${TELNYX_API_KEY:?Set TELNYX_API_KEY to your Telnyx API key first}" API="https://api.telnyx.com/v2/ai" api() { curl --fail-with-body --silent --show-error --connect-timeout 10 \ --max-time 60 -H "Authorization: Bearer $TELNYX_API_KEY" "$@" } ``` ```bash api "$API/sandbox-access" | jq -e '.data.whitelisted' ``` `true` means the account is enabled for the preview. `false` means every other GPU Sandboxes endpoint answers `403 sandboxes_not_whitelisted`. ```bash api "$API/sandbox-gpu-types" | jq '.data[] | {type, allowed_counts, cpu, memory_mib, disk_gib, root_disk_gib, prices}' GPU_TYPE=$(api "$API/sandbox-gpu-types" | jq -er '.data[0].type') GPU_COUNT=$(api "$API/sandbox-gpu-types" | jq -er --arg t "$GPU_TYPE" '.data[] | select(.type == $t) | .allowed_counts[0]') printf 'Renting a %s node with %s GPUs\n' "$GPU_TYPE" "$GPU_COUNT" ``` `allowed_counts` lists the GPU counts a type can be rented with. Currently each type lists one, the number of GPUs on its node, so the script takes it from the list instead of hard-coding it. The sandbox gets that type's `cpu`, `memory_mib`, and `disk_gib` defaults multiplied by the count. The main process prints a line, then sleeps so the sandbox stays up for execs. The `Idempotency-Key` makes the create safe to retry: a retry with the same key returns the same sandbox. ```bash CREATE_BODY=$(jq -n --arg type "$GPU_TYPE" --argjson count "$GPU_COUNT" '{ name: "quickstart", image: {ref: "ubuntu:24.04"}, command: ["sh", "-c", "echo sandbox started; exec sleep infinity"], gpu: {type: $type, count: $count}, timeout: 1800, queue_timeout: 600, tags: {purpose: "quickstart"} }') # Set once, so running this block again after a lost response retries with the same key. : "${CREATE_KEY:=$(uuidgen)}" SANDBOX=$(api -X POST "$API/sandboxes" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $CREATE_KEY" \ -d "$CREATE_BODY") SANDBOX_ID=$(jq -er '.data.id' <<< "$SANDBOX") printf 'Sandbox: %s (%s)\n' "$SANDBOX_ID" "$(jq -r '.data.state' <<< "$SANDBOX")" ``` Creation returns `201` with `state: queued`. ```bash while :; do SANDBOX=$(api "$API/sandboxes/$SANDBOX_ID") STATE=$(jq -er '.data.state' <<< "$SANDBOX") case "$STATE" in running) break ;; terminated) jq '.data | {termination_reason, termination_message, exit_code}' <<< "$SANDBOX" >&2 exit 1 ;; esac printf 'state: %s\n' "$STATE" sleep 5 done jq '.data | {state, ready, started_at, cpu, memory_mib, disk_gib, resolved}' <<< "$SANDBOX" ``` `resolved.image` shows the image pinned by digest. If the sandbox ends before `running`, `termination_reason` says why: for example `queue_timeout` when no node became free within `queue_timeout`, or `image_pull_failed` with details in `termination_message`. ```bash # Set once, so running this block again retries with the same key and never runs the command twice. : "${EXEC_KEY:=$(uuidgen)}" EXEC=$(api -X POST "$API/sandboxes/$SANDBOX_ID/execs" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $EXEC_KEY" \ -d '{"command": ["sh", "-c", "nvidia-smi > /tmp/gpus.txt"]}') EXEC_ID=$(jq -er '.data.id' <<< "$EXEC") # Long-poll: each call returns when the exec ends or after at most 10 s. while :; do EXEC=$(api "$API/sandboxes/$SANDBOX_ID/execs/$EXEC_ID?wait=10") case "$(jq -er '.data.status' <<< "$EXEC")" in exited|failed|terminated) break ;; esac done jq '.data | {status, exit_code, reason}' <<< "$EXEC" ``` `nvidia-smi` lists the GPUs you rented; the driver and `nvidia-smi` are provided in every GPU sandbox, see [GPUs](/docs/gpu-sandboxes/images#gpus). The exec runs in the sandbox's working directory and environment, and writes its output to a file read in the next step. To stream an exec's output and write to its stdin, use the [WebSocket attach](/docs/gpu-sandboxes/attach). ```bash api "$API/sandboxes/$SANDBOX_ID/files?path=/tmp/gpus.txt" api "$API/sandboxes/$SANDBOX_ID/files?path=/tmp&list=true" | jq '.data[] | {name, type, size_bytes}' ``` A read returns the file's raw bytes. With `list=true`, the endpoint lists the directory as JSON instead. ```bash api "$API/sandboxes/$SANDBOX_ID/logs" | jq '.data[] | {ts, stream, line}' ``` Output reaches the logs a few seconds after the process prints it. Add `follow=true` to stream it as Server-Sent Events. ```bash api -X POST "$API/sandboxes/$SANDBOX_ID/terminate" | jq '.data.state' until [[ $(api "$API/sandboxes/$SANDBOX_ID/wait?timeout=10" | jq -er '.data.state') == terminated ]]; do :; done api "$API/sandboxes/$SANDBOX_ID" | jq '.data | {state, termination_reason, exit_code, terminated_at}' # Clear the keys so that a later run creates a new sandbox and a new exec. unset CREATE_KEY EXEC_KEY ``` The main process gets `SIGTERM`, then `SIGKILL` if it is still running after a grace period. The sandbox ends with `termination_reason: terminated_by_user`. Terminated sandboxes stay readable for at least 30 days. ## Next Steps - [Lifecycle](/docs/gpu-sandboxes/lifecycle): states, timeouts, readiness probes, and termination reasons. - [Execs](/docs/gpu-sandboxes/execs) and [WebSocket attach](/docs/gpu-sandboxes/attach): interactive commands and resumable output. - [Images and environment](/docs/gpu-sandboxes/images): how the command, working directory, and environment are resolved. --- ## Concepts ### Lifecycle > Source: https://developers.telnyx.com/docs/gpu-sandboxes/lifecycle.md ## States ```text queued ──► preparing ──► scheduled ──► starting ──► running ──► terminated ``` | State | Meaning | | --- | --- | | `queued` | Accepted. The image is being resolved, and the sandbox waits for a free node. | | `preparing` | GPUs are being prepared for the sandbox. Skipped when no preparation is needed. | | `scheduled` | A node is assigned. | | `starting` | The image is being pulled and the sandbox's VM is starting. | | `running` | The main process is running. Billing runs only in this state. | | `terminated` | Final. `termination_reason` says why. | Any non-terminal state can go straight to `terminated`. Follow a sandbox with `GET /v2/ai/sandboxes/{sandbox_id}`, or wait for it to end with [`GET …/wait`](#wait-for-a-sandbox-to-end). ## Termination Reasons `termination_reason` is always set once `state` is `terminated`. `exit_code` is set whenever the main process ran. | Reason | When | | --- | --- | | `exit` | The main process exited on its own. See `exit_code`. | | `timeout` | The sandbox reached its `timeout`. | | `idle_timeout` | The sandbox had no activity for `idle_timeout` seconds. | | `queue_timeout` | It was still queued or preparing after `queue_timeout` seconds. | | `terminated_by_user` | `POST …/terminate` was called. A queued or preparing sandbox is cancelled at once. | | `image_pull_failed` | The image can't be used. `termination_message` says why when it's known. | | `no_command` | The image has no `ENTRYPOINT` or `CMD`, and the request has no `command`. | | `oom_killed` | The sandbox ran out of memory. | | `disk_limit_exceeded` | The sandbox wrote more outside `/data` than its root filesystem limit (`root_disk_gib`). | | `account_suspended` | The account lost access. | | `killed_by_operator` | Telnyx stopped the sandbox. | | `spend_limit_reached` | The account, or the API key that created the sandbox, reached its GPU Sandboxes spend limit. The sandbox isn't restarted when the limit is raised. | | `node_lost` | The sandbox's node failed. | | `internal_error` | Telnyx couldn't start or keep the sandbox running. | A process killed by a signal reports `exit_code` 128 plus the signal number: 137 for `SIGKILL`, 143 for `SIGTERM`. `termination_message` is set in two cases only. With `internal_error`, it holds a short reason from Telnyx, such as the sandbox's disk not being ready. With `image_pull_failed` before the sandbox ran, it holds the registry's own message or what the image checks found (the reference, the image's platform, `ENTRYPOINT`/`CMD`, `WorkingDir`, or `User`). It is text from your registry, shown as received with control characters removed. ## Timeouts | Field | Default | Range | Counts | | --- | --- | --- | --- | | `timeout` | 300 s | 1 s or more; `null` for no limit | From `started_at`. Queue time, GPU preparation, and image pulls don't count. | | `idle_timeout` | none | 1 s up to `timeout` | Time without activity, while running. | | `queue_timeout` | 600 s | 0–86,400 s | Resolving the image, waiting for a node, and preparing GPUs. | Send `"timeout": null` explicitly for a sandbox with no lifetime limit. A client that drops `null` fields from the JSON body gets the 300 s default. **Activity** for `idle_timeout` is an exec running, starting, or finishing, and stdin written to an exec or to the main process. Reading output, file calls, and the main process's own work don't count. A sandbox whose main process is a server, with nothing else going on, ends after `idle_timeout`. With `queue_timeout: 0`, a sandbox always ends `queue_timeout`, because resolving the image counts. The first sandbox of an account can also wait for its [log bucket](/docs/gpu-sandboxes/logs#log-bucket) to be created before its queue time starts. ## Stopping `POST /v2/ai/sandboxes/{sandbox_id}/terminate` stops a sandbox: - A queued or preparing sandbox is cancelled at once. - A placed sandbox is stopped asynchronously. Its processes get `SIGTERM`, then `SIGKILL` if they are still running after a grace period. It reaches `terminated` with `termination_reason: terminated_by_user` and the main process's `exit_code` if it ran. - A sandbox that already ended on its own keeps its own reason. Terminating a terminated sandbox succeeds and changes nothing. The response returns `202` with the sandbox as it is at that moment. [File calls](/docs/gpu-sandboxes/files) keep working during the grace period, so results can still be fetched from a sandbox that is ending. When `timeout` and a terminate request overlap, the earlier one wins. A stop that comes after the main process already exited changes nothing. ## Wait for a Sandbox to End `GET /v2/ai/sandboxes/{sandbox_id}/wait?timeout=10` is a long poll. It returns `200` with the sandbox as soon as it is `terminated`, or after at most 10 seconds. Larger `timeout` values are clamped to 10; `0` returns at once. Call it again until `state` is `terminated`. This waits for a long-running sandbox without holding one connection open. ## Readiness `ready` tells whether the sandbox can serve its purpose. Without a probe, it is `true` once the sandbox is `running`. With `readiness_probe`, set exactly one of: | Field | Ready once | | --- | --- | | `tcp_port` | The port (1–65535) accepts connections inside the sandbox. | | `exec` | The command (argv) exits with `0`. | ```json { "readiness_probe": { "exec": ["test", "-f", "/tmp/model-loaded"] } } ``` ## Names and Tags - **`name`** (optional): 1–64 characters of `A-Z`, `a-z`, `0-9`, `.`, `_`, `-`. It is unique among the account's non-terminated sandboxes (`409 name_conflict` otherwise) and reusable once the sandbox holding it ends. Look a sandbox up with `GET /v2/ai/sandboxes?name=`. - **`tags`** (optional): up to 20 key/value labels. Keys are 1–63 characters, values up to 255. Filter with `GET /v2/ai/sandboxes?tag[project]=llm-ft`; every given tag must match. `PATCH /v2/ai/sandboxes/{sandbox_id}` with `{"tags": {...}}` replaces the whole tag set; `{}` clears it. Tags are the only thing that can change after create, and they can change on terminated sandboxes too. ## Listing and Retention `GET /v2/ai/sandboxes` lists sandboxes newest first. Without `state`, it lists only non-terminated sandboxes. Add `state=terminated` for finished ones, or repeat `state` for several. Sandboxes belong to the organization: every user in it sees and manages them. Terminated sandboxes and their execs stay readable for at least 30 days. [Metrics](/docs/gpu-sandboxes/metrics) are kept for 30 days. --- ### GPU Types and Billing > Source: https://developers.telnyx.com/docs/gpu-sandboxes/resources.md ## GPU Types `GET /v2/ai/sandbox-gpu-types` lists the GPU types the account can rent. Only enabled, qualified types are listed; requesting anything else fails with `422 resources_not_allowed`. ```json { "data": [ { "type": "B300", "allowed_counts": [8], "cpu": { "default": 24, "max": 24 }, "memory_mib": { "default": 262144, "max": 262144 }, "disk_gib": { "default": 1024, "max": 1024 }, "root_disk_gib": 200, "prices": [ { "sku": "sandbox.node.b300", "unit": "node-second", "amount": "…", "currency": "USD" } ] } ], "meta": { "page_number": 1, "page_size": 20, "total_pages": 1, "total_results": 1 } } ``` The values above illustrate the shape only. Read the actual catalog from the API. | Field | Description | | --- | --- | | `type` | GPU type to pass as `gpu.type`. | | `allowed_counts` | The GPU counts that can be requested as `gpu.count`. Currently each type lists exactly one, its node's GPU count, so a sandbox rents the whole node. Read `gpu.count` from this list rather than hard-coding it. | | `cpu`, `memory_mib`, `disk_gib` | CPU cores, memory, and the size of `/data` (the sandbox's own disk) per GPU. A sandbox gets `default` × its GPU count. `max` equals `default`. | | `root_disk_gib` | Limit in GiB of the root filesystem: the image plus everything written outside `/data`. It applies to the whole sandbox, whatever its GPU count. | | `prices` | Billed units and prices. `null` until prices are published. | ### Worked Example With the `B300` entry above, `"gpu": {"type": "B300", "count": 8}` gives the sandbox: | Field | Per GPU | Calculation | On the sandbox | | --- | --- | --- | --- | | `cpu` | 24 cores | 24 × 8 | `"cpu": 192` | | `memory_mib` | 262,144 MiB (256 GiB) | 262,144 × 8 | `"memory_mib": 2097152` (2 TiB) | | `disk_gib` | 1,024 GiB | 1,024 × 8 | `"disk_gib": 8192` | The totals are calculated when the sandbox is created and stored with it. `GET /v2/ai/sandboxes/{sandbox_id}` returns them as `cpu`, `memory_mib`, and `disk_gib`, and a later change to the catalog doesn't change an existing sandbox. `cpu` is a number and can be fractional. ## Whole-Node Rental Each sandbox currently rents a whole GPU node. `gpu` is required and names a type and a count from its `allowed_counts`. The CLI takes it as `TYPE:COUNT`: ```bash CLI telnyx-edge sandbox-gpu create --image ghcr.io/acme/trainer:1.4 --gpu B300:8 --timeout 36000 \ -- python train.py ``` ```json REST { "image": { "ref": "ghcr.io/acme/trainer:1.4" }, "command": ["python", "train.py"], "gpu": { "type": "B300", "count": 8 }, "timeout": 36000 } ``` - The sandbox gets every GPU on one node of that type, with that type's `cpu`, `memory_mib`, and `disk_gib` defaults multiplied by the count. These values appear on the sandbox. - No other sandbox shares the node. - `disk_gib` is the size of `/data`, the sandbox's own disk, mounted in every sandbox. Writing past its size fails with "no space left on device", and the sandbox keeps running. - Everything written outside `/data` (the image's directories, `/tmp`, caches, package installs) counts against the root filesystem's separate limit, `root_disk_gib`. Going past it ends the sandbox with `disk_limit_exceeded`. - Nothing on either survives the sandbox: persist data to [Cloud Storage](/docs/cloud-storage/overview) from inside the sandbox. ## GPU Limits Each organization has a limit per GPU type: the most GPUs of that type its sandboxes can hold at once. Every sandbox that hasn't ended counts, queued and preparing ones included. A create that would take the organization over its limit for the requested type fails at once with `429 quota_exceeded`, and the error's detail names the type, the limit, the GPUs in use, and the GPUs requested. It is never queued. Contact support to raise a limit. ## Queueing When the organization is within its GPU limit but no node of the requested type is free, the sandbox waits in `queued`. Once a node is found, it can spend time in `preparing` while its GPUs are prepared. `queue_timeout` (default 600 seconds, maximum 86,400) covers both: a sandbox still queued or preparing when it passes ends with `termination_reason: queue_timeout`. Queued and preparing time isn't billed. ## Billing - The billing clock starts when the sandbox enters `running` (`started_at`) and stops when it is `terminated`. Time in `queued`, `preparing`, `scheduled`, and `starting`, including image pulls, is free. - A sandbox is billed per node type, per second. The price list is in `prices` on `GET /v2/ai/sandbox-gpu-types`. - What is billed is the rented node over wall-clock time, not measured utilization. - Set `timeout` or `idle_timeout` to bound the cost of a sandbox that is left running. --- ### Images and Environment > Source: https://developers.telnyx.com/docs/gpu-sandboxes/images.md ## Images `image.ref` is a standard image reference of up to 1,024 characters, such as `ubuntu:24.04`, `docker.io/library/python:3.12-slim`, or `ghcr.io/acme/trainer:1.4@sha256:…`. - The image must be publicly pullable and have a `linux/amd64` variant. - The registry must be a public DNS name. IP literals, `localhost`, single-label hosts, and registries that resolve to internal addresses fail with `422 registry_not_allowed`. - Before the sandbox is placed, the reference is resolved to the `linux/amd64` manifest's digest, and the image's configuration is read from it. The sandbox then runs exactly that digest, even if the tag moves later. The pinned reference appears as `resolved.image` (`host/repo@sha256:…`). - An image that can't be pulled or used ends the sandbox with `termination_reason: image_pull_failed` and, when known, the registry's message or the failed check in `termination_message`. Images run as the user their configuration names, `root` included. The sandbox's VM isolates the container from the host and from other sandboxes. ## GPUs Every GPU on the sandbox's node is passed through to its VM, and the NVIDIA driver runs in the VM. When the container starts, it gets the GPU devices (`/dev/nvidia*`), the driver's libraries (such as `libcuda` and `libnvidia-ml`), and `nvidia-smi`. A plain `ubuntu:24.04` image can run `nvidia-smi` without any changes. - **Don't install an NVIDIA driver in the image.** The driver is provided, and driver libraries in the image can conflict with the ones added at start. - **Use a glibc-based image**, such as Debian, Ubuntu, or an `nvidia/cuda` image. The driver's libraries and tools are built for glibc and don't run in musl-based images such as Alpine. - **Bring the CUDA libraries your workload needs** in the image, for example from an `nvidia/cuda` base image or a framework image such as PyTorch's. Their CUDA version can't be newer than the driver supports, which `nvidia-smi` shows as `CUDA Version`. ## Command | Request | Main process | | --- | --- | | `command` set | `command` is the full argv. It replaces both the image's `ENTRYPOINT` and `CMD`. | | `command` omitted | The image's `ENTRYPOINT` followed by its `CMD`. | | Neither | The sandbox ends with `termination_reason: no_command`. | Entrypoint wrapper scripts (`docker-entrypoint.sh "$@"` style) work unchanged. The final argv appears as `resolved.command`. ## Working Directory `workdir` must be an absolute path (`422 invalid_workdir` otherwise). Without it, the image's `WorkingDir` is used, then `/`. Execs default to the same directory. The final value appears as `resolved.workdir`. ## Environment Variables The environment is merged in this order, later entries winning: 1. The image's `Env`. 2. Variables set by Telnyx: | Variable | Value | | --- | --- | | `TELNYX_SANDBOX_ID` | The sandbox's ID (`sb-…`). | | `TELNYX_SANDBOX_REGION` | The region the sandbox runs in. | | `TELNYX_SANDBOX_DATA_DIR` | `/data`, the path of the sandbox's own disk. | 3. The request's `env`. `env` names must be POSIX names and can't start with `TELNYX_SANDBOX_`. The limits are 256 variables, 32 KiB per variable, and 256 KiB in total. Any violation fails with `422 invalid_env`. Execs inherit the sandbox's environment and can add variables on top. `env` values are stored with the sandbox and returned by `GET /v2/ai/sandboxes/{sandbox_id}` and the exec endpoints. Don't put credentials in `env`. To give a sandbox a credential, write it to a file with the [Files](/docs/gpu-sandboxes/files) API once the sandbox is running; file contents aren't stored by the API. ## Reserved Paths `/.telnyx` inside the sandbox is reserved. The [Files](/docs/gpu-sandboxes/files) API refuses to write or delete under it. ## Persistent Data Sandboxes have no persistent volumes or snapshots. `/data`, the sandbox's own disk, and the root filesystem are both gone when the sandbox ends. Write large files such as model weights and caches under `/data`: everything written outside it counts against the root filesystem limit (see [Whole-Node Rental](/docs/gpu-sandboxes/resources#whole-node-rental)). Read inputs from and write results to [Telnyx Cloud Storage](/docs/cloud-storage/overview) or another S3-compatible store from inside the sandbox. Use the [Files](/docs/gpu-sandboxes/files) API for files of up to 64 MiB. --- ### Networking > Source: https://developers.telnyx.com/docs/gpu-sandboxes/networking.md Each sandbox has one network mode, fixed at create and shown as `network_mode`. Every mode denies inbound connections and access to Telnyx internal addresses. | `network_mode` | Request | Outbound access | DNS | | --- | --- | --- | --- | | `public` | Default | The public internet | Public resolvers | | `allowlist` | `cidr_allowlist: ["…"]` | Only the listed CIDRs | Not included | | `blocked` | `block_network: true` | None | None | `block_network` and `cidr_allowlist` can't be combined. ## Public The default. The sandbox reaches any public internet address, including `api.telnyx.com` and Telnyx Cloud Storage, and resolves names through public DNS resolvers. Internal addresses are never reachable or resolvable. ## Allowlist ```json { "cidr_allowlist": ["203.0.113.0/24", "198.51.100.7/32"] } ``` - Outbound traffic is allowed only to the listed CIDRs. - Internal ranges are always excluded. A CIDR that lies entirely inside them fails with `422 cidr_not_allowed`. A CIDR that contains internal ranges, such as `0.0.0.0/0`, is allowed minus those ranges. - DNS isn't included. Add your resolvers' addresses to the list, or connect to IP addresses directly. ## Blocked ```json { "block_network": true } ``` The sandbox has no network at all, not even DNS. Execs, files, logs, and metrics keep working: they don't use the sandbox's network. ## Inbound Connections Sandboxes accept no inbound connections, and ports can't be exposed. Interact with a running sandbox through [execs](/docs/gpu-sandboxes/execs), [WebSocket attach](/docs/gpu-sandboxes/attach), and [files](/docs/gpu-sandboxes/files). --- ## Guides ### Execs > Source: https://developers.telnyx.com/docs/gpu-sandboxes/execs.md An exec is a process started in a running sandbox. It keeps running when the client that started it disconnects, and its output can be replayed later from any machine. Execs live as long as their sandbox. ## Start an Exec ```bash CLI telnyx-edge sandbox-gpu exec "$SANDBOX_ID" --workdir /app --env BATCH_SIZE=64 --timeout 3600 \ -- python eval.py --checkpoint /app/ckpt ``` ```bash curl curl -X POST "https://api.telnyx.com/v2/ai/sandboxes/$SANDBOX_ID/execs" \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "command": ["python", "eval.py", "--checkpoint", "/app/ckpt"], "workdir": "/app", "env": {"BATCH_SIZE": "64"}, "timeout": 3600 }' ``` - **CLI:** `exec` streams the command's stdout and stderr to yours and exits with its exit code. With `-i`, your stdin is passed to the command; with `--detach` (`-d`), the command starts and its exec ID is printed. Both send an `Idempotency-Key`. The CLI also resumes reading output after a dropped connection; with curl, read the output through the [exec attach WebSocket](/docs/gpu-sandboxes/attach#exec-attach). | Field | Required | Description | | --- | --- | --- | | `command` | Yes | Argv. At most 4,096 arguments, each at most 131,071 bytes in UTF-8, 1 MiB in total, and no NUL byte (`422 invalid_command` otherwise). | | `workdir` | No | Absolute working directory. Defaults to the sandbox's. | | `env` | No | Extra variables on top of the sandbox's environment, with the same rules as on create (`422 invalid_env`). | | `timeout` | No | Stop the process after this many seconds (status `terminated`, reason `timeout`). Default: no limit. An exec never outlives its sandbox. | Through the REST API, the call returns `201` at once, without waiting for the command or streaming its output. The exec is `running`, or `exited` with its `exit_code` if it already finished. - If the sandbox can't confirm the start within a few seconds, the exec comes back `starting` and the start completes in the background. A start that can't be confirmed within 5 minutes ends `failed` with reason `agent_unavailable`. - The sandbox must be `running` (`409 sandbox_not_running` otherwise). - Send an `Idempotency-Key`. A retry with the same key returns the same exec instead of running the command twice, and completes a start that is still `starting`. ## Statuses ```text starting ──► running ──► exited │ └─────► terminated └──► failed ``` | Status | Meaning | | --- | --- | | `starting` | The start isn't confirmed yet. | | `running` | The process is running. | | `exited` | The process ended. `exit_code` is set: 128 plus the signal number when a signal killed it. | | `terminated` | The process was stopped because its sandbox ended (`sandbox_terminated`) or its `timeout` was reached (`timeout`). | | `failed` | The process was never confirmed started. See `reason`. | | `reason` | Meaning | | --- | --- | | `sandbox_terminated` | The sandbox ended, or was ending, first. | | `timeout` | The exec's `timeout` was reached. | | `agent_unavailable` | The sandbox didn't confirm the start in time. | | `cancelled` | `SIGKILL` was sent before the start was confirmed. | | `agent_error` | The sandbox returned an inconsistent answer. | An exec that is `failed` with `agent_unavailable` or `cancelled` can still move on to `running`, `exited`, or `terminated` if its start did reach the sandbox. ## Wait for an Exec `GET /v2/ai/sandboxes/{sandbox_id}/execs/{exec_id}?wait=10` is a long poll: it returns `200` as soon as the exec has ended, or after at most 10 seconds. Call it again until `status` is `exited`, `failed`, or `terminated`. Without `wait`, it returns at once. If the sandbox can't answer, the response carries the last known state. `GET /v2/ai/sandboxes/{sandbox_id}/execs` lists a sandbox's execs, newest first, optionally filtered by repeated `status` parameters. A status in the list can lag the process by up to about 15 seconds; `GET …/execs/{exec_id}` asks the sandbox. ## Output and Stdin Exec output isn't part of the sandbox's [logs](/docs/gpu-sandboxes/logs). Read it, and write to the exec's stdin, through the [exec attach WebSocket](/docs/gpu-sandboxes/attach#exec-attach). The CLI's `exec` and `execs attach` commands use it for you. Each exec keeps at least its last 64 MiB of output for replay, within a per-sandbox total of 1/16 of the sandbox's memory, at most 256 MiB. That retained output counts against the sandbox's memory. `POST /v2/ai/sandboxes/{sandbox_id}/execs/{exec_id}/stdin/close` sends EOF to the exec's stdin, once the input already accepted has been written. Disconnecting from the attach WebSocket never sends EOF: a process reading stdin keeps waiting until it gets `stdin_eof` or this call. Closing twice, or closing an exec that ended, changes nothing. The CLI's equivalent is `telnyx-edge sandbox-gpu execs close-stdin`. ## Send a Signal ```bash CLI telnyx-edge sandbox-gpu execs kill "$SANDBOX_ID" "$EXEC_ID" --signal SIGTERM ``` ```bash curl curl -X POST "https://api.telnyx.com/v2/ai/sandboxes/$SANDBOX_ID/execs/$EXEC_ID/kill" \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{"signal": "SIGTERM"}' ``` The signal goes to the exec's process group. `signal` is one of `SIGTERM`, `SIGKILL` (default), `SIGINT`, `SIGHUP`, `SIGQUIT`, `SIGUSR1`, or `SIGUSR2`. - The call is asynchronous: it returns `202` with the exec as it is right after. With `SIGKILL`, the exec ends shortly after with `status: exited` and `exit_code: 137`. - Signalling an exec that already ended changes nothing. - An exec still `starting` can only be cancelled: `SIGKILL` ensures the command never runs, and it ends `failed` with reason `cancelled`. Any other signal fails with `409 exec_not_started`; retry once the exec is `running`. - With an `Idempotency-Key`, a retry replays the first answer. Two overlapping requests with the same key may both deliver the signal. ## Activity Starting, running, and finishing execs, and writing to an exec's stdin, count as activity for the sandbox's `idle_timeout`. See [Timeouts](/docs/gpu-sandboxes/lifecycle#timeouts). --- ### WebSocket Attach > Source: https://developers.telnyx.com/docs/gpu-sandboxes/attach.md Two WebSocket endpoints carry interactive I/O: | Endpoint | Carries | | --- | --- | | `wss://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/execs/{exec_id}/attach?offset=0` | An exec's stdout and stderr, replayed from a byte offset then live, and its stdin. | | `wss://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/attach` | The main process's stdin only. Its output comes through [logs](/docs/gpu-sandboxes/logs). | The CLI's `exec` and `execs attach` commands implement this protocol, resuming included. Use this page to build a client of your own. ## Connect Send the API key in the handshake's `Authorization: Bearer` header. Browsers can't set that header on a WebSocket, so connect from a server-side client. The handshake is an HTTP request. A refusal is an HTTP response with the standard Telnyx [error body](/docs/gpu-sandboxes/errors), never an opened-then-closed socket: | Status | Error | | --- | --- | | `401` | Missing or invalid API key. | | `403` | `sandboxes_require_verification`, `sandboxes_not_whitelisted`, or, for an exec attach, `sandboxes_disabled`. | | `404` | The sandbox or exec doesn't exist, or belongs to another account. | | `409` | `sandbox_not_running`. | | `422` | `offset_out_of_range`: `offset` is past the end of the exec's output so far. | | `429` | `too_many_attaches`: the sandbox already has the maximum number of open attach connections. Close one, or retry later. | | `503` | A dependency can't answer right now. Retry later. | Every message after the upgrade is a JSON text frame with a `type` field. Binary data is base64-encoded. ## Exec Attach The server replays the exec's combined output (stdout and stderr in the order written) from byte `offset`, then streams it live. ### Client Messages | `type` | Fields | Effect | | --- | --- | --- | | `stdin` | `data`: base64, at most 64 KiB decoded | Writes bytes to the exec's stdin. Messages are delivered whole and in order; the server takes the next one only after the process accepted this one. | | `stdin_eof` | — | Closes the exec's stdin (EOF). | ### Server Messages | `type` | Fields | Meaning | | --- | --- | --- | | `output` | `stream` (`stdout` or `stderr`), `offset`, `data` (base64) | A chunk of output. `offset` is the byte offset of `data` in the combined output. | | `truncated` | `oldest_offset` | The requested offset is older than the retained output, or the reader fell behind it. Replay continues at `oldest_offset`. | | `gap` | `offset`, `length` | Output in this range was lost and can't be replayed. Offsets still advance past it. | | `stdin_closed` | — | A `stdin` message arrived after stdin was closed and wasn't delivered. | | `exit` | `status`, `exit_code`, `reason` | The exec ended. The server then closes the connection with `1000`. | | `error` | `error` (a Telnyx error object) | Something went wrong. The server then closes the connection. | | `heartbeat` | — | Keeps the connection alive. Sent every 30 s, and every second while stdin is held back by a process that isn't reading it. Ignore it. | ### Resume Reconnect at any time, from anywhere, with `offset` set to: - after an `output` message: its `offset` plus the decoded length of its `data`; - after a `gap`: its `offset` plus its `length`; - after a `truncated`: its `oldest_offset`. Reconnecting this way also covers the edge proxy's connection limit of about 600 seconds. Each exec keeps at least its last 64 MiB of output, within the sandbox's total for exec output (1/16 of its memory, at most 256 MiB), oldest output deleted first. `offset=0` replays everything still retained. Disconnecting never sends EOF and never stops the process. Use `stdin_eof`, [`POST …/execs/{exec_id}/stdin/close`](/docs/gpu-sandboxes/execs#output-and-stdin), or [`POST …/kill`](/docs/gpu-sandboxes/execs#send-a-signal). ### Example: Follow an Exec's Output The following Python client (using the [`websockets`](https://pypi.org/project/websockets/) package, version 14 or later) prints an exec's output and resumes after a dropped connection: ```python import asyncio import base64 import json import os import sys import websockets API = "wss://api.telnyx.com/v2/ai" async def follow(sandbox_id: str, exec_id: str) -> None: headers = {"Authorization": f"Bearer {os.environ['TELNYX_API_KEY']}"} offset = 0 while True: url = f"{API}/sandboxes/{sandbox_id}/execs/{exec_id}/attach?offset={offset}" try: async with websockets.connect(url, additional_headers=headers) as ws: async for raw in ws: message = json.loads(raw) kind = message["type"] if kind == "output": data = base64.b64decode(message["data"]) out = sys.stdout if message["stream"] == "stdout" else sys.stderr out.buffer.write(data) out.flush() offset = message["offset"] + len(data) elif kind == "gap": offset = message["offset"] + message["length"] elif kind == "truncated": offset = message["oldest_offset"] elif kind == "exit": print(f"\n{message['status']}: exit_code={message['exit_code']}", file=sys.stderr) return elif kind == "error": raise RuntimeError(message["error"]) except websockets.ConnectionClosedError: pass # Cut connection or server restart: resume from `offset`. await asyncio.sleep(1) asyncio.run(follow(sys.argv[1], sys.argv[2])) ``` A refused handshake raises `websockets.InvalidStatus`, which this client doesn't retry. The client stops at the first `exit` message. An exec that ends `failed` with reason `agent_unavailable` or `cancelled` can still start afterwards (see [Statuses](/docs/gpu-sandboxes/execs#statuses)), so before treating one of those as final, read the exec again with `GET /v2/ai/sandboxes/{sandbox_id}/execs/{exec_id}`. ### Example: Write to an Exec's Stdin Start the exec with a command that reads stdin, then send input and EOF: ```python await ws.send(json.dumps({"type": "stdin", "data": base64.b64encode(b"hello\n").decode()})) await ws.send(json.dumps({"type": "stdin_eof"})) ``` ## Main Process Stdin `wss://api.telnyx.com/v2/ai/sandboxes/{sandbox_id}/attach` writes to the stdin of the sandbox's main process. It accepts the same client messages as the exec attach: `stdin` (at most 64 KiB decoded each) and `stdin_eof`. The server sends: | `type` | Fields | Meaning | | --- | --- | --- | | `exit` | `exit_code` | The main process ended. The server then closes the connection with `1000`. This `exit_code` is for display; the sandbox's own `exit_code` is authoritative. | | `stdin_closed` | — | A `stdin` message arrived after stdin was closed and wasn't delivered. | | `error` | `error` | Something went wrong. The server then closes the connection. | | `heartbeat` | — | Sent every 30 s. Ignore it. | Reconnect at any time. Disconnecting never sends EOF, so the process keeps waiting for input. `POST /v2/ai/sandboxes/{sandbox_id}/stdin/close` closes the main process's stdin without a WebSocket. ## Close Codes | Code | Meaning | Action | | --- | --- | --- | | `1000` | The process ended, after `exit`. | Done. | | `1008` | The client sent an invalid message. An `error` message precedes it. | Fix the message. | | `1009` | A message was over 128 KiB. | Send smaller `stdin` messages. | | `1011` | Another server error. | Reconnect and resume. | | `1012` | The server is restarting. | Reconnect and resume. | --- ### Files > Source: https://developers.telnyx.com/docs/gpu-sandboxes/files.md `/v2/ai/sandboxes/{sandbox_id}/files` reads and changes files inside a running sandbox. Every call takes an absolute `path` query parameter. | Operation | Request | Success | | --- | --- | --- | | Read a file | `GET …/files?path=/app/out.txt` | `200`, raw bytes | | List a directory | `GET …/files?path=/app&list=true` | `200`, JSON page | | Write a file | `PUT …/files?path=/app/in.txt` with the bytes as body | `201` created, `200` replaced | | Create a directory | `PUT …/files?path=/app/data&directory=true`, empty body | `201` created, `200` already there | | Delete | `DELETE …/files?path=/app/out.txt` | `204` | | Delete a directory tree | `DELETE …/files?path=/app/data&recursive=true` | `204` | ```bash CLI telnyx-edge sandbox-gpu files put "$SANDBOX_ID" config.yaml /app/config.yaml telnyx-edge sandbox-gpu files get "$SANDBOX_ID" /app/results.json results.json telnyx-edge sandbox-gpu files ls "$SANDBOX_ID" /app telnyx-edge sandbox-gpu files mkdir "$SANDBOX_ID" /app/data telnyx-edge sandbox-gpu files rm -r "$SANDBOX_ID" /app/tmp ``` ```bash curl BASE="https://api.telnyx.com/v2/ai/sandboxes/$SANDBOX_ID/files" AUTH="Authorization: Bearer $TELNYX_API_KEY" curl -sS -H "$AUTH" -X PUT --data-binary @config.yaml "$BASE?path=/app/config.yaml" curl -sS -H "$AUTH" "$BASE?path=/app/results.json" -o results.json curl -sS -H "$AUTH" -G "$BASE" --data-urlencode "path=/app" \ --data-urlencode "list=true" --data-urlencode "page[size]=100" curl -sS -H "$AUTH" -X DELETE "$BASE?path=/app/tmp&recursive=true" ``` The CLI retries a download that was cut short and replaces the local file only once the whole file has arrived; `files get` with `-` as the local path writes to stdout. With curl, percent-encode `path` when it contains reserved characters. ## Common Rules - **Running sandboxes only.** The sandbox must be `running` (`409 sandbox_not_running` otherwise). File calls keep working during the stop's grace period, so results can be fetched from a sandbox that is ending. - **Paths.** `path` is absolute, at most 4,096 bytes in UTF-8, and valid UTF-8 once percent-decoded. It is resolved as the sandbox's kernel resolves it: `.`, `..`, and `//` included. A path containing a NUL byte is `422 invalid_path`. - **Permissions.** Calls run as the sandbox's own user, with its permissions. What that user may not do, or a read-only file system, is `403 permission_denied`. - **File system refusals.** No space, a name too long, a busy file or mount point, a symlink loop, or an I/O error is `422 file_operation_failed`, with a fixed text naming the reason. - **Size and time.** Each call moves at most 64 MiB, within a time budget of about 12 seconds for the whole transfer. A full-size file needs about 5.3 MiB/s between the client and the API to read, and about 6.4 MiB/s to write. Move larger data through [Cloud Storage](/docs/cloud-storage/overview) from an [exec](/docs/gpu-sandboxes/execs). - **Not activity.** File calls don't count as activity for `idle_timeout`. ## Read a File The response is `application/octet-stream`, and symlinks are followed. - The length is declared in `Content-Length` before the content. **A response shorter than its `Content-Length` was cut**: the sandbox stopped answering, the file shrank while it was read, or the time budget ran out. Retry. - A file over 64 MiB is `413 file_too_large`, before any content is sent. - A directory, device, FIFO, or socket is `409 path_type_mismatch`. - Files of at most 1 MiB, including pseudo-files under `/proc` and `/sys`, are read whole inside the sandbox first, so their real length is declared. Reading a pseudo-file can use up to 64 MiB of the sandbox's own memory. ## List a Directory `list=true` lists the directory at `path` (a symlink there is followed) as JSON, sorted by name in byte order and paged with `page[number]` and `page[size]` (default 20, maximum 100). ```json { "data": [ { "name": "config.yaml", "path": "/app/config.yaml", "type": "file", "size_bytes": 412, "modified_at": "2026-11-13T10:15:02Z" }, { "name": "data", "path": "/app/data", "type": "directory", "size_bytes": 4096, "modified_at": "2026-11-13T10:14:40Z" } ], "meta": { "page_number": 1, "page_size": 20, "total_pages": 1, "total_results": 2 } } ``` | `type` | Entry | | --- | --- | | `file` | A regular file. | | `directory` | A directory. | | `symlink` | A symbolic link, listed with its own size and time, never followed. | | `other` | A device, FIFO, or socket. | - `.` and `..` aren't listed; hidden entries are. - `size_bytes` is what the file system reports for the entry itself. `modified_at` is the sandbox's own clock. - A directory with more than 100,000 entries is `413 directory_too_large`. - Each page is a fresh listing, so entries can move between pages while the directory changes. - Names that aren't valid UTF-8 are shown with each invalid byte replaced by U+FFFD. They can't be addressed through the Files API; use an exec. - Listing a file is `409 path_type_mismatch`. ## Write a File The request body's raw bytes are written to `path`, whatever its `Content-Type`. - **Atomic replace.** Readers see the whole old content or the whole new content. A write that fails or is cut off leaves the file exactly as it was. - Missing parent directories are created with mode `0755` once the whole body has arrived. A new file gets `0644`; a replaced file keeps its permission bits. - A write through a symlink writes the file it points to and keeps the link. - A write needs permission to write both the file and its directory. A non-root writer becomes the replaced file's owner; root keeps the old owner. - An overwrite needs room for both copies until the new one replaces the old. Hard links to the old file keep the old content, and processes holding it open keep reading it. - Files the sandbox mounts itself (`/etc/hosts`, `/etc/resolv.conf`, `/etc/hostname`) can't be replaced this way (`422 file_operation_failed`). Use an exec. - A directory, device, FIFO, or socket at `path`, a `path` ending in `/`, or a parent that is a file is `409 path_type_mismatch`. A `path` ending in `.` or `..`, or under `/.telnyx`, is `422 invalid_path`. - A declared `Content-Length` over 64 MiB is `413 file_too_large` before anything reaches the sandbox; a body without one is refused as soon as it passes 64 MiB. - The body must be complete 2 seconds before the time budget ends. A body still arriving then is `408`, and the file is unchanged. - **A `503` after the whole body was sent may have written the file.** Retrying writes the same content again, which is harmless. With `directory=true` and an empty body, the call creates the directory and any missing parents. Trailing slashes are ignored, and a file in the way is `409 path_type_mismatch`. ## Delete `DELETE` removes the file, symlink, or empty directory at `path`. - A symlink is removed itself, never its target. - A non-empty directory needs `recursive=true`; otherwise it is `409 directory_not_empty` and nothing is removed. A recursive delete never follows symlinks. - Trailing slashes are ignored. A missing path is `404`. A parent that is a file is `409 path_type_mismatch`. `/`, anything under `/.telnyx`, or a `path` ending in `.` or `..` is `422 invalid_path`. - **A recursive delete that runs out of time** answers `503`, with part of the tree possibly removed; it continues in the sandbox. A retry continues it or, if it has finished meanwhile, answers `404`. After a `503`, a `404` means the delete is done. ## Retries Writes and deletes accept an `Idempotency-Key`. A retry with the same key, path, flags, and body after the call completed returns the stored answer, and nothing is written or deleted again. A different request with the same key is `422 idempotency_key_reused`. A retry that overlaps the first call can repeat the write, or answer `404` for a path the first call deleted. --- ### Logs > Source: https://developers.telnyx.com/docs/gpu-sandboxes/logs.md `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](/docs/gpu-sandboxes/attach#exec-attach). | `follow` | Response | | --- | --- | | `false` (default) | One page of stored output as JSON (`application/json`). | | `true` | A Server-Sent Events stream (`text/event-stream`): stored output, then new output as it is stored, until the sandbox ends. | `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 a `line` or a `gap`, and carries a `position`: ```json { "type": "line", "stream": "stdout", "ts": "2026-11-13T10:15:02.123456789Z", "line": "epoch 1/3 loss=0.412", "position": "p1.18.0" } ``` | Field | Description | | --- | --- | | `stream` | `stdout` or `stderr`. | | `ts` | When the line was written, to the nanosecond. | | `line` | The text without its newline. Lines are cut at 256 KiB, and bytes that weren't valid UTF-8 appear as U+FFFD. | | `position` | Opaque position. Pass it as `page[after]` or `Last-Event-ID` to continue right after this entry. | 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: ```json { "type": "gap", "reason": "expired", "stream": null, "from_ts": "2026-10-01T08:00:00Z", "to_ts": "2026-10-01T09:12:44Z", "records": null, "position": "p1.4.0" } ``` | `reason` | Meaning | | --- | --- | | `expired` | Past its retention, or removed or changed in the bucket. | | `log_bucket_unavailable` | The log bucket couldn't be written, so the output wasn't stored. | | `size_cap_reached` | The sandbox's output passed the size cap. | `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. ```bash CLI telnyx-edge sandbox-gpu logs "$SANDBOX_ID" telnyx-edge sandbox-gpu logs "$SANDBOX_ID" --json --after "$AFTER" ``` ```bash curl curl -sS -G "https://api.telnyx.com/v2/ai/sandboxes/$SANDBOX_ID/logs" \ -H "Authorization: Bearer $TELNYX_API_KEY" \ --data-urlencode "page[size]=100" \ --data-urlencode "page[after]=$AFTER" ``` ```json { "data": [ { "type": "line", "stream": "stdout", "ts": "…", "line": "…", "position": "p1.18.0" } ], "meta": { "page_size": 100, "next_page_after": null } } ``` `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 ```bash CLI telnyx-edge sandbox-gpu logs "$SANDBOX_ID" -f --timestamps ``` ```bash curl curl -sS -N "https://api.telnyx.com/v2/ai/sandboxes/$SANDBOX_ID/logs?follow=true" \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Accept: text/event-stream" ``` With `-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: ```text event: log id: p1.18.0 data: {"type":"line","stream":"stdout","ts":"2026-11-13T10:15:02.123456789Z","line":"epoch 1/3 loss=0.412","position":"p1.18.0"} : heartbeat event: end data: {"logs":"complete","reason":null} ``` | Event | Data | | --- | --- | | `log` | A `line` entry. Its `id` is the line's position. | | `gap` | A `gap` entry. Its `id` is the gap's position. | | `end` | How the log ended. Sent once the sandbox has ended and every stored line was sent; the stream then closes. | 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: | `logs` | Meaning | | --- | --- | | `complete` | Every line the sandbox printed is stored. | | `incomplete` | Some output is missing for good. `reason` says why. | | `settling` | The sandbox ended a while ago and its log isn't final yet. A later read may return more. | The sandbox itself shows the same outcome in `logs_incomplete` and `logs_incomplete_reason`: | Reason | Meaning | | --- | --- | | `log_bucket_unavailable` | The log bucket couldn't be written. | | `node_lost` | The sandbox's node was lost. | | `logs_missing` | Output was lost on its way to storage. | | `logs_unverified` | The sandbox's output couldn't be counted, so the log can't be shown complete. | | `size_cap_reached` | The output passed the size cap. | ## Log Bucket Logs are stored in a [Telnyx Cloud Storage](/docs/cloud-storage/overview) bucket in your account. The sandbox's `log_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_bucket` on 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 with `422 log_bucket_not_allowed`. Retention is whatever lifecycle rules the bucket has. ### Object Layout The logs can be read with any S3-compatible tool under `sandboxes/{sandbox_id}/` in the bucket. Objects are zstd-compressed NDJSON, one record per line: ```json {"ts": "2026-11-13T10:15:02.123456789Z", "stream": "stdout", "line": "epoch 1/3 loss=0.412"} ``` | Object | When | | --- | --- | | `sandboxes/{sandbox_id}/chunks/.ndjson.zst` | Chunks, written while the sandbox runs. | | `sandboxes/{sandbox_id}/logs--.ndjson.zst` | The whole log, once it is final. | 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_reached` gap. --- ### Metrics > Source: https://developers.telnyx.com/docs/gpu-sandboxes/metrics.md `GET /v2/ai/sandboxes/{sandbox_id}/metrics` returns the latest sample and a per-minute series for a time range. The metrics currently cover CPU, memory, disk, and network. GPU usage isn't reported yet: `gpus` is always `null`. ```bash CLI telnyx-edge sandbox-gpu metrics "$SANDBOX_ID" --from 2026-11-13T09:00:00Z --to 2026-11-13T10:00:00Z telnyx-edge sandbox-gpu metrics "$SANDBOX_ID" --since 15m ``` ```bash curl curl -sS -G "https://api.telnyx.com/v2/ai/sandboxes/$SANDBOX_ID/metrics" \ -H "Authorization: Bearer $TELNYX_API_KEY" \ --data-urlencode "from=2026-11-13T09:00:00Z" \ --data-urlencode "to=2026-11-13T10:00:00Z" ``` `--since` sets the range's length before `--to` or now, and `--json` prints the `data` object of the response below. | Parameter | Default | Description | | --- | --- | --- | | `from` | 60 minutes before `to`, clipped to the sandbox's lifetime | Start of the range (RFC 3339, with a UTC offset). | | `to` | Now, or the sandbox's end if it has ended | End of the range (RFC 3339, with a UTC offset). | A range spans at most 24 hours. An invalid range is `400`. Metrics are kept for 30 days. ## Response ```json { "data": { "sandbox_id": "sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e", "from": "2026-11-13T09:00:00Z", "to": "2026-11-13T10:00:00Z", "step_seconds": 60, "latest": { "ts": "2026-11-13T09:59:51Z", "cpu_cores": 11.84, "net_rx_bytes": 52428800, "net_tx_bytes": 1048576, "mem_bytes": 2147483648, "disk_bytes": 34359738368, "gpus": null }, "series": [ { "ts": "2026-11-13T09:00:00Z", "cpu_cores_avg": 11.2, "cpu_cores_max": 12.6, "net_rx_bytes": 209715200, "net_tx_bytes": 4194304, "mem_bytes_avg": 2013265920, "mem_bytes_max": 2147483648, "disk_bytes": 34359738368, "gpus": null } ] } } ``` - `latest` is the most recent sample, taken every 15 seconds; `null` if there is none yet. - `series` has one point per minute (`step_seconds` is always 60), starting at the minute. It is empty where nothing is stored. ## Sources CPU (`cpu_cores`, `cpu_cores_avg`, `cpu_cores_max`) and network (`net_rx_bytes`, `net_tx_bytes`) are measured on the host, outside the sandbox. Disk (`disk_bytes`) is the bytes used on `/data`, also measured outside the sandbox, every one to two minutes; it doesn't include the root filesystem. Memory (`mem_bytes`, `mem_bytes_avg`, `mem_bytes_max`) is reported from inside the sandbox. Memory and disk are for display only: billing uses the sandbox's requested resources, never these numbers. Each is `null` for a period in which it wasn't measured. ## Field Notes - **CPU** is in cores, for the whole sandbox VM including its virtualization overhead. A busy sandbox can read above its `cpu`, by up to 1 core. `latest.cpu_cores` is the average since the previous sample; `cpu_cores_max` is the busiest interval between two samples in the minute. - **Memory** is in bytes: what's in use inside the sandbox, meaning its processes, page cache in active use, and what it keeps in memory, such as files in `/dev/shm` and the kept output of its execs. It isn't the sandbox VM's total. `latest.mem_bytes` is the latest sample; `mem_bytes_avg` and `mem_bytes_max` are the average and the highest of the minute's samples (about every 15 seconds). - **Network** counts bytes received (`net_rx_bytes`) and sent (`net_tx_bytes`): since the previous sample in `latest`, and within the minute in `series`. After a gap in measurement, the gap's bytes are in the first minute measured after it. - A sandbox's last few seconds, and a sandbox that lives less than about 15 seconds, may not be measured. --- ## Reference ### API Conventions > Source: https://developers.telnyx.com/docs/gpu-sandboxes/api-conventions.md ## Base URL and Authentication All endpoints are under `https://api.telnyx.com/v2/ai`. Authenticate with a Telnyx API key as a Bearer token. The Telnyx CLI (`telnyx-edge sandbox-gpu`) calls the same API with the same key, which it stores with `telnyx-edge auth api-key set`. ```bash CLI telnyx-edge auth api-key set "$TELNYX_API_KEY" telnyx-edge sandbox-gpu list ``` ```bash curl curl -H "Authorization: Bearer $TELNYX_API_KEY" https://api.telnyx.com/v2/ai/sandboxes ``` Sandboxes, execs, and idempotency keys belong to the organization of the API key. Every user in the organization sees and manages its sandboxes; GPU limits and billing are per organization. IDs are prefixed: `sb-…` for sandboxes and `exec-…` for execs. ## Access GPU Sandboxes is available only to [fully verified accounts](/docs/account-setup/levels-and-capabilities/verified) enabled for the invite-only preview. Every endpoint refuses an account that isn't fully verified, and every endpoint except the access check refuses one that isn't enabled: | Status | Error | Meaning | | --- | --- | --- | | `403` | `sandboxes_require_verification` | The account isn't fully verified. | | `403` | `sandboxes_not_whitelisted` | The account isn't enabled for the preview. | ### Check Access ```bash curl -H "Authorization: Bearer $TELNYX_API_KEY" https://api.telnyx.com/v2/ai/sandbox-access ``` ```json { "data": { "whitelisted": true } } ``` `whitelisted: true` means the other endpoints are available as far as the preview goes. Account verification, GPU limits, and the errors below still apply: | Status | Error | Meaning | | --- | --- | --- | | `403` | `sandboxes_disabled` | Creating sandboxes and starting execs is disabled for the account. Other operations keep working. | | `403` | `sandboxes_spend_limit_reached` | The account, or the API key the call was made with, has reached its GPU Sandboxes spend limit. Returned when creating a sandbox. | | `503` | `sandbox_creation_paused` | Creating sandboxes is paused for everyone. Retry later. | ## Responses A single object is returned as `{"data": {...}}`. A list is returned as `{"data": [...], "meta": {...}}`. Lists page by number with `page[number]` (1-based, default 1) and `page[size]` (default 20, maximum 100): ```json { "meta": { "page_number": 1, "page_size": 20, "total_pages": 3, "total_results": 47 } } ``` [Logs](/docs/gpu-sandboxes/logs#read-pages) are the one exception: they page by cursor with `page[after]`. ## Idempotency Every side-effecting endpoint accepts an `Idempotency-Key` header: any client-chosen string of up to 255 characters, such as a UUID. - **Same key, same request**, within 24 hours: the stored response is returned, with the same resource ID and status code, and nothing happens twice. - **Same key, different request**: `422 idempotency_key_reused`. - **Same key while the first request is still running**: `409 request_in_progress`. Retry later. - **Failed requests aren't stored.** A retry with the same key after a validation error, `429`, or conflict is evaluated afresh. The CLI sends a new key with every write and reuses it when it retries. To make a retry across runs safe too, pass your own key: `--idempotency-key` on the CLI's `create`, `exec`, `terminate`, `set-tags`, and `files put`. Always send an `Idempotency-Key` with `POST /v2/ai/sandboxes` and `POST …/execs`. Without one, a retry after a lost response can start, and bill, a second GPU sandbox, or run a command twice. The CLI sends one for you. | Endpoint | Key | | --- | --- | | `POST /v2/ai/sandboxes` | Recommended | | `POST /v2/ai/sandboxes/{sandbox_id}/execs` | Recommended | | `PATCH /v2/ai/sandboxes/{sandbox_id}`, `POST …/terminate`, `POST …/stdin/close`, `POST …/execs/{exec_id}/kill`, `POST …/execs/{exec_id}/stdin/close`, `PUT` and `DELETE …/files` | Accepted | ## Long Polls `GET …/wait` and `GET …/execs/{exec_id}?wait=` hold the request for at most 10 seconds and then return `200` with the current state. Larger values are clamped. Loop until the state is final. The CLI's `wait` loops for you: ```bash CLI telnyx-edge sandbox-gpu wait "$SANDBOX_ID" ``` ```bash curl until [[ $(curl -sS -H "Authorization: Bearer $TELNYX_API_KEY" \ "https://api.telnyx.com/v2/ai/sandboxes/$SANDBOX_ID/wait?timeout=10" | jq -r '.data.state') == terminated ]]; do :; done ``` ## Streaming Connections The [attach WebSockets](/docs/gpu-sandboxes/attach) and the [log stream](/docs/gpu-sandboxes/logs#follow-live) are cut by the edge proxy after about 600 seconds. Both resume without gaps or duplicates: exec attach from a byte `offset`, logs from the last event `id`. Plan to reconnect. The CLI reconnects for you. ## Errors Errors use the standard Telnyx error body. See [Errors](/docs/gpu-sandboxes/errors). --- ### Errors > Source: https://developers.telnyx.com/docs/gpu-sandboxes/errors.md Errors use the standard Telnyx error body: ```json { "errors": [ { "code": "…", "title": "resources_not_allowed", "detail": "GPU type `H100` isn't available; see GET /sandbox-gpu-types.", "source": { "pointer": "/gpu/type" } } ] } ``` | Field | Description | | --- | --- | | `title` | For the GPU Sandboxes errors below, the error's name. | | `detail` | What is wrong with this request and what is allowed. | | `source.pointer` | JSON pointer to the request field at fault, when there is one. | | `source.parameter` | The query or path parameter at fault, when there is one. | During the preview, the `code` of the GPU Sandboxes errors below isn't final. Identify them by `title`. ## GPU Sandboxes Errors ### Access | Status | `title` | Meaning | Retry | | --- | --- | --- | --- | | `403` | `sandboxes_require_verification` | The account isn't fully verified. | No | | `403` | `sandboxes_not_whitelisted` | The account isn't enabled for the invite-only preview. Check with `GET /v2/ai/sandbox-access`. | No | | `403` | `sandboxes_disabled` | Creating sandboxes and starting execs is disabled for the account. Other operations keep working. | No | | `403` | `sandboxes_spend_limit_reached` | The account, or the API key the call was made with, has reached its GPU Sandboxes spend limit. Returned when creating a sandbox. | No | | `503` | `sandbox_creation_paused` | Creating sandboxes is paused for everyone. | Later | ### Requests and Idempotency | Status | `title` | Meaning | Retry | | --- | --- | --- | --- | | `409` | `request_in_progress` | A request with the same `Idempotency-Key` is still being processed. | Later, same key | | `422` | `idempotency_key_reused` | The same `Idempotency-Key` was sent with a different request. | No | ### Creating Sandboxes | Status | `title` | Meaning | Retry | | --- | --- | --- | --- | | `409` | `name_conflict` | A non-terminated sandbox of the account already has this `name`. | After it ends | | `422` | `resources_not_allowed` | The GPU type or count isn't offered, or `gpu` is missing. | No | | `422` | `registry_not_allowed` | The image's registry isn't a public DNS name, or resolves to an internal address. | No | | `422` | `cidr_not_allowed` | A `cidr_allowlist` entry lies entirely inside internal ranges. | No | | `422` | `invalid_env` | An `env` name isn't a POSIX name, starts with `TELNYX_SANDBOX_`, or a size limit is exceeded. | No | | `422` | `invalid_workdir` | `workdir` isn't an absolute path. | No | | `422` | `log_bucket_not_allowed` | `log_bucket` doesn't exist, isn't the organization's, is in another region, or isn't writable. | No | | `429` | `quota_exceeded` | The organization's GPU limit for the requested type would be exceeded. `detail` names the type, the limit, and the usage. | After a sandbox ends | ### Running Sandboxes and Execs | Status | `title` | Meaning | Retry | | --- | --- | --- | --- | | `409` | `sandbox_not_running` | The operation needs a `running` sandbox. | No | | `409` | `exec_not_started` | The exec is still `starting`, so only `SIGKILL` (which cancels it) can be sent. | Once `running` | | `422` | `invalid_command` | The argv breaks a size rule: at most 4,096 arguments, each at most 131,071 bytes, 1 MiB in total, no NUL byte. | No | | `422` | `offset_out_of_range` | The attach `offset` is past the end of the exec's output so far. | No | | `429` | `too_many_attaches` | The sandbox already has the maximum number of open attach connections. | After closing one | | `429` | `too_many_log_readers` | The organization already has the maximum number of log streams open. | After closing one | ### Files | Status | `title` | Meaning | Retry | | --- | --- | --- | --- | | `403` | `permission_denied` | The sandbox's user may not do this at the path, or the file system is read-only. | No | | `409` | `path_type_mismatch` | The path is a directory where a file was expected, or the reverse, or neither a file nor a directory. | No | | `409` | `directory_not_empty` | The directory isn't empty and `recursive` is `false`. | No | | `413` | `file_too_large` | The file is over the 64 MiB per-request limit. | No | | `413` | `directory_too_large` | The directory has more than 100,000 entries. | No | | `422` | `invalid_path` | The path holds a NUL byte, ends in `.` or `..`, is under `/.telnyx` (writes and deletes), or is `/` (deletes). | No | | `422` | `file_operation_failed` | The file system refused for another stated reason: no space, a name too long, a busy file or mount point, a symlink loop, or an I/O error. | Depends | ## Standard Errors | Status | Code | Meaning | Retry | | --- | --- | --- | --- | | `400` | `10004` | Missing required parameter. `source` points at it. | No | | `400` | `10015` | Bad request: the request isn't well-formed, or a value is invalid, such as a metrics range. `source` points at the field when there is one. | No | | `400` | `10025` | String length out of range. `source` points at the field. | No | | `400` | `10026` | Invalid parameter type. `source` points at the field. | No | | `401` | `10009` | Missing or invalid API key. | No | | `404` | `10005` | The resource doesn't exist or belongs to another organization. `detail` says what is missing. | No | | `408` | `10008` | A file write's body didn't arrive within the call's time budget. The file is unchanged. | Yes | | `503` | `10037` | A dependency can't answer right now. | Yes, with backoff | Retry writes after a `503` with the same `Idempotency-Key`. See [Idempotency](/docs/gpu-sandboxes/api-conventions#idempotency). --- ### Limits and Defaults > Source: https://developers.telnyx.com/docs/gpu-sandboxes/limits.md ## Sandboxes | Setting | Default | Limit | | --- | --- | --- | | `timeout` | 300 s | 1 s or more; `null` for no limit | | `idle_timeout` | None | 1 s up to `timeout` | | `queue_timeout` | 600 s | 0–86,400 s | | `gpu` | Required | A GPU type and a count from its `allowed_counts`; currently its node's GPU count, so one whole node per sandbox | | `name` | None | 1–64 characters of `A-Za-z0-9._-`; unique among non-terminated sandboxes | | `tags` | None | 20 tags; keys 1–63 characters, values up to 255 | | `env` | None | 256 variables, 32 KiB each, 256 KiB in total; POSIX names; no `TELNYX_SANDBOX_` prefix | | `image.ref` | — | 1,024 characters; public DNS registry; `linux/amd64` | | `log_bucket` | A bucket created for you, with a 30-day lifecycle rule | 3–63 characters; your bucket, in the GPU Sandboxes log region | | GPUs held at once, per GPU type | Set per organization | Every non-terminated sandbox counts; `429 quota_exceeded` beyond it | | Readable after termination | — | At least 30 days | ## Execs | Setting | Limit | | --- | --- | | `command` | 4,096 arguments, 131,071 bytes each in UTF-8, 1 MiB in total, no NUL byte | | `timeout` | Default none; 1–2,147,483,647 s; never outlives the sandbox | | Start confirmation | Fails with `agent_unavailable` after 5 minutes | | Retained output | At least the last 64 MiB per exec, within a per-sandbox total of 1/16 of the sandbox's memory, at most 256 MiB | | `stdin` message | 64 KiB decoded; frames over 128 KiB close the connection | | Open attach connections | Limited per sandbox; `429 too_many_attaches` beyond it | ## Files | Setting | Limit | | --- | --- | | Transfer | 64 MiB per request | | Time budget | About 12 s per call, transfer included; a write's body must arrive 2 s before it ends | | `path` | Absolute, 4,096 bytes in UTF-8 | | Directory listing | 100,000 entries; `page[size]` default 20, maximum 100 | ## Logs | Setting | Limit | | --- | --- | | Line length | 256 KiB; longer lines are cut | | `page[size]` | Default 20, maximum 100 | | Delay | A few seconds after the sandbox prints a line | | Open log streams | Limited per organization; `429 too_many_log_readers` beyond it | | Retention | Your bucket's lifecycle rules; 30 days in the default bucket | ## Metrics | Setting | Limit | | --- | --- | | Sample interval | 15 s | | Series resolution | 60 s | | Range | Default the last 60 minutes of the sandbox's life; at most 24 hours | | Retention | 30 days | ## Requests | Setting | Limit | | --- | --- | | `page[size]` | Default 20, maximum 100 | | Long polls (`/wait`, exec `?wait=`) | At most 10 s per call | | `Idempotency-Key` | 255 characters; kept 24 hours | | WebSocket and Server-Sent Events connections | Cut by the edge proxy after about 600 s; resume | --- ## API Reference (GPU Sandboxes) ### Sandboxes - [Create a sandbox](https://developers.telnyx.com/api-reference/sandboxes/create-a-sandbox.md): Creates a sandbox and returns it at once in state `queued`. It then starts in the background (`queued` → `preparing`, when its GPUs need preparing → `scheduled… - [List sandboxes](https://developers.telnyx.com/api-reference/sandboxes/list-sandboxes.md): Lists your organization's sandboxes, newest first. Without `state`, only non-terminated sandboxes are listed; add `state=terminated` for finished ones. Filter… - [Get a sandbox](https://developers.telnyx.com/api-reference/sandboxes/get-a-sandbox.md): Returns one sandbox: its `state`, `termination_reason`, `exit_code` and `ready`, what was requested, and what was resolved. Poll it to follow a sandbox startin… - [Replace a sandbox's tags](https://developers.telnyx.com/api-reference/sandboxes/replace-a-sandboxs-tags.md): Replaces the sandbox's whole tag set; `{}` clears it. Tags are the only thing you can change after create; any other field is rejected. Works on terminated san… - [Wait for a sandbox to end](https://developers.telnyx.com/api-reference/sandboxes/wait-for-a-sandbox-to-end.md): Long-poll: returns as soon as the sandbox is `terminated`, or after at most 10 s, whichever comes first, always with `200` and the sandbox as it is then. If `s… - [Terminate a sandbox](https://developers.telnyx.com/api-reference/sandboxes/terminate-a-sandbox.md): Stops the sandbox. A queued or preparing sandbox is cancelled at once. A sandbox that has been placed is stopped asynchronously: its processes get `SIGTERM`, t… - [Close the main process's stdin](https://developers.telnyx.com/api-reference/sandboxes/close-the-main-processs-stdin.md): Sends EOF to the stdin of the sandbox's main process, as the attach WebSocket's `stdin_eof` message does: the process sees it once the input already accepted h… ### Sandbox execs - [Run a command in a sandbox](https://developers.telnyx.com/api-reference/sandbox-execs/run-a-command-in-a-sandbox.md): Starts a command inside a running sandbox and returns the exec at once: `running`, or `exited` with its `exit_code` if it already finished. It doesn't wait for… - [List a sandbox's execs](https://developers.telnyx.com/api-reference/sandbox-execs/list-a-sandboxs-execs.md): Lists the sandbox's execs, newest first, optionally filtered by `status`. Works on terminated sandboxes too, while they're readable. A status here may lag the… - [Get an exec](https://developers.telnyx.com/api-reference/sandbox-execs/get-an-exec.md): Returns the exec: `status`, `exit_code` and `reason`. With `wait`, it's a long-poll: it returns as soon as the exec has ended, or after at most 10 s, always wi… - [Send a signal to an exec](https://developers.telnyx.com/api-reference/sandbox-execs/send-a-signal-to-an-exec.md): Sends a signal to the exec's process group (default `SIGKILL`). It's asynchronous: the response shows the exec as it is right after; with `SIGKILL` it ends sho… - [Close an exec's stdin](https://developers.telnyx.com/api-reference/sandbox-execs/close-an-execs-stdin.md): Sends EOF to the exec's stdin, as the exec attach WebSocket's `stdin_eof` message does: the process sees it once the input already accepted has been written. D… ### Sandbox files - [Read a file or list a directory](https://developers.telnyx.com/api-reference/sandbox-files/read-a-file-or-list-a-directory.md): **Without `list`:** downloads the file at `path` as raw bytes (`application/octet-stream`), following a symlink. Its length is declared in `Content-Length` bef… - [Write a file or create a directory](https://developers.telnyx.com/api-reference/sandbox-files/write-a-file-or-create-a-directory.md): Writes the raw request body to the file at `path`, whatever its `Content-Type`: `201` with the file's entry when it was created, `200` when it replaced one. **… - [Delete a file or directory](https://developers.telnyx.com/api-reference/sandbox-files/delete-a-file-or-directory.md): Deletes the file, symlink or empty directory at `path`, `204`. A symlink is removed itself, never what it points to. A non-empty directory needs `recursive=tru… ### Sandbox logs - [Read or follow a sandbox's logs](https://developers.telnyx.com/api-reference/sandbox-logs/read-or-follow-a-sandboxs-logs.md): The output (stdout and stderr) of the sandbox's main process. Exec output isn't included; read it through the exec attach WebSocket. ### Sandbox metrics - [Get a sandbox's metrics](https://developers.telnyx.com/api-reference/sandbox-metrics/get-a-sandboxs-metrics.md): The latest values plus a per-minute series for a time range: CPU, memory, disk and network. The range defaults to the last 60 minutes of the sandbox's life (up… ### Sandbox GPU types - [List GPU types](https://developers.telnyx.com/api-reference/sandbox-gpu-types/list-gpu-types.md): Lists the GPU types you can rent: each with its GPU count per node, the CPU, memory and disk a sandbox of that type gets per GPU, and prices. ### Sandbox access - [Check Sandboxes access](https://developers.telnyx.com/api-reference/sandbox-access/check-sandboxes-access.md): Tells you whether Sandboxes is enabled for your organization. During the invite-only preview, only enabled organizations can use the other Sandboxes endpoints;…