x402 Compute API — Pay-Per-Request Code Execution for AI Agents
Execute Python and Node.js code in sandboxed environments with USDC micropayments. No accounts, no API keys — just pay and compute.
Overview
AutEng's x402 compute service enables AI agents to execute code in sandboxed environments and pay per-request using USDC stablecoins via the x402 protocol. No accounts required. No API keys. Just pay and compute.
Python 3.14
NumPy, Pandas, Requests, and more
Node.js 24 LTS
TypeScript, npm packages
USDC on Base
From $0.002 per request
https://x402.auteng.ai/api/x402/computeQuick Start
The x402 protocol uses HTTP 402 (Payment Required) responses. When you make a request without payment, you receive payment requirements. Sign the payment with your wallet, include it in the header, and your code executes.
Execute Code
Complete examples using the x402 SDK
# Step 1: Get payment requirements (returns 402)
curl -X POST https://x402.auteng.ai/api/x402/compute \
-H "Content-Type: application/json" \
-d '{"stack": "python", "size": "small", "code": "print(1+1)"}'
# Step 2: Use x402 SDK to sign and pay automatically
# See Python or TypeScript examples for full flowPricing
Choose the right size for your workload. All sizes support both Python and Node.js stacks.
| Size | vCPU | RAM | Default Timeout | Max Timeout | Base Price | Per-Second |
|---|---|---|---|---|---|---|
| small | 2 | 1 GB | 30s | 5 min | $0.002 | $0.00005 |
| med | 4 | 4 GB | 60s | 10 min | $0.008 | $0.00012 |
| large | 8 | 8 GB | 120s | 1 hour | $0.03 | $0.00025 |
timeout_seconds. You pay the base price plus per-second rate for time beyond the default timeout.Size Selection Guide
small (default)
API calls, JSON parsing, light analysis, HTTP requests, simple calculations
med
Heavier dependencies, data processing, pandas operations, npm installs, TypeScript compilation
large
Must succeed first time, parallel operations, large data analysis, complex builds
API Reference
Request
POST https://x402.auteng.ai/api/x402/compute
Content-Type: application/json
PAYMENT-SIGNATURE: <base64_signed_payload>
{
"stack": "python",
"size": "small",
"timeout_seconds": 60,
"code": "print('Hello, world!')",
"files": {
"data.csv": "<base64_content>"
}
}| Field | Type | Required | Description |
|---|---|---|---|
| stack | string | No | python (default) or node |
| size | string | No | small (default), med, or large |
| timeout_seconds | int | No | Custom timeout (clamped to size max) |
| code | string | Yes | Code to execute |
| files | object | No | Files to upload (filename → base64 content) |
Response (Success)
{
"stdout": "Hello, world!\n",
"stderr": "",
"exit_code": 0,
"execution_time_ms": 234,
"files": {},
"stack": "python",
"size": "small",
"sandbox_id": "sbx_abc123"
}Response (402 Payment Required)
When no payment is provided, the server returns HTTP 402 with payment requirements in the PAYMENT-REQUIRED header (base64-encoded) and response body:
{
"x402Version": 2,
"error": "PAYMENT-SIGNATURE header is required",
"resource": {
"url": "https://x402.auteng.ai/api/x402/compute",
"description": "Execute python code (small)",
"mimeType": "application/json"
},
"accepts": [
{
"scheme": "exact",
"network": "eip155:8453",
"amount": "2000",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0x...",
"maxTimeoutSeconds": 300,
"extra": {
"name": "USDC",
"version": "2"
}
}
],
"extensions": {
"bazaar": {
"info": { ... },
"schema": { ... }
}
}
}Protocol Flow
The x402 protocol follows a simple request-payment-execute flow:
- 1
Request (No Payment)
Client sends POST request without
PAYMENT-SIGNATUREheader - 2
402 Response
Server returns HTTP 402 with
PAYMENT-REQUIREDheader containing payment requirements - 3
Sign Payment
Client signs payment payload with wallet (EIP-712 typed data)
- 4
Request (With Payment)
Client retries request with
PAYMENT-SIGNATUREheader - 5
Verify & Execute
Server verifies payment via CDP facilitator, executes code in sandbox
- 6
Settle & Respond
Server settles payment on-chain, returns result with
PAYMENT-RESPONSEheader
Discovery
The service provides discovery endpoints for AI agents and marketplaces:
x402scan Discovery
curl https://x402.auteng.ai/.well-known/x402Returns the x402scan discovery document listing all available resources:
{
"version": 1,
"resources": [
"https://x402.auteng.ai/api/x402/compute"
],
"ownershipProofs": ["0x..."],
"instructions": "# AutEng x402 Compute Service\n..."
}Bazaar Extension
The 402 response includes a Bazaar extension with input/output schemas for AI agent discovery:
{
"extensions": {
"bazaar": {
"info": {
"input": {
"type": "http",
"method": "POST",
"bodyType": "json",
"body": {
"code": "print('Hello!')",
"stack": "python",
"size": "small"
}
},
"output": {
"type": "json",
"example": {
"stdout": "Hello!\n",
"stderr": "",
"exit_code": 0
}
}
},
"schema": { ... }
}
}
}Error Handling
| Status | Meaning |
|---|---|
| 402 | Payment required or invalid payment |
| 400 | Invalid request (bad stack, size, missing code) |
| 408 | Execution timeout |
| 413 | Code or files too large |
| 500 | Internal execution error |
| 503 | Service unavailable |
exit_code set and error output in stderr. Payment is still settled.Security
Payment Security
- All payment verification via Coinbase CDP (trusted facilitator)
- No private keys stored on AutEng servers
- Settlement only after successful execution
- EIP-712 typed data signatures for payment authorization
Execution Security
- Fresh sandbox per request (no state leakage between agents)
- Resource limits enforced per size tier
- Network access available (for API calls, package installs)
- File size limits: 1MB code, 10MB total files
Resources
Related Content
AutEng - AI-Native Technical Documentation
Create beautiful technical documentation with Markdown, Mermaid diagrams, and KaTeX math equations
Pricing
Simple, transparent pricing for individuals and teams
Documentation
Complete guide to using AutEng for technical documentation
Privacy Policy
How we collect, use, and protect your data
Terms of Service
Terms and conditions for using AutEng
Ready to Start?
Start creating beautiful technical documentation with AutEng.
Get Started with AutEng