Code execution (Pro)
$0.050 per call · USDC via x402 ·
POST /api/code-run-proExecute Python or JavaScript code in a secure, isolated cloud sandbox (Pro tier). Same as /api/code-run but with 60s timeout and 50k char code limit for longer computations. Returns stdout, stderr, and the expression result.
Input
| Field | Type | Description |
|---|---|---|
code * | string | Source code to execute (max 50,000 chars) |
language | string | Language: python (default) or javascript |
Example output
{
"language": "python",
"stdout": "Hello from Agent402!\n",
"stderr": "",
"result": null,
"error": null
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/api/code-run-pro \
-H "Content-Type: application/json" \
-d '{"code":"print('Hello from Agent402!')","language":"python"}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/code-run-pro", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"code": "print('Hello from Agent402!')",
"language": "python"
}),
});
Wallet-only. This tool reaches the network/browser/storage, so it is paid in USDC via x402 (no proof-of-work tier).
Related tools
LLM inference
$0.010 ·
POST /api/llmLLM inference proxy - send an OpenAI-format chat/completions request and get a response from GPT-4o-mini. Supports visio…
LLM inference (Pro)
$0.100 ·
POST /api/llm-proLLM inference proxy (Pro tier) - GPT-4o or GPT-4.1. Supports vision (up to 2 image URLs) and structured output (response…
LLM inference (Premium)
$0.500 ·
POST /api/llm-premiumLLM inference proxy (Premium tier) - o3 or o3-mini reasoning models. Supports vision (up to 2 image URLs) and structured…