# agent402.tools Code Execution Sandbox

> agent402.tools Code Execution Sandbox is a paid API for AI agents from agent402.tools, paid per call via x402, $0.02/call, status unknown (last checked 2026-09-14).

Executes Python or JavaScript code in a secure cloud sandbox and returns stdout, stderr, and expression results

## Facts

- Endpoint: POST https://agent402.tools/api/code-run
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-code-execution-sandbox-ed664c07
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_mMyN5p7jolZs9cvgB5QGj

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent402-tools-code-execution-sandbox-ed664c07 -d '<json body>'
```

Example prompt: Run this Python code in a secure sandbox and tell me what it prints: `import math; result = [math.factorial(n) for n in range(10)]; print(result)`

## When to prefer this

Use this endpoint when you need to run a short Python or JavaScript snippet in a fully isolated, no-setup cloud environment and get back the output immediately. Ideal for dynamic computations, data transformations, quick algorithmic tasks, or evaluating untrusted code safely. Prefer over local execution when the agent has no local runtime, or when sandboxing is required for security. Not suitable for long-running jobs (>30s), code requiring external dependencies not pre-installed, or code larger than 10,000 characters.

## Known failure modes

- Code exceeds 10,000 character limit — request rejected
- Execution exceeds 30-second timeout — returns timeout error
- Syntax errors in code — returned in stderr field
- Unsupported language specified — error response
- Payment via x402 fails or is insufficient — 402 Payment Required response
- Runtime exceptions in code — captured in stderr, stdout may be partial

## How this service works

Execute Python or JavaScript code in a secure, isolated cloud sandbox. Returns stdout, stderr, and the expression result. No setup needed; pay per call via x402. 30s timeout, 10k char code limit.

## Output

Returns stdout (printed output), stderr (error messages or warnings), and the evaluated expression result from the executed code snippet, all as structured fields.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "code": {
   "type": "string",
   "description": "Source code to execute (max 10,000 chars)"
  },
  "language": {
   "type": "string",
   "description": "Language: python (default) or javascript"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "error": null,
  "result": null,
  "stderr": "",
  "stdout": "Hello from Agent402!\n",
  "language": "python"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-code-execution-sandbox-ed664c07/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
