Skip to content
GitHubGo to app

Agents · x402 · pay per request

Your agent buys inference per request.

One key to use multiple models. Or no key: pay per query.

Two ways to pay

Same prices

Two ways to pay. With an API key, each request is charged to your prepaid balance. There is no quote and no payment step; an empty balance or a key at its limit answers 402 with the reason. Without a key, the API answers 402 with a quote, and your agent pays for that one request with x402. Each payment is at least $0.01; either way, each request is charged its exact price, and the x-inferit-model header names the model.

Either way, each request is charged its exact price, for the model the agent names.

01 — Where to go

One API, one discovery document, one guide.

Point the agent at the API base. The whole guide is one markdown file: /agents.md.

WhatWhere
API baseOpenAI-compatible, for any OpenAI client
https://api-production-c74b9.up.railway.app/v1
Chat completionsName a model, or send model auto. Without a key it answers 402
POSThttps://api-production-c74b9.up.railway.app/v1/chat/completions
RoutingThe quality ranking and the auto policies
GEThttps://api-production-c74b9.up.railway.app/v1/routing
x402 discoveryWhat a client signs for: network, asset, payTo
GEThttps://api-production-c74b9.up.railway.app/.well-known/x402
API credits faucet1,000 free API credits per address per day
POSThttps://api-production-c74b9.up.railway.app/v1/faucet
Models and pricesList prices, and the price of the cheapest healthy offer of every model
GEThttps://api-production-c74b9.up.railway.app/v1/models
The guide for agentsThis page as one markdown file; also at https://inferit.app/agents.md
https://inferit.cc/agents.md
Every page as markdownIndex, and the full text in one file
https://inferit.cc/llms.txt
The appWallet sign-in, balance, ceiling and API keys
https://inferit.app/buy
Sell inferenceList any open-weight model you run, at your price
POSThttps://api-production-c74b9.up.railway.app/v1/seller/models
Source on GitHubThe seller app, examples and the x402 facilitator; the market's code is private
https://github.com/InferitAI

02 — How paying works

Pay $0.01 or more. Spend it per request.

Each payment goes to your agent's balance; each request is charged its exact price.

One keyless request

Minimum payment, $0.01

One keyless request: the agent posts to /v1/chat/completions with model auto and no key; Inferit answers 402 Payment Required with a quote of at least $0.01; the agent resends the same body with a PAYMENT-SIGNATURE header; Inferit answers 200 OK, names the model in x-inferit-model, and the rest of the payment stays in the agent's balance.

03 — API credits

Free API credits, one call away.

POST /v1/faucet adds free API credits (ITC) to an address once a day.

Claim free API credits · bash
curl -s -X POST https://api-production-c74b9.up.railway.app/v1/faucet \
  -H 'content-type: application/json' \
  -d '{"address":"0xYourAddress"}'

04 — A paying agent

Copy, paste, run.

Three agents: TypeScript and Python pay with x402; curl shows the 402.

Show the full agentTypeScript · Python · curl
agent.mts
// npm i @x402/fetch @x402/evm viem    then: npx tsx agent.mts    (Node 18+, @x402 2.28 or newer)
import { decodePaymentResponseHeader, wrapFetchWithPayment, x402Client } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm/exact/client';
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';

const API = 'https://api-production-c74b9.up.railway.app';
// A brand-new key works: the agent never sends a transaction itself.
const account = privateKeyToAccount((process.env.AGENT_KEY as `0x${string}` | undefined) ?? generatePrivateKey());

// 1. Inferit's faucet gives this address 1,000 free ITC (the claim costs nothing).
const faucet = await fetch(`${API}/v1/faucet`, {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ address: account.address }),
});
console.log('faucet', faucet.status, await faucet.text());

// 2. The standard x402 v2 client. It only pays in tokens it was told about, so allow ITC in its spend
//    controls, and cap one payment at 1 ITC (1000000 base units, 6 decimals), whatever the server quotes.
// Pin these two values in real code instead of asking the server that is being paid.
const doc = await (await fetch(`${API}/.well-known/x402`)).json();
const { network, asset } = doc.accepts?.[0] ?? doc;
const ITC = { network, asset };
const client = new x402Client()
  .register('eip155:*', new ExactEvmScheme(account))
  .setSpendControls({ allowedAssets: [{ ...ITC, maxAmountPerPayment: '1000000' }] });
const fetchWithPayment = wrapFetchWithPayment(fetch, client);

// 3. Call the API with no key: 402 -> sign -> paid retry, all inside fetchWithPayment.
const res = await fetchWithPayment(`${API}/v1/chat/completions`, {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    model: 'qwen/qwen-2.5-14b-instruct',
    messages: [{ role: 'user', content: 'Say hello in five words.' }],
    max_tokens: 64, // the quote is the worst case for this body, so a small max_tokens keeps it small
  }),
});
const body = await res.json();
console.log(res.status, body.choices?.[0]?.message?.content ?? body);

// Which model answered (with model auto, Inferit picked it), and the payment receipt: the deposit transaction and who paid.
console.log('model', res.headers.get('x-inferit-model'));
const receipt = res.headers.get('PAYMENT-RESPONSE');
if (receipt) console.log(decodePaymentResponseHeader(receipt));
console.log('cost', res.headers.get('x-inferit-buyer-cost-micro'), 'millionths of a dollar; the rest stays in your balance');

Allow ITC in the client's spend controls, capped at $1 per payment.

05 — Discovery

Read what to sign, then pin it.

GET /.well-known/x402 lists what a client signs for. Pin the network and the asset.

Discovery · read live

Live payment requirements

x402 v2

What a client is asked to sign, read from GET /.well-known/x402. The amount is quoted per request in the 402 response.

API: api-production-c74b9.up.railway.app. Checked against the payment contract and token from /v1/rails.

06 — Or use an API key

Steady traffic? Spend the balance with a key.

Signing in with your wallet mints a key; its requests spend the balance with no payment step.

continue agent.mts
// Same wallet as the x402 payer: sign in (EIP-4361, an off-chain text signature; it moves no tokens) and mint an API key.
const post = (path: string, body: unknown, token?: string) =>
  fetch(`https://api-production-c74b9.up.railway.app${path}`, {
    method: 'POST',
    headers: { 'content-type': 'application/json', ...(token ? { authorization: `Bearer ${token}` } : {}) },
    body: JSON.stringify(body),
  }).then((r) => r.json());

const { message } = await post('/v1/auth/evm/challenge', { address: account.address });
const { token } = await post('/v1/auth/evm/verify', { message, signature: await account.signMessage({ message }) });
const { key } = await post('/v1/keys', { name: 'agent' }, token);   // shown once; ik_…
// From here on: Authorization: Bearer <key>, spending what is left of your balance. No payment step.

07 — Who runs what

Inferit runs the API and the facilitator.

The seller that serves a request sees it; Inferit stores token counts and prices, never prompts.

Hand your agent one file.

agents.md has the endpoints, model auto, both ways to pay, the code, the limits and the errors.