runCode
Execute code in a secure sandbox environment with specified language and environment variables. Retrieve text output directly; for file operations, use dedicated viewing and export endpoints.
Instructions
Run code on a specific sandbox. This returns text output only. For operations that generate files, you'll need to use separate file viewing and export endpoints. Default file saving path is /home/user.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
code | Yes | The code to run | |
envs | No | Environment variables to set when running the code | |
language | No | The programming language to use. If not specified or if the value is not in the allowed range, it will be treated as Python code. | python |
sandbox_id | Yes | The ID of the sandbox to run the code on | |
timeout | No | The timeout for code execution in seconds |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"code": {
"description": "The code to run",
"type": "string"
},
"envs": {
"additionalProperties": {
"type": "string"
},
"description": "Environment variables to set when running the code",
"type": "object"
},
"language": {
"default": "python",
"description": "The programming language to use. If not specified or if the value is not in the allowed range, it will be treated as Python code.",
"enum": [
"python",
"r",
"java",
"bash",
"js"
],
"type": "string"
},
"sandbox_id": {
"description": "The ID of the sandbox to run the code on",
"type": "string"
},
"timeout": {
"default": 5,
"description": "The timeout for code execution in seconds",
"type": "integer"
}
},
"required": [
"code",
"sandbox_id"
],
"type": "object"
}