Skip to main content
Give each of your users their own coding sandbox (Claude Code, Codex, OpenCode or Pi on a small private computer that sleeps when idle), created and paid for by your platform through our API. You tag every sandbox with your own customer id, cap what you spend, get webhooks, and can embed a sandbox’s terminal in your own app with no Singularity Layer branding. Base URL: https://compute.x402layer.cc/pods/v1. Auth: a compute API key (X-API-Key: x402c_...) with pods:control:write (a sandbox runs commands) and spend, or a wallet signature.

Price: pay as you go, from your credits

A sandbox sleeps after 15 idle minutes and wakes on the next request in about 2 seconds, so a user who works 2 hours a day costs about $0.72 + $1.50 = $2.22 a month. No monthly base fee. Each sandbox: 2 vCPU, 4 GB memory, 12 GB disk.

1. Set your platform up (once)

GET /platform shows these, this month’s spend, and your live-sandbox limit (max_live, set by us: ask to raise it). Per-user overrides: PUT /platform/end-users/{end_user_id} with {"monthly_cap_usd": 25, "max_live": 3}, GET to read it with that user’s spend, DELETE to go back to the defaults.

2. Create a sandbox for one of your users

  • Idempotency-Key is required: retry with the SAME key and you get the same sandbox, never a second charge.
  • harness: claude-code, codex, opencode, pi. ai_mode: own_key (api_key; for OpenCode/Pi also model and optionally base_url, default OpenRouter) or own_login (Claude Code: the user signs in to their own Claude account in the terminal). The key stays on our side (the box gets a proxy token), but anyone using the sandbox can spend through it, so give each user their own.
  • end_user_id: your id for the user (1 to 128 of A-Z a-z 0-9 . _ : @ | + = -). Fixed for the sandbox’s life.
  • tags: up to 16 string pairs, replaceable later with PATCH /sandboxes/{id}.
It is ready in about two minutes (sandbox.ready webhook, or poll GET /sandboxes/{id}). Refusals take no money: 402 spend_cap_reached (a cap), 402 insufficient_credits, 409 limit (live-sandbox limit), 503 at_capacity (we are full: try again later).

3. List, read, change, delete

Run commands, read and write files, open preview links and mint OpenAI-compatible keys with the same routes as any sandbox: /pods/v1/pods/{id}/exec, /files, /ports, /keys.

4. Caps: what happens at the limit

  • The next awake hour that would pass a cap is not charged: the sandbox goes on hold and sleeps (sandbox.cap_reached, billing.hold_reason = cap_platform, cap_end_user or insufficient_credits). It will not wake while on hold.
  • If a day of disk cannot be paid, the sandbox is deleted after 7 days unless it is paid by then (billing.deletes_at, and sandbox.deleting just before).
  • Raise the cap or add credits and the hold lifts by itself on the next wake.

5. Webhooks

Use the pod webhooks (POST /pods/v1/webhooks with your https URL; signed t=...,v1=... HMAC). Every sandbox event carries data.end_user_id. Missed one? GET /pods/v1/events?after=<seq>.

6. Embed the terminal in your app

Your server asks for a short-lived link for one sandbox and gives it to that user’s browser:
  • Only your embed_origins may frame it. The page has no branding.
  • The token is for that one sandbox, terminal only, 60 s to 1 h (default 15 min). It sits in the URL fragment, so it never reaches a server log.
  • Revoke every link for a sandbox: POST /sandboxes/{id}/embed-token/revoke. This stops new connections; a terminal already open stays until it closes (after 10 idle minutes at most).
  • Your own terminal UI instead: POST ticket_url with Authorization: Bearer <token> (CORS open to your embed_origins) returns {ws_url}: text frame {"cols":..,"rows":..} resizes, binary frames are the terminal’s input and output.

SDK snippets

TypeScript:
Python:
(Use a new Idempotency-Key for each new sandbox and the same one when you retry that request.)