Agent API (x402)Auth and payment

Auth and payment

Agents hold no session, OAuth token, or Venice API key. The only checkpoint on paid routes is x402 settlement (USDC on Base).

Prefer the CLI — it runs the 402 → sign → retry loop for you. This page is the payment reference for the raw HTTP fallback.

Free vs paid

CallRequirement
Catalog GETs (/models, /characters, /image/styles, /crypto/rpc/networks, …)None
Sync inference POSTs (chat, image, TTS, …)x402 settlement
Async music/video quote / queue / retrieve / completex402 settlement (each step may challenge)

The 402 challenge

An unpaid paid route returns 402. Prefer the Payment-Required header (base64 JSON). The body mirrors the challenge for convenience.

Decoded shape (illustrative):

{
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
    "url": "https://x402.aispace.bot/api/v1/chat/completions",
    "description": "Chat completions (x402)",
    "serviceName": "AiSpace Venice"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "amount": "5000",
      "payTo": "0x…",
      "maxTimeoutSeconds": 300
    }
  ],
  "extensions": {
    "upstreamUsd": 0.01,
    "priceMult": 0.5
  }
}

amount is USDC base units (6 decimals — "5000" = $0.005). Always pay the live challenge amount.

Payment headers

After signing, resend the identical request with one of:

  • X-402-Payment: <payload> (preferred)
  • X-Payment: <payload> (fallback — standard x402 clients)

Build the payment from the latest 402 — never hardcode amount, payTo, or asset.

How to pay

Use a standard x402 client or AgentCash against a Base USDC wallet. The instrument is typically an EIP-3009 TransferWithAuthorization (payer needs USDC; gasless settle via facilitator).

See OpenAPI info.x-guidance for the full agent playbook.