# x402-gateway Rust Code Runner (cargo_run)

> x402-gateway Rust Code Runner (cargo_run) is a paid API for AI agents from x402.freeq.one, paid per call via x402, $0.002/call, status unknown (last checked 2026-11-15).

Executes a Rust source file in a sandboxed environment, returning stdout, stderr, exit code, and timings — paid per call in USDC on Base via x402.

## Facts

- Endpoint: POST https://x402.freeq.one/tools/cargo_run?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-gateway-rust-code-runner-cargo-run-da8b0246
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_fpc22Gj2I5kRFw-SusFYG

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 x402-gateway-rust-code-runner-cargo-run-da8b0246 -d '<json body>'
```

Example prompt: Can you run this Rust program for me using the 2021 edition and pass 'Alice
' as stdin? Here's the code: fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); println!("Hello, {}", s.trim()); }

## When to prefer this

Choose this endpoint when you need to compile and run arbitrary Rust code in a sandboxed remote environment without setting up local toolchains, CI, or cloud VMs. It is ideal for AI agents that generate or validate Rust code snippets, need execution results as part of a pipeline, and want pay-per-use billing (USDC on Base) with no account or API key setup. Prefer it over general-purpose code execution services when the target language is specifically Rust and you need cargo_run semantics including edition and release-mode control.

## Known failure modes

- Code exceeds 64 KB limit — request rejected
- Stdin exceeds 16 KB limit — request rejected
- Compilation error — job completes with non-zero exit code and compiler error in stderr
- Execution timeout (up to 1 hour max) — job terminated
- Payment failure via x402 — call not executed
- Invalid Rust edition specified — may default or error
- Network access to major cloud providers blocked from sandbox — runtime network calls may fail
- Result expired after 7 days — polling returns nothing

## How this service works

Rust Code Runner: Run a Rust file in a sandbox. One call buys up to an hour: submit code (64 KB) and optional stdin (16 KB), get a job_id, then poll the free result endpoint for stdout/stderr (64 KB each), exit code, timings. Results kept 7 days; extend with same code and job_id. Network access outside the major clouds. Price varies with upstream compute ($0.002–$0.10), shown before you pay. Pay per call in USDC on Base via x402 — POST https://x402.freeq.one/tools/cargo_run.

## Output

The initial POST returns a job_id. Polling the free result endpoint with that job_id yields: stdout (up to 64 KB), stderr (up to 64 KB), an integer exit code, and compilation/execution timing data. Results are retained for 7 days and can be extended by resubmitting with the same code and job_id.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "job_id": {
   "type": "string",
   "example": "job_abc123",
   "description": "Extend a previous job with the same zip URL for one more hour"
  },
  "zip_url": {
   "type": "string",
   "description": "Public URL of the zip to run; entrypoint.sh at the zip root runs (a single top-level folder is also accepted)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "content": [],
  "isError": false,
  "structuredContent": {}
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-gateway-rust-code-runner-cargo-run-da8b0246/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.freeq.one](https://www.zero.xyz/host/x402.freeq.one/llms.txt)
