Pay with a wallet (x402)
Where the deployment enables it, you can call Aile with no account and no API key. Send the
request with no Authorization header. Aile answers 402 with the exact price and the lender
being paid, once per network it accepts: Solana, and Base where the deployment enables it. Sign a
USDC payment for that amount on either chain and send the same request again with a
PAYMENT-SIGNATURE header. This is x402, and any x402 client
(@x402/fetch, x402-axios, agentcash) does the signing for you. The same 402 can also be
paid with MPP where that is enabled.
1POST /v1/images/generations no Authorization header2 ← 402 + PAYMENT-REQUIRED price, USDC mint, payTo, feePayer, request schema3POST /v1/images/generations PAYMENT-SIGNATURE: <signed>4 → 200 + PAYMENT-RESPONSE the image, and the settled transaction
The money goes straight to the lender who serves the call. Aile takes no cut on this path and never holds the payment.
What you can buy
| Endpoint | Priced per | Notes |
|---|---|---|
/v1/chat/completions, /v1/messages, /v1/responses | token | Quoted against your max_tokens |
/v1/images/generations, /v1/images, /v1/images/edits | image | Up to 4 per request; base64 answer |
/v1/audio/speech | 1,000 characters | Buffered; stream_format: "sse" works, audio streaming needs a key |
/v1/audio/transcriptions, /v1/audio/translations | minute of audio | Priced on the file's measured length; up to 10 minutes |
/v1/search | query of up to 10 results | |
/v1/scrape | webpage | One page; name max_pdf_pages to parse a PDF, and you pay for that many |
/v1/rerank, /v2/rerank | search (up to 100 documents) | |
/v1/moderations | input | |
/v1/ocr | page | Name pages for a PDF |
/v1/music/generations | track | One-shot models such as Lyria |
/v1/videos, /v1/videos/generations | second | Charged when the render starts, refunded if it fails; poll with no key |
Keyless chat and the media endpoints are separate deployment settings.
GET https://api.aile.sh/x402/discovery lists exactly which endpoints take a wallet payment
right now. Embeddings, decisions and music render jobs (Suno) need an API key.
Example: one image
1# 1. Ask. No credential.2curl -si https://api.aile.sh/v1/images/generations \3-H "Content-Type: application/json" \4-d '{ "model": "openrouter/black-forest-labs/flux.2-pro", "prompt": "a lighthouse at dusk" }'5# -> 402. accepts[0] has amount (micro-USDC), asset, payTo and extra.feePayer.67# 2. Sign that transfer, base64 it, and resend the same body.8curl -si https://api.aile.sh/v1/images/generations \9-H "Content-Type: application/json" \10-H "PAYMENT-SIGNATURE: $SIGNED" \11-d '{ "model": "openrouter/black-forest-labs/flux.2-pro", "prompt": "a lighthouse at dusk" }'12# -> 200 with data[0].b64_json, plus PAYMENT-RESPONSE.
Every 402 carries extensions.bazaar with the request schema for that endpoint, so an agent
can build the paid call from the challenge alone.
Solana or Base
accepts[0] is always Solana: a USDC transfer built around the extra.feePayer it names. Where
the deployment enables Base, a second entry on eip155:8453 pays the same amount to the lender's
Base address, when the lender has one: sign an EIP-3009 transferWithAuthorization for Base USDC. There is no fee payer on Base; the
facilitator pays the gas. Register both schemes and the client pays on whichever chain holds
your USDC:
1import { ExactEvmScheme } from "@x402/evm/exact/client";23client.register("eip155:*", new ExactEvmScheme(evmSigner));
The PAYMENT-RESPONSE receipt names the network the payment settled on.
Paying with MPP instead
Where the deployment enables it, every priced 402 also speaks MPP, the "Payment" HTTP auth
scheme. Beside the unchanged x402 document it carries WWW-Authenticate: Payment challenges, one
per method that can pay this call, at the same price to the same lender. Several challenges share
one comma-separated header line. Each is intent="charge" and expires after 120 seconds. The
JSON body also gains the problem fields type, title, status and detail.
| Method | What you sign | Offered when |
|---|---|---|
evm | An EIP-3009 authorization for USDC on Base, whose nonce is bound to the challenge. The facilitator settles it. | The deployment enables Base and the lender has a Base address |
solana | A USDC transfer to the lender, sent unbroadcast. Aile's sponsor is the fee payer: it co-signs and broadcasts once your answer is ready. | Aile's sponsor is funded and the lender's USDC account exists |
tempo | A stablecoin transfer on Tempo to the lender's EVM address (USDC.e on mainnet). Aile pays the fee, co-signs and broadcasts. | The deployment runs a Tempo fee payer. Not on video or use_agent_tool |
An MPP client (mppx for EVM and Tempo, @solana/pay-kit for Solana) answers with
Authorization: Payment <credential>, which is never read as an API key. A chat request made
with an API key is offered header="Payment-Authorization" instead: send the credential in
Payment-Authorization and keep your key in Authorization.
1import { Mppx, evm } from "mppx/client";23const mppx = Mppx.create({ methods: [evm({ account })], polyfill: false });4const res = await mppx.fetch("https://api.aile.sh/v1/images/generations", { method: "POST", body });
A settled payment comes back with a Payment-Receipt header and Cache-Control: private, never
PAYMENT-RESPONSE. The receipt is base64url JSON naming the method, the challengeId, the
transaction as reference, and a status, timestamp and chainId. A settlement that failed
or could not be confirmed carries no receipt. On the media endpoints a refused settlement is a
402 with a fresh challenge.
Everything else is x402's: the payment goes straight to the lender with no platform cut, a credential is single-use, and the answer is buffered, never streamed.
When you are charged
- Only for what you get. The payment settles after the answer is ready and before it is sent. If the lender fails, or returns fewer images than you paid for, nothing settles and you get an error saying you were not charged. Two surfaces charge the quote as named: a transcription is priced on the length Aile measured, and a scrape on the page cap you chose. Video is the exception, below.
- No failover. A signed payment names one lender at one price, so a failed call is not retried elsewhere. Sign a new payment to try again.
- A signed payment is single-use. Re-sending the same
PAYMENT-SIGNATUREafter a call is refused. A Solana payment also expires about a minute after you sign it.
Video: paid up front, refunded on failure
A render takes minutes, longer than a signed payment lives, so a video is charged when the
provider accepts the job. Poll GET /v1/videos/{id} with no key. If the render fails or
expires, the payment goes back to the wallet that paid, on the chain it paid on, and the job's
status shows refund: { state, transaction } until it lands. Base is offered for video only where
the deployment can send that refund on Base, and MPP's tempo method is not offered for video.
Limits
- One call costs at most $5.00 without an account.
- Wallet calls are rate-limited per IP (30 a minute) and per paying wallet (two at a time).
- Very small quotes, such as a short speech clip, can fall under the facilitator's minimum
(about $0.0008 on Solana, $0.0011 on Base). The
402then has noacceptsentry and says so; use an API key. - Wallet calls reach self-hosted and nodeless lenders only, never a lender's personal Claude Code or Codex subscription. A refusal naming an API key means the model you asked for is only served that way.
Over MCP
The same purchases are MCP tools on https://api.aile.sh/mcp: use_model (one chat call),
generate_image, edit_image, text_to_speech, transcribe_audio, generate_music,
web_search, scrape_url, generate_video with get_video, and find_models to see what is
for sale. Another agent's tool is find_agent_tools, then use_agent_tool. A session with no
key sees use_model and the two agent-tool tools where the deployment enables keyless chat, and
the media tools where it enables keyless media.
With no key, the first call returns the 402 document as a tool result (isError, the document
in structuredContent). Sign it and call the tool again with the PaymentPayload in
_meta["x402/payment"]; images and audio come back as content blocks and the receipt in
_meta["x402/payment-response"]. An MPP client finds the same challenges in
_meta["org.paymentauth/payment-required"] on that result, pays with
_meta["org.paymentauth/credential"], and gets _meta["org.paymentauth/receipt"] back.
use_agent_tool takes an evm or solana credential; tempo is not offered there. See
Rent via MCP.
Finding it without asking
GET https://api.aile.sh/x402/discovery(also/.well-known/x402): what is payable now, on which network, in which asset.GET https://api.aile.sh/openapi.json: the payable routes with their schemas and price bands. Where MPP is enabled, each payable operation'sx-payment-info.protocolslists anmppentry (method,intent,currency) besidex402for every method that can settle right now, and/x402/discoverycarries anmppblock. A method that is off is never listed.GET https://api.aile.sh/v1/models?x402=keyless: the models a wallet can buy right now, each withpricing(its list price, the most a call can cost; the lender you get may charge less).
Older clients that send X-PAYMENT and read X-PAYMENT-RESPONSE (x402 v1) work too; Aile
answers in whichever version you used.