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

Endpoint
https://x402.auteng.ai/api/x402/compute

Quick 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 flow

Pricing

Choose the right size for your workload. All sizes support both Python and Node.js stacks.

SizevCPURAMDefault TimeoutMax TimeoutBase PricePer-Second
small21 GB30s5 min$0.002$0.00005
med44 GB60s10 min$0.008$0.00012
large88 GB120s1 hour$0.03$0.00025
Custom Timeouts
Request longer execution time by setting 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>"
  }
}
FieldTypeRequiredDescription
stackstringNopython (default) or node
sizestringNosmall (default), med, or large
timeout_secondsintNoCustom timeout (clamped to size max)
codestringYesCode to execute
filesobjectNoFiles 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. 1

    Request (No Payment)

    Client sends POST request without PAYMENT-SIGNATURE header

  2. 2

    402 Response

    Server returns HTTP 402 with PAYMENT-REQUIRED header containing payment requirements

  3. 3

    Sign Payment

    Client signs payment payload with wallet (EIP-712 typed data)

  4. 4

    Request (With Payment)

    Client retries request with PAYMENT-SIGNATURE header

  5. 5

    Verify & Execute

    Server verifies payment via CDP facilitator, executes code in sandbox

  6. 6

    Settle & Respond

    Server settles payment on-chain, returns result with PAYMENT-RESPONSE header

SDK Handles This
The x402 SDK handles steps 2-4 automatically. Your code just makes a normal HTTP request and receives the result.

Discovery

The service provides discovery endpoints for AI agents and marketplaces:

x402scan Discovery

curl https://x402.auteng.ai/.well-known/x402

Returns 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

StatusMeaning
402Payment required or invalid payment
400Invalid request (bad stack, size, missing code)
408Execution timeout
413Code or files too large
500Internal execution error
503Service unavailable
Execution Errors
If your code runs but exits with a non-zero exit code, you still receive a 200 response with 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

Ready to Start?

Start creating beautiful technical documentation with AutEng.

Get Started with AutEng