Guides
Pay per request with x402
x402 turns HTTP 402 Payment Required into a working payment flow. An agent with a funded wallet can call the API without signing up.
The flow
- Send the normal chat request without a key. The answer is
402with the payment requirements: amount, asset, network and recipient. - Sign a USDC transfer authorization on Base for that amount with any x402 client.
- Repeat the same request with the
PAYMENT-SIGNATUREheader (x402 v2) orX-PAYMENT(v1). The answer is the completion plus aPAYMENT-RESPONSEreceipt.
curl -i https://api.laminarity.uk/v1/chat/completions \
-H 'content-type: application/json' \
-d '{"model":"deepseek-ai/DeepSeek-V4-Flash-0731","messages":[{"role":"user","content":"Hello"}],"max_tokens":64}'
HTTP/2 402
payment-required: eyJ4NDAyVmVyc2lvbiI6Mi… # base64 JSON, x402 v2
{"x402Version":1,"accepts":[{"scheme":"exact","network":"eip155:8453",
"maxAmountRequired":"1000","payTo":"0x…",
"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", …}]}Price
price = max($0.001, (prompt tokens + max_tokens) × $0.15 / 1,000,000). When max_tokens is omitted it defaults to the model maximum, so set it to pay less. maxAmountRequired is in USDC base units: 1000 is $0.001.
Retries are safe
Sending the same signed payment twice returns the stored response and is never settled twice, so a client can retry after a timeout.
Discovery
- /.well-known/x402 — resources and instructions
- openapi.json — OpenAPI 3.1 with payment information
- llms.txt — a summary written for language models
Humans and long-running apps are usually better served by an API key: no per-call signature and no $0.001 minimum.