# PayWeave Sandbox · Pay-per-call Code Execution

> PayWeave Sandbox · Pay-per-call Code Execution is a paid API for AI agents from sandbox.payweave.services, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-14).

Executes arbitrary source code in an isolated sandbox environment, returning stdout/stderr logs and rich outputs, charged per execution via x402 micropayment.

## Facts

- Endpoint: POST https://sandbox.payweave.services/run
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/payweave-sandbox-pay-per-call-code-execution-b08c704b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Yy-J7PMkVWrSpCs1u7uP_

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 payweave-sandbox-pay-per-call-code-execution-b08c704b -d '<json body>'
```

Example prompt: Run this Python script in an isolated sandbox and give me the output — it generates a bar chart using matplotlib: `import matplotlib.pyplot as plt; plt.bar(['A','B','C'],[3,7,2]); plt.savefig('out.png')` — set a 10-second timeout and pass ENV_MODE=production as an environment variable.

## When to prefer this

Choose this endpoint when you need to execute arbitrary or untrusted code in a secure, isolated environment on a pay-per-use basis without provisioning persistent infrastructure. Ideal for AI agents that need to run generated code snippets, data analysis scripts, or chart-rendering code dynamically. The micropayment model (x402, $0.01 USDC) makes it cost-effective for low-frequency or one-off executions compared to spinning up a persistent container.

## Known failure modes

- Code raises an unhandled exception — success=false, error contains name/message/traceback
- Execution exceeds timeout_ms — process is killed, success=false with timeout error
- Unsupported language specified — error returned indicating unknown interpreter
- Payment fails or is insufficient via x402 — 402 response before execution begins
- Malformed request body missing required 'code' field — validation error returned

## How this service works

Run untrusted code in isolated sandboxes, one payment per execution.

## Output

Returns a JSON object with a success boolean, the language used, captured stdout and stderr as ordered arrays, Jupyter-style rich results (including base64 PNG images, HTML, or text from the final expression), and a structured error object (name, message, traceback) if execution failed — all null on success.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "code"
 ],
 "properties": {
  "env": {
   "type": "object",
   "description": "Environment variables visible to this execution only"
  },
  "code": {
   "type": "string",
   "description": "Source code to execute"
  },
  "language": {
   "enum": [
    "python",
    "javascript",
    "typescript"
   ],
   "type": "string",
   "description": "Interpreter to run the code with. Defaults to python."
  },
  "timeout_ms": {
   "type": "integer",
   "description": "Execution wall-clock limit in milliseconds (1000 to 60000, default 30000). Executions that exceed it are killed."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "success",
  "language",
  "logs",
  "results",
  "error"
 ],
 "properties": {
  "logs": {
   "type": "object",
   "required": [
    "stdout",
    "stderr"
   ],
   "properties": {
    "stderr": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "Captured stderr chunks, in order"
    },
    "stdout": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "Captured stdout chunks, in order"
    }
   },
   "additionalProperties": false
  },
  "error": {
   "anyOf": [
    {
     "type": "object",
     "required": [
      "name",
      "message",
      "traceback"
     ],
     "properties": {
      "name": {
       "type": "string"
      },
      "message": {
       "type": "string"
      },
      "traceback": {
       "type": "array",
       "items": {
        "type": "string"
       }
      }
     },
     "additionalProperties": true
    },
    {
     "type": "null"
    }
   ]
  },
  "results": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "png": {
      "type": "string",
      "description": "Base64 PNG when the code produced an image, e.g. a matplotlib chart"
     },
     "html": {
      "type": "string"
     },
     "text": {
      "type": "string"
     }
    },
    "additionalProperties": true
   },
   "description": "Rich outputs from the final expression, Jupyter-style"
  },
  "success": {
   "type": "boolean",
   "description": "True when the code ran without raising an error"
  },
  "language": {
   "type": "string"
  }
 },
 "additionalProperties": true
}
```

## More

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