Skip to content

Execute code

POST
/execute

Run code in a persistent REPL session and wait for the full result. If context_id is omitted a new session is created automatically. Supported languages: python, typescript.

object
code
required

Source code to execute.

string
Example
print('hello')
context_id

Link execution to an existing context. Auto-generated if omitted.

string
language

Language runtime to use.

string
default: python
Allowed values: python py python3 typescript ts javascript js bun node
env_vars

Environment variables for the execution.

object
key
additional properties
string
timeout_ms

Execution timeout in milliseconds.

integer
default: 30000

Execution completed.

object
context_id
required

ID of the execution context used. Auto-generated if not provided in the request.

string
items
required

Rich output items from the execution.

Array<object>
object
is_primary

Whether this is the primary output item.

boolean
text
string
html
string
markdown
string
svg
string
png

Base64-encoded PNG image.

string
jpeg

Base64-encoded JPEG image.

string
pdf

Base64-encoded PDF.

string
latex
string
json
object
key
additional properties
any
javascript
string
extra
object
key
additional properties
any
logs
required
object
stdout

Lines of standard output.

Array<string>
stderr

Lines of standard error.

Array<string>
error
object
name

Error type name.

string
Example
NameError
value

Error message.

string
Example
name 'x' is not defined
traceback

Full traceback string.

string
execution_count

Incremental execution counter for the session.

integer

Bad request – validation error.

object
message
required

Summary message.

string
Example
Invalid request
errors
required
Array<object>
object
field
required

JSON field name that failed validation.

string
error
required

Human-readable validation failure.

string

Internal error (returned as an Execution object with an error field).

object
context_id
required

ID of the execution context used. Auto-generated if not provided in the request.

string
items
required

Rich output items from the execution.

Array<object>
object
is_primary

Whether this is the primary output item.

boolean
text
string
html
string
markdown
string
svg
string
png

Base64-encoded PNG image.

string
jpeg

Base64-encoded JPEG image.

string
pdf

Base64-encoded PDF.

string
latex
string
json
object
key
additional properties
any
javascript
string
extra
object
key
additional properties
any
logs
required
object
stdout

Lines of standard output.

Array<string>
stderr

Lines of standard error.

Array<string>
error
object
name

Error type name.

string
Example
NameError
value

Error message.

string
Example
name 'x' is not defined
traceback

Full traceback string.

string
execution_count

Incremental execution counter for the session.

integer