Code execution
Run code in the gateway's sandbox and return its output.
The run is admitted as an otari_code_execution call is: a workspace whose code execution policy is off is refused, and its execution ceiling and pinned image apply. It is priced under otari:code_execution and reserved against the caller's budgets. file_ids puts uploads in the working directory, and each file the code writes comes back with a file_id. container: "auto" holds the sandbox after the run and names it in Otari-Container-Id; sending that id back runs in the same sandbox, with its files and interpreter state.
Authentication modes:
Master key: the
userfield is required and may name any existing user.API key: usage and spend bind to the key's own user. A
userfield naming a different user is rejected with 403 (or ignored, when the key's ownreject_user_mismatchis false, or the deployment-wide setting is disabled and the key does not override it); it is never billed to that user.Service key: a
userfield names one of the key owner's end users, created on first use on the budgetOtari-End-User-Budgetnames (or the key's default), and is billed and rate limited as that end user.
Enter your API key here (sent as Otari-Key header).
A direct code execution request: the code to run, and the sandbox to run it in.
Python source to run in the sandbox
'auto' to hold the sandbox after the run, or a container id an earlier response named in Otari-Container-Id to run in that sandbox again, with its files and interpreter state. Omitted, the sandbox is released when the run ends.
Uploads from POST /api/v1/files to put in the working directory before the code runs, each under its own filename.
How long the code may run. Never more than the workspace's code execution ceiling, or 60 seconds when it sets none.
User ID for usage attribution
Successful Response
A completed code execution. Code that failed is a completed execution with a nonzero return_code.
code_execution.resultThe program's exit status; null when the sandbox did not report one.
Validation Error
POST /api/v1/code/execute HTTP/1.1
Otari-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 42
{
"code": "print(1 + 1)",
"container": "auto"
}{
"files": [
{
"file_id": "text",
"filename": "text"
}
],
"object": "code_execution.result",
"return_code": 1,
"stderr": "text",
"stdout": "text"
}Last updated
Was this helpful?
