Skip to main content
Execute arbitrary code natively inside the runtime. Code execution is stateful and returns structured output, including stdout, stderr, and any unhandled exceptions. POST /v1/agents/runtime/{runtime_id}/code/run

Basic (Python)

JavaScript and contexts

Create a persistent context, then run JavaScript so state survives across calls.
gravixlayer runtime run infers language from the file extension (.py, .js) but does not accept --context-id. Use Python or cURL for context-bound runs.

Parameters

string
required
The source code to execute.
string
The programming language of the code. Defaults to "python". Use "javascript" for Node.js execution.
Base templates include both Python and Node.js. Use base-small, base-medium, or base-large.
string
An identifier for a persistent execution context.
object
Environment variables specific to this code execution block.
integer
Execution timeout in seconds. Kills the process if it exceeds this limit.

Response

string
The standard output (stdout) produced by the executed code.
boolean
True if the code executed without raising unhandled exceptions.
object
Detailed error information if success is False. Includes name (e.g., ValueError), value (the error message), and traceback (the full stack trace).
object
The raw stdout and stderr streams, formatted as lists of strings.