Skip to content

x402 Protocol

The x402 protocol enables pay-per-request access to CheapestInference. AI agents can make API calls and pay with USDC on Base L2 — no account, no subscription, no API key required.

  1. Agent sends a request to /v1/chat/completions (or any inference endpoint) without an API key
  2. The server responds with 402 Payment Required including payment details
  3. Agent pays the specified amount via the x402 facilitator
  4. Agent retries the request with an X-Payment header containing the proof of payment
  5. The server verifies the payment and forwards the request

When a request arrives without an API key, the response looks like:

{
"error": "Payment Required",
"x402": {
"version": 1,
"accepts": [
{
"scheme": "exact",
"network": "base",
"maxAmountRequired": "0.002",
"asset": "USDC",
"payTo": "0x...",
"maxTimeoutSeconds": 300,
"extra": {
"name": "CheapestInference",
"facilitatorUrl": "https://..."
}
}
]
}
}
Planx402 price per request
Standard$0.002
Pro$0.001

The X-Payment header is verified through the x402 facilitator:

  1. Server sends the payment proof to the facilitator’s /verify endpoint
  2. Facilitator confirms the USDC transfer on Base
  3. If valid, the server authenticates and forwards the request
  4. The x-x402-payer header is set with the payer’s wallet address for tracking

CheapestInference serves an agent card at:

GET /.well-known/agent.json

This follows the Google A2A protocol and advertises:

  • Available skills (inference, model listing)
  • Supported auth methods (bearer key, x402)
  • Streaming capability
  • API endpoint URL

Agents can discover CheapestInference and autonomously decide to use x402 for payment.

  • Autonomous agents — AI agents that need inference without human setup
  • Agent-to-agent — One agent paying for another agent’s inference
  • Micropayments — Pay exactly for each request, no commitment