Guide · x402 pay-per-call
Pay Synap per call with x402
-
Fund a wallet with USDC on Base
No account, no email, no API key. Any wallet holding USDC on Base can pay, and the paying address is the account.
-
Ask the endpoint what it costs
A call with no payment header answers
402and states exactly what to pay — amount, token, chain and recipient — in the x402 v2 format.curl -sS https://synap.linkrra.com/api/billing/x402/chat/completions \ -H 'content-type: application/json' \ -d '{"model":"qwen3-coder-30b","messages":[{"role":"user","content":"Say OK"}],"max_tokens":16}' -
Pay the quote and get the answer
The client signs the quote and retries the same request. Register the Base rail under its CAIP-2 id,
eip155:8453. Node first, Python second.// npm i @x402/fetch @x402/evm viem import { wrapFetchWithPayment, x402Client } from "@x402/fetch"; import { ExactEvmScheme } from "@x402/evm"; import { privateKeyToAccount } from "viem/accounts"; const signer = privateKeyToAccount(process.env.PRIVATE_KEY); const client = new x402Client().register("eip155:8453", new ExactEvmScheme(signer)); const pay = wrapFetchWithPayment(fetch, client); const r = await pay("https://synap.linkrra.com/api/billing/x402/chat/completions", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ model: "qwen3-coder-30b", messages: [{ role: "user", content: "Write a Python function that reverses a string" }], max_tokens: 256, }), }); console.log((await r.json()).choices[0].message.content);# pip install "x402[httpx,evm]" eth-account import asyncio, os from eth_account import Account from x402.client import x402Client from x402.http.clients.httpx import x402HttpxClient from x402.mechanisms.evm import EthAccountSigner from x402.mechanisms.evm.exact import ExactEvmClientScheme async def main(): signer = EthAccountSigner(Account.from_key(os.environ["PRIVATE_KEY"])) client = x402Client().register("eip155:8453", ExactEvmClientScheme(signer)) async with x402HttpxClient(client, timeout=120) as http: r = await http.post("https://synap.linkrra.com/api/billing/x402/chat/completions", json={ "model": "qwen3-coder-30b", "messages": [{"role": "user", "content": "Write a Python function that reverses a string"}], "max_tokens": 256}) print(r.json()["choices"][0]["message"]["content"]) asyncio.run(main())
Notes, prices and limits
The same chat endpoint, paid per call in USDC instead of with a key. Recommended model: qwen3-coder-30b —
$0.0675 in and $0.27 out
per 1M tokens, 98,304-token context.
Use the x402 v2 packages — @x402/fetch and @x402/evm on Node, or the Python x402 SDK. The older x402-fetch 1.x cannot read this quote: it rejects eip155:8453, because v1 names the chain base instead.
The quote is a minimum, not the bill: $0.001 buys the call, and usage above that is priced per token at the same rate as the keyed API.
model must be an id that /v1/models lists, or auto to let us pick the cheapest model that fits. A name we do not serve comes back with a suggested_model and its own quote, so the retry can be signed for the right amount.
Payment is USDC on Base. We re-read every settlement from the chain before answering: the transaction must exist, have succeeded, and carry a USDC transfer to our address — the facilitator’s word is not enough. A wallet with no USDC is turned away at verification, so fund it first.
The body, the streaming and the tool-calling fields are the same as the keyed API. The only difference is how you pay for the call.
Field names from the x402 v2 payment requirements this endpoint returns, and the x402 SDKs run against it, checked 2026-11-03 17:45 UTC. Prices refresh from /v1/models when this page loads.