v5

latestOpenAPI 3.0.3raw.githubusercontent.com2026-07-01224150.1 KB
Runtime

Run a code snippet

Writes code to a temp file and runs it with the chosen interpreter. Cleaner than /exec for multi-line scripts because you don't have to deal with shell escaping. Response shape matches /exec.

Supports the same stream: true opt-in as /exec; see that endpoint's description for the SSE event shape.

post/sandboxes/{id}/code

Path parameters

idstring required

24-char hex id of the sandbox.

Request body

language'python' | 'node' required
codestring required

Snippet source. Multi-line via \n in the JSON string.

timeout_secondsinteger
cwdstring
envobject

Extra environment variables for this snippet only. Same semantics as env on /exec, per-call override on top of the sandbox's default environment.

streamboolean

When true, the response is SSE (text/event-stream) as the snippet runs, same behaviour as /exec with stream: true.

Example request

{
  "env": {
    "OPENAI_API_KEY": "sk-..."
  }
}

Response

Code completed.

When the request body has stream: true, the response is text/event-stream, one ExecStreamFrame per data: event.

messagestring required

Example response

{
  "message": "Exec completed"
}