Quickstart
Base URL: /v1. There are two ways to pay for a call, and both reach the same models at the same price.
- Prepaid key. Deposit once, get a key that starts with
off_sk_, and use it as a normal bearer token. Best for anything built on an OpenAI SDK. - Pay per call. Send no key. The gateway replies
402with a price and an x402 client pays it. Best for autonomous agents that hold their own wallet.
curl /v1/chat/completions \ -H "Authorization: Bearer $OFFROUTER_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "deepseek-v4.1-flash", "stream": true, "messages": [{"role": "user", "content": "Hello"}]}'
List the models with GET /v1/models, or see them on the models page.
Images and video
Some models read images, and some read video too: input_modalities on each entry of GET /v1/models says which. Send them the OpenAI way, as an array of parts in content. Every model answers in text.
{"model": "gemma-4-31b", "max_tokens": 400,
"messages": [{"role": "user", "content": [
{"type": "text", "text": "What does this chart show?"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0..."}}
]}]}- Inline only. Each image or clip is a base64
data:URL (video goes in avideo_urlpart). A remote link is refused withremote_media_not_allowed: fetching it would send a request out of the enclave to a host that then knows what you asked about. - The price ceiling is the whole context window. A model counts an image by its size on screen, not its bytes, so the request cannot be bounded any tighter before it runs. Pay per call collects that ceiling and refunds the rest; a prepaid key holds it for the length of the call and settles to the real token count.
- It encrypts like text. With end-to-end encryption the whole parts array is one ciphertext, so the gateway never holds the image.
Embeddings, rerank and speech to text
Three more endpoints, each in a GPU TEE and paid the same two ways. Their models are listed in GET /v1/models with type embedding, rerank or transcription.
Embeddings
curl /v1/embeddings \ -H "Authorization: Bearer $OFFROUTER_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qwen3-embedding-0.6b", "input": ["first passage", "second passage"]}'
- Input. A string, up to 256 strings, or token-id arrays; up to 32K tokens each. Vectors have 1024 dimensions;
dimensionsis refused because the model has one size.encoding_formatmay befloatorbase64. - Price. Per input token, with no
max_tokens. Pay per call collects a ceiling of one token per byte of input and refunds the rest. - Proof. The response links the model's attestation (
X-OffRouter-Attestation) but carries no per-call receipt: NEAR, which serves this model, does not sign embeddings. Embeddings are not end-to-end encrypted yet.
Rerank
The second step of search over your own documents: embeddings find the candidates, rerank puts the best first.
curl /v1/rerank \ -H "Authorization: Bearer $OFFROUTER_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qwen3-reranker-0.6b", "query": "how do I pay per call", "documents": ["Pay per call with x402", "Fund a prepaid key"], "top_n": 1}'
- Input. A
queryand up to 256documents, as strings or{"text": ...}objects (the Cohere and Jina format).top_nkeeps the best n;return_documentsechoes each text back. - Output.
results, best first, each with the document'sindexand arelevance_scorefrom 0 to 1. - Price. Per input token: the model reads the query with each document in turn. Pay per call collects a ceiling from the size of the query and documents and refunds the rest.
- Proof. Like embeddings, the response links the model's attestation (
X-OffRouter-Attestation) but carries no per-call receipt, and is not end-to-end encrypted yet.
Speech to text
curl /v1/audio/transcriptions \
-H "Authorization: Bearer $OFFROUTER_KEY" \
-F model=voxtral-small-24b \
-F file=@meeting.m4a- Models.
voxtral-small-24bis the cheaper one and very accurate in the main European and Asian languages.whisper-large-v3covers about 100 languages and is the one that takesresponse_format: verbose_json(language, duration and timed segments). Both takelanguage,promptandtemperature. - The file. wav, mp3, m4a, ogg, webm or flac, at most 25 MB, sent as multipart like the OpenAI SDK sends it. It goes to the enclave and is never stored.
- Price. Per second of audio, rounded up. The price ceiling comes from the file before it is sent: exact for a PCM WAV, otherwise one second per 1000 bytes, and never more than 30 minutes. You are charged for the seconds transcribed; pay per call refunds the rest.
- Proof. Every answer carries a signed receipt (
X-OffRouter-Receipt-URL). Phala routes Whisper to NEAR AI's enclave and Voxtral to Tinfoil's; the receipt names the route and the verified model.
Prepaid keys
A key is created by a deposit and spends down per call. There are no accounts: the key is the account, and the wallet that paid for it is its owner. The easiest way to make one is the dashboard. The same thing over the API:
POST /v1/keys {"amount_usd": 5} # x402 deposit, returns the key once
POST /v1/keys/topup {"amount_usd": 5} # x402 deposit + Bearer, adds balance
GET /v1/keys/me # balance and recent usage
DELETE /v1/keys/me # revoke, refund what is leftHow a keyed call is charged
Before the call is served, the worst case (your full input plus max_tokens of output) is held against the balance. After it finishes, the hold is settled down to the real token count. A key can never spend more than it holds, even with many calls at once.
If you leave max_tokens out it defaults to 8192. If the balance cannot cover the budget you asked for, the budget is lowered to what it can.
The charge for each call comes back in the X-OffRouter-Charge-USD response header.
Pay per call
With no key, a request is paid for on the spot using x402. The flow is two requests:
POST /v1/chat/completions # 402, price in PAYMENT-REQUIRED POST /v1/chat/completions + PAYMENT-SIGNATURE # settles, then 200 + PAYMENT-RESPONSE
max_tokens is required here. The price in the 402 is a ceiling: your full input plus max_tokens of output. Your client signs that amount, it settles onchain, and the call is served only after settlement.
Refunds
When the call ends, the real charge is worked out from actual usage. The difference between what you signed and what you used is queued as a refund to the paying wallet, on the network you paid on. A failed call or an empty completion is refunded in full. Small refunds are batched and sent together.
If the transfer was sent but has not confirmed yet, you get a 402 with "code": "settlement_pending", "pending": true and a Retry-After. Resend the same request with the same payment header after that many seconds; do not sign a new payment. The call is served once the transfer confirms, and it is never served before.
Refunds mean extra onchain transfers. If you make many calls, a prepaid key is cheaper to run and leaves a smaller onchain trail: one deposit instead of a payment and a refund per call.
Client
import { privateKeyToAccount } from "viem/accounts";
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm/exact/client";
const account = privateKeyToAccount(process.env.AGENT_KEY);
const client = x402Client.fromConfig({
schemes: [{ network: "eip155:4663", client: new ExactEvmScheme(account) }],
});
const pay = wrapFetchWithPayment(fetch, client);
const res = await pay("/v1/chat/completions", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
model: "gpt-oss-120b",
max_tokens: 512,
messages: [{ role: "user", content: "Hello" }],
}),
});A machine-readable description of every paid endpoint is at /.well-known/x402.
Networks
Every 402 lists each network below in accepts[] at the same amount, except that a Robinhood Chain quote is never under 1 cent (Priors, which settles it, takes nothing smaller; the unused part of a call is refunded). Pay on whichever one your wallet holds a balance on. Each network settles in its own dollar stablecoin, all with 6 decimals. Payments are a signed transfer authorization (EIP-3009), so the payer needs no gas token.
| Network | CAIP-2 | Asset | Paid from | Asset contract |
|---|---|---|---|---|
| Loading from the gateway… | ||||
This table is read live from GET /networks. A deposit is refunded on the network it arrived on.
Arc and Circle Gateway
On Arc, payments go through Circle Gateway. You pay from a Gateway balance, not from the USDC sitting in your wallet, so deposit into Gateway once before your first call. The 402 entry for Arc names Circle's GatewayWalletBatched contract in extra, and the authorization must stay valid for 7 days because Circle settles in batches.
Circle's client handles all of that: new GatewayClient({ chain: "arc", privateKey }) from @circle-fin/x402-batching/client, then client.deposit("5") once and client.pay(url, options) per call. A plain x402 client works unchanged on Base and Robinhood Chain.
Receipts
Every model runs in a GPU enclave (Intel TDX with a confidential NVIDIA GPU) on hardware we do not operate. Each response carries three headers so you can check that for yourself:
X-OffRouter-Receipt: the receipt id. It equals the completionid.X-OffRouter-Receipt-URL: where to fetch the signed receipt,GET /v1/private/receipts/:id. It holds hashes and timestamps, never content, and needs no key.X-OffRouter-Attestation: the enclave's public attestation report. The key that signs the receipt is published in it.
We cannot forge a receipt: it is signed by a key that only exists inside the attested enclave.
What this does and does not cover
The enclave operator cannot read your prompts or outputs. On a plain call the OffRouter gateway does see the request in memory while forwarding it, and does not store it. To take the gateway out of that path too, encrypt to the enclave yourself: see End-to-end encryption.
End-to-end encryption
Encrypt your messages to the enclave and the gateway forwards ciphertext it has no key for. The answer comes back encrypted to a key you make up for that one request. It works with a prepaid key, with pay per call and in OffChat, which does it for every message.
- Fetch
GET /v1/private/attestation?nonce=<32 random bytes in hex>and verify it yourself: the quote up to Intel's root, that it covers your nonce and the key set, and the boot measurement. Take a key frome2ee_public_keysonly if all of that holds. A key from a report you did not verify could be anyone's, ours included. - Encrypt the
contentof every message to that key. Each ciphertext is bound to the model's name as the enclave knows it:e2ee.modelon each entry ofGET /v1/models. Themodelin your request stays the usual id. - Send the request as usual with five headers:
X-E2EE-Version: 2,X-Client-Pub-Key,X-Model-Pub-Key,X-E2EE-NonceandX-E2EE-Timestamp. - Check for
X-E2EE-Applied: trueon the response and decryptcontentandreasoningwith your key, chunk by chunk in a stream. An answer that does not decrypt was not made by the enclave for your request.
The format is the open-source enclave gateway's E2EE v2: X25519 or secp256k1, HKDF-SHA256 and AES-256-GCM, with a fresh key for every field. A ready-made client for browsers and Node is served at /assets/e2ee/e2ee.js.
What the gateway still sees
The model, max_tokens and other settings, tool definitions and tool-call arguments, how long each message is, the token counts the enclave reports, your IP address and who paid. It does not see what you asked or what was answered, and it holds no key that could open either.
Pricing
You are charged for the same tokens either way. With pay per call the up-front ceiling is larger, because ciphertext is about twice the size of its text; the difference is refunded with the rest.
Private payments
A prepaid key that no wallet can be linked to. You buy a note with an ordinary payment, then later fund a key with a zero-knowledge proof that one of the notes ever bought is yours, without saying which. The gateway learns that a deposit was made, never which one, so neither the key nor any call on it names a wallet.
- Make a note on your own machine: two random numbers,
nullifierandsecret. Keep them: they are the note. Its commitment isPoseidon(nullifier, secret). POST /v1/noteswith{amount_usd, commitment}is an x402 payment for one of the fixed amounts inGET /v1/notes($5, $20 or $100). The note joins a public tree of every deposit.- Later, make an API key locally, download the whole tree from
GET /v1/notes/leaves(never one leaf's path: asking for it would say which is yours) and prove that you know a note under the tree's root. POST /v1/notes/redeemwith{proof, root, nullifier_hash, amount_usd, key_hash}. No payment, no wallet, no signature. A new key with that hash is funded, or an existing key with no owner is topped up.
In the app it is two forms: buy a note at /dashboard#private (signed in) and redeem it at /dashboard#redeem, which needs no sign-in and proves in your browser. A ready-made client is served at /assets/note/note.js.
The rules
- A note funds only a key with no owner, and such a key is never refunded: there is no wallet to send to.
- Holder discounts do not apply: they are read from a wallet.
- Notes on Base, Arc and Robinhood Chain share one tree, so a deposit on one hides among all of them.
What stays public
Every deposit (payer, amount, time) and that some note of a given amount was redeemed at a given time. A note hides among the deposits of the same amount made before it is spent, so wait between buying and redeeming, and do not redeem from the address you paid from.
Pay with Gloam
Fund a prepaid key from a private Gloam balance, in USDG on Robinhood Chain. The chain shows USDG leaving Gloam's vault for our treasury, never your wallet, and the key carries no wallet either. Your payment is private, and so are your calls.
POST /v1/keyswith{amount_usd}and no payment header. Next to the usual x402 entries, the 402'sacceptslists agloam-cashoutentry:payTo, an exactamountin USDG base units, aquoteIdand anexpiresAt15 minutes out.- Cash out exactly that amount from your Gloam balance to
payTobefore it expires, ideally through Gloam's relay so your wallet never sends it. The Gloam SDK does this in one call:payGloamCashout, orGloamAgent.payX402Cashout. - Send the same request again with
X-PAYMENT: base64 of{"scheme":"gloam-cashout","txHash":"0x…","quoteId":"…"}. We read the receipt on chain and answer with a newoff_sk_key.
A key made this way, or by a private note, is topped up the same way at POST /v1/keys/topup. GET /v1/gloam says whether Gloam payments are on and gives the vault's current fee.
The rules
- The amount is the price grossed up for Gloam's cash-out fee (0.5% today, read live from the vault), plus a few base units that tie the cash out to your quote. Your key is credited the price.
- The key has no owner and is never refunded: there is no wallet we could send it to. A key with an owner cannot be topped up from Gloam.
- Not offered for pay-per-call, because the unused part of a call is refunded and a Gloam payer has no address to refund to.
- One cash out pays one quote, once. A cash out mined outside its quote's window is refused: ask for a new quote.
What stays public
That the treasury received a cash out from Gloam's vault, of what amount and when. Not who sent it, and not which Gloam deposit or payment funded it.
Private Gateway
Any OpenAI-compatible base URL, made private: your own model server, or a router you already use. Make a link once, then point your SDK at the link. Every call goes through an enclave that strips what identifies you, swaps secrets and personal data for placeholders, calls the upstream with your key sealed inside, puts the values back in the answer and signs a receipt of what left.
curl /v1/gateway/links \ -H 'content-type: application/json' \ -d '{"upstream":"https://openrouter.ai/api/v1","api_key":"sk-or-..."}' # {"id":"…","key":"gw_…","base_url":"/g/…/v1"} the key is shown once
Then use base_url and key as the base URL and API key of any OpenAI SDK. Chat completions (streaming too), embeddings and GET /models work as they do on the upstream. The page at /gateway does the same in a browser.
What leaves and what does not
- Dropped:
user,metadata,safety_identifier,prompt_cache_key, your IP and your headers. The upstream sees the enclave calling. - Replaced with placeholders such as
[EMAIL_1]: seed phrases, private keys, API keys and tokens, passwords in URLs, emails, card numbers, IBANs, EVM and Solana addresses, IP addresses and phone numbers. - Not detected: names and other free-form details, images and files. The upstream still reads everything that is not redacted: this keeps your secrets and your identity from it, not your prompt.
The receipt
Each answer carries X-OffRouter-Gateway-Receipt (the hash of what you sent, the hash of what the upstream got, the counts of what was redacted) and X-OffRouter-Gateway-Signature, signed by the key named in the enclave's report at GET /v1/gateway/attestation. POST /v1/gateway/links/{id}/preview shows the exact request the upstream would get.
Free during the beta, up to 60 calls a minute per link and 8 MB per request. An upstream must be a public https host.
Private web search
When an agent searches from its own machine, the search engine learns its IP, its account and every query it ever made. Here the search runs from inside the Private Gateway's enclave. The engine (Brave Search) sees one more query from that enclave, shared by everyone who searches through it, and never your IP, account, cookies or headers. POST /v1/web/fetch reads a result page the same way, so the site never sees you either.
curl /v1/web/search \ -H "Authorization: Bearer $OFFROUTER_KEY" -H 'content-type: application/json' \ -d '{"query":"confidential computing for AI agents","count":5}' curl /v1/web/fetch \ -H "Authorization: Bearer $OFFROUTER_KEY" -H 'content-type: application/json' \ -d '{"url":"https://offrouter.org/"}'
$0.008 a search and $0.002 a page, with a prepaid key or per call with x402. A request that is refused, or a page that cannot be read, is not charged.
Encrypted end to end
Send {"request":"<hex>"} instead: the whole JSON request, encrypted to the web key at GET /v1/web in the E2EE v2 format, with web-search or web-fetch in place of the model name. The answer comes back sealed to your one-time key. OffRouter then sees that you searched and paid, and not what for. Check the key first: the Intel TDX quote at GET /v1/web/attestation names the enclave's signer, and that signer signs the web key. The local MCP server does all of this for you in its web_search and web_fetch tools.
What leaves and what does not
- Taken out of the query before it leaves: seed phrases, private keys, API keys, emails, card numbers, IBANs, IP addresses and phone numbers. Addresses stay in, because looking one up is usually the point;
"redact"picks the kinds, orfalsefor none. The answer says what was taken out and what was sent. - Seen by the search engine: the rest of the query. A query that names you still names you.
- Seen by the site: a request from the enclave, with no cookies, no referrer and a plain user agent. Redirects are followed and checked hop by hop; private networks are refused.
Each answer carries receipt and signature: the hashes of what you sent and what left, signed by the enclave's signer. When the request was encrypted, the receipt is inside the encrypted answer too.
Private Swap
Swap tokens without publishing your order. What you buy, your minimum and where it is paid go to an enclave only; on chain the order is a hash until it is filled, so there is nothing to front-run. The enclave fills open orders of a pair together in one swap through a Uniswap v4 pool and pays each recipient in a later transaction. No key and no payment: the desk's fee (0.1%) comes out of the swap. The page at /swap does all of this from your wallet.
In beta on Robinhood Chain: ETH and $OFFROUTER, with a cap on each order. GET /v1/swap lists the pools, the tokens, each token's least and most per order, the fee and the contract.
POST /v1/swap/quotewith{token_in, token_out, amount_in, payer, recipient?, slippage_bps?}. Amounts are atomic units; ETH is0x0000000000000000000000000000000000000000. You get the quote, the order asintent, and what the payer does next, bymethod.- Fund the order from the payer wallet:
native(paying in ETH): sendtxunchanged. It carries the ETH to the contract with the order's hash.approval(a token such as $OFFROUTER): approveapproval.spenderfor the amount once, then signsignas EIP-712 typed data.eip3009(a dollar token such as USDG): signsign. No approval and no transaction.
POST /v1/swap/orderswith{intent, signature}, or for ETH{intent, open_tx}.GET /v1/swap/orders/{id}with the headerX-Order-Key: <intent.salt>untilstatusispaid. Keep the salt: it is the only way to read the order.
Rebuild what you sign or send from the order you asked for before you do it, as the page does: the message's nonce, or the transaction's data, is the hash of your order and nothing else.
The money's only ways out
An order in escrow leaves only into its swap or back to the wallet that paid. One the pool cannot fill at your minimum is sent back; once it expires (10 minutes), anyone can call refund on the contract and it returns to the payer. The executor's key lives in the enclave, and GET /v1/swap/attestation is the hardware report that names it.
What stays public
Your payment into escrow (payer, token, amount), each batch swap and each payout (recipient, token, amount). With few orders in a batch, amounts and timing can link a payment to a payout. Pay out to an address with no history.
MCP server
POST /mcp is a remote MCP server. There is nothing to install: add the URL with a prepaid key as the bearer.
claude mcp add --transport http offrouter /mcp \
--header "Authorization: Bearer $OFFROUTER_KEY"Tools: list_models (no key needed), ask, compare (the same prompt to several models) and balance. Tool calls are billed exactly like direct API calls. Pay per call is not available over MCP, because a remote server cannot sign for your wallet.
Private Swap adds swap_quote, swap_submit and swap_status, which need no key. The server never signs: your agent signs the quote's message, or sends its transaction, with its own wallet. To encrypt prompts on your own machine before they leave it, and to search the web privately with web_search and web_fetch, run the open-source local server instead: github.com/offrouter/mcp.
Errors
API errors use the OpenAI shape, {"error": {"message", "type", "code"}}. Payment problems use the x402 shape with a code.
| Status | Code | What to do |
|---|---|---|
| 400 | max_tokens_required | Set max_tokens on pay-per-call requests. |
| 400 | unsupported_media | The model does not read images (or video). Pick one whose input_modalities lists it. |
| 400 | remote_media_not_allowed | Send the image or clip inline, as a base64 data: URL. |
| 401 | invalid_api_key | Check the key. Closed keys stop working at once. |
| 402 | insufficient_balance | Top up the key or lower max_tokens. |
| 402 | terms_mismatch | Sign exactly the amount, asset and recipient from the 402. |
| 402 | payment_replayed | That payment was already used. Sign a new one. |
| 404 | model_not_found | Use an id from GET /v1/models. |
| 429 | model_overloaded | Retry in a few seconds. |
| 502 | upstream_error | Retry shortly. A paid call that fails is refunded. |