tool_compute_sandbox
POST /tools/tool_compute_sandbox/run — Executes Python 3.12 code in an isolated subprocess with a 5-second hard timeout. Input: {python_code: string, input_data: any (optional, bound as variable 'input_data')}. Output: {success, result, stdout (capped 50KB), execution_time_ms, error_type}. Return value: assign to 'result' variable. Pre-loaded: math, json, re, statistics, itertools, functools, collections, decimal, datetime, random, hashlib, base64. Blocked: import, open(), eval(), exec(), os, sys, network, class definitions, dunder attributes. error_type values: syntax_error | security_error | runtime_error | timeout_error. Cost: $0.1500 USDC per call.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data | No | JSON-serializable value (dict, list, str, number, bool, or null) passed as the variable 'input_data' inside the sandbox. Omit or pass null if the code has no external input. | |
| python_code | Yes | Python 3.12 source code to execute. No import statements. Set 'result = <value>' to return a value. Pre-loaded modules are in scope: math, json, re, statistics, itertools, functools, collections, decimal, datetime, random, string, textwrap, hashlib, base64, struct, copy, pprint. |