open solid
Money movement
View as Markdown

Paying any x402 API

More and more of the tools an agent's company needs are sold per call over x402: generation models, search, scraping, enrichment, market data. Your agent can pay them straight from its Open Solid wallet.

How x402 works

The agent calls a paid endpoint. The endpoint answers 402 Payment Required with a challenge: the price, the asset, the network and the address to pay. The client pays that amount in USDC and retries, and the call goes through. No account, no API key, no invoice.

Make the call

Use POST /api/v1/pay (or the pay MCP tool) with type: "x402". Open Solid makes the request, reads the challenge, pays it from the wallet and returns the API's own response.

curl -X POST https://opensolid.ai/api/v1/pay \
  -H "Authorization: Bearer $OPENSOLID_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "type": "x402",
    "url": "https://api.example.com/v1/generate",
    "method": "POST",
    "body": {"prompt": "15-second clip of a nursery coming together"},
    "max_usd": 0.50,
    "note": "Reel for this week's nursery post"
  }'
Field Required Meaning
url yes A public https:// endpoint that answers with an x402 challenge
max_usd yes The most you'll pay for this one call
method no GET by default, POST when you send a body
body no JSON sent to the API as-is
note yes One sentence on why, shown in the owner's feed

The response is {replayed, status, ok, paid_usd, result, activity}. result is what the API returned: JSON when it sent JSON, otherwise text.

Ceilings

The quote in the 402 challenge is checked before anything is signed:

  • Over max_usd: refused with 402. Nothing is charged; retry with a higher cap if the price is right.
  • Over the spend limit: refused with 403 and terminal: true. Ask the owner to raise the limit; never split a call to get under it.

max_usd can only tighten: it lowers the ceiling for one call and can never raise the owner's limit.

Networks

Open Solid pays x402 challenges in USDC on Base. The wallet's Solana and Base balances act as one: if the Base side is short, the difference moves over from Solana automatically before paying. An API that only accepts other networks is refused with 422 and nothing is charged.

Refusal or endpoint error

  • Refusal: the price, the network or a limit didn't fit, so nothing was signed. It's safe to retry with corrected input.
  • Endpoint error: the service answered non-2xx after a payment was offered. Payment may or may not have settled. Don't blindly repeat a paid request. Check GET /api/v1/activity first, and reuse the same Idempotency-Key when you do retry.