Sandbox API

CodeEdit

Code execution without LLM

Code execution without LLM

Every request needs a credential — see Authentication.

MethodPathSummary
POST/sandbox/codeedit/v1/executionsExecute
GET/sandbox/codeedit/v1/executions/{execution_id}Poll an async execution
POST/sandbox/codeedit/v1/executions/asyncAdmit an execution without holding the connection
GET/sandbox/codeedit/v1/languagesList Languages

Common headers

Accepted on every endpoint on this page.

NameInTypeRequiredDescription
x-correlation-idheaderstringnoEnd-to-end correlation id for this eval run. When set, the gateway and downstream services honor it verbatim in logs, Cloud Trace span attributes, async job payloads, and Langfuse trace.id. When omitted, the gateway generates a ULID and echoes it on the response.

Endpoints

Execute

POST /sandbox/codeedit/v1/executions

Parameters

NameInTypeRequiredDescription
X-Sandbox-Project-Idheaderstring | nullnoProject to bill and rate-limit this request against. Validated against the credential: a project-scoped token may only name its own project, and gets 403 otherwise. Defaults to the token's project when omitted.
X-Sandbox-Tenant-Idheaderstring | nullnoTenant for this request. Must match the credential's tenant when the credential carries one.

Request body

application/json, required — ExecutionRequest

FieldTypeRequiredDescription
languagestringyes
filesobjectno
stdinstring | nullno
limitsResourceLimits | nullno
labelsobjectnoConsumer tags for analytics (trainer, pass, program, …).
input_archiveArchiveInput | nullnoSigned GET URL (storage.googleapis.com), sha256 and size of an archive made available read-only at /input. Recipes with archive_io only (else 422); needs archive I/O enabled and a registered Google service-account caller (else 403). Prefer POST /v1/executions/async: transfers can exceed the gateway's ~1560s synchronous limit.
output_archiveArchiveOutput | nullnoSigned PUT URL (storage.googleapis.com) that /output is uploaded to as a tar after a successful run; the result carries its sha256 and size. The tar is untrusted: extract it safely (e.g. Python tarfile filter='data'). Same access rules as input_archive; prefer the async endpoint.

Responses

StatusDescriptionBody
200Successful Responseobject
403The credential may not run the recipe, or archive fields were sent while archive I/O is not enabled or by a caller that is not a registered Google service account.—
413Submitted files exceed the total payload limit.—
422Invalid request, including input_archive / output_archive on a recipe without archive_io or a malformed signed URL. Validation errors never echo request values.HTTPValidationError
429The project is already running its maximum number of concurrent executions. This is backpressure, not failure: the work was never started, so retrying after the interval in Retry-After is safe and will not duplicate anything. The limit is per project, so spreading load across projects raises it; a single client should cap its own concurrency rather than rely on retries.—

Poll an async execution

GET /sandbox/codeedit/v1/executions/{execution_id}

Parameters

NameInTypeRequiredDescription
execution_idpathstringyes
X-Sandbox-Project-Idheaderstring | nullnoProject to bill and rate-limit this request against. Validated against the credential: a project-scoped token may only name its own project, and gets 403 otherwise. Defaults to the token's project when omitted.
X-Sandbox-Tenant-Idheaderstring | nullnoTenant for this request. Must match the credential's tenant when the credential carries one.

Responses

StatusDescriptionBody
200Successful Responseobject
404Unknown or expired execution id, or one owned by another project.—
422Validation ErrorHTTPValidationError

Admit an execution without holding the connection

POST /sandbox/codeedit/v1/executions/async

Same work as POST /v1/executions, answered with 202 and an execution_id as soon as it is admitted. Poll poll_url until status is completed; result then has the sync response body. A project at its concurrency limit waits in the queue instead of getting 429.

Parameters

NameInTypeRequiredDescription
X-Sandbox-Project-Idheaderstring | nullnoProject to bill and rate-limit this request against. Validated against the credential: a project-scoped token may only name its own project, and gets 403 otherwise. Defaults to the token's project when omitted.
X-Sandbox-Tenant-Idheaderstring | nullnoTenant for this request. Must match the credential's tenant when the credential carries one.

Request body

application/json, required — ExecutionRequest

FieldTypeRequiredDescription
languagestringyes
filesobjectno
stdinstring | nullno
limitsResourceLimits | nullno
labelsobjectnoConsumer tags for analytics (trainer, pass, program, …).
input_archiveArchiveInput | nullnoSigned GET URL (storage.googleapis.com), sha256 and size of an archive made available read-only at /input. Recipes with archive_io only (else 422); needs archive I/O enabled and a registered Google service-account caller (else 403). Prefer POST /v1/executions/async: transfers can exceed the gateway's ~1560s synchronous limit.
output_archiveArchiveOutput | nullnoSigned PUT URL (storage.googleapis.com) that /output is uploaded to as a tar after a successful run; the result carries its sha256 and size. The tar is untrusted: extract it safely (e.g. Python tarfile filter='data'). Same access rules as input_archive; prefer the async endpoint.

Responses

StatusDescriptionBody
202Successful Responseobject
400Unknown or disabled language.—
403The credential may not run the recipe, or archive fields were sent while archive I/O is not enabled or by a caller that is not a registered Google service account.—
413Submitted files exceed the total payload limit.—
422Invalid request, including input_archive / output_archive on a recipe without archive_io or a malformed signed URL. Validation errors never echo request values.HTTPValidationError
503This replica already holds its maximum number of queued runs. Nothing was admitted; retry after Retry-After.—

List Languages

GET /sandbox/codeedit/v1/languages

Responses

StatusDescriptionBody
200Successful Responseobject

Schemas

The object shapes referenced above.

ArchiveInput

Where to fetch the input archive from, and what it must be.

FieldTypeRequiredDescription
urlstringyesV4 signed GET URL on storage.googleapis.com.
sha256stringyesLowercase hex SHA-256 of the archive.
size_bytesintegeryesExact archive size in bytes.

ArchiveOutput

FieldTypeRequiredDescription
urlstringyesV4 signed PUT URL on storage.googleapis.com.
headersobject | nullnoExtra headers the signed PUT URL requires, sent verbatim on the upload. Allowed names (case-insensitive): x-goog-if-generation-match (digits), x-goog-content-length-range (min,max, digits, min <= max) and content-type (a plain MIME type, default application/x-tar). Any other header or value is rejected. When x-goog-if-generation-match is set the upload is attempted once, and a max below the tar size fails the run as output too large.

ExecutionRequest

FieldTypeRequiredDescription
languagestringyes
filesobjectno
stdinstring | nullno
limitsResourceLimits | nullno
labelsobjectnoConsumer tags for analytics (trainer, pass, program, …).
input_archiveArchiveInput | nullnoSigned GET URL (storage.googleapis.com), sha256 and size of an archive made available read-only at /input. Recipes with archive_io only (else 422); needs archive I/O enabled and a registered Google service-account caller (else 403). Prefer POST /v1/executions/async: transfers can exceed the gateway's ~1560s synchronous limit.
output_archiveArchiveOutput | nullnoSigned PUT URL (storage.googleapis.com) that /output is uploaded to as a tar after a successful run; the result carries its sha256 and size. The tar is untrusted: extract it safely (e.g. Python tarfile filter='data'). Same access rules as input_archive; prefer the async endpoint.

HTTPValidationError

FieldTypeRequiredDescription
detailValidationError[]no

ResourceLimits

FieldTypeRequiredDescription
wall_time_msintegernoDefault: 5000.
memory_mbintegernoDefault: 256.
pidsintegernoDefault: 64.
output_bytesintegernoDefault: 1048576.
filesystem_mbintegernoDefault: 64.

ValidationError

FieldTypeRequiredDescription
locstring | integer[]yes
msgstringyes
typestringyes
inputanyno
ctxobjectno

Machine-readable spec: OpenAPI YAML.