402 Payment Required with machine-readable payment instructions, pays,
and retries. The wallet is the identity, and you pay per call in USD.
Two payment rails are supported on the same endpoints:
x402
Settle in USDC on Base mainnet. Gasless: the facilitator sponsors gas, you sign an
authorization. Works with any standard x402 client.
MPP
Machine Payments Protocol, settling on Tempo. The buyer signs and broadcasts the
transfer, then replays the credential.
Which path do you want? This page is the no-account path: pay each call from a
crypto wallet, nothing to set up. If you would rather hold a USD balance and call with an
API key, see the Quickstart or let your
agent onboard itself. Both hit the same
/v1/run/{sku} endpoints.How inline payment works
The flow is the standard HTTP 402 handshake, identical for both rails: AnyAPI validates the SKU and input before it calculates a challenge or accepts a payment. An unknown SKU or invalid payload therefore fails immediately without asking the agent to pay.1
Call the endpoint
Make a normal
POST https://api.getanyapi.com/v1/run/{sku} with the SKU’s JSON input and
no credentials.2
Get a 402 with payment instructions
AnyAPI responds
402 Payment Required. The x402 challenge rides in the
PAYMENT-REQUIRED header (and the response body); the MPP challenge rides in the
WWW-Authenticate: Payment header. Each carries the price, the network, the asset, and
the address to pay.3
Pay and retry
Your client signs the payment and re-sends the request with the credential attached
(
PAYMENT-SIGNATURE / X-PAYMENT for x402, Authorization: Payment for MPP). AnyAPI
verifies the payment, runs the API, and returns 200 with the result plus a receipt
header.Pay with x402 (Base, USDC)
The simplest path is a standard x402 client such asx402-fetch, which wraps fetch and handles the
402, the signature, and the retry automatically. Point it at any SKU:
You only pay on success. With x402, AnyAPI settles the payment after the API call
succeeds, so a failed run never charges you. The response includes
costUsd (the USD
charged) and provider: "AnyAPI". A recognized empty result such as found: false is a
successful answer and is charged like any other successful result.- Network: Base mainnet (
eip155:8453). - Asset: USDC (
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913). - Price: the per-call USD amount, in the challenge’s
amount(atomic units). - Versions: the v2 challenge is in the
PAYMENT-REQUIREDheader; the v1 challenge is in the response body, so stockx402-fetchworks out of the box. Pay back withPAYMENT-SIGNATURE(v2) orX-PAYMENT(v1).
Pay with MPP (Tempo)
The same endpoints accept Machine Payments Protocol on Tempo. Use themppx client, which signs and broadcasts the transfer,
then replays the credential:
WWW-Authenticate: Payment header
(method="tempo", intent="charge"); you settle on Tempo (chain id 4217) and replay the
credential in Authorization: Payment. AnyAPI returns the result with a Payment-Receipt
header.
What you pay
- Per call, in USD. Each endpoint is priced in real dollars, shown as the
amountin the 402 challenge and ascostUsdin the result. There is no subscription and no minimum. - No balance to hold. You pay straight from your wallet on each call; nothing is pre-funded with AnyAPI.
- AnyAPI is the provider. Responses report
provider: "AnyAPI"and the USD cost, the same normalized shape as a keyed call. - Empty can still be successful. A normalized result such as
found: falsemeans the lookup completed and found no matching entity. It is a successful, billable result rather than an upstream failure.
Discovery
AnyAPI’s endpoints are listed in the x402 Bazaar (the Coinbase facilitator’s discovery index) and on explorers like x402scan, so an agent can find a SKU, read its input and output schema, and pay it without you wiring anything up. You can also pull the full machine-readable spec athttps://api.getanyapi.com/openapi.json.