Chat completions - nano tier
POST /v1/nano/chat/completionsOpenAI-compatible chat completions, nano tier: gpt-4.1-nano, gpt-5-nano, gemini flash-lite, small llama/ministral/qwen, deepseek-chat - $0.003 per call in USDC over x402, priced for high-frequency agent loops. Same wire format as /v1/chat/completions with loop-sized caps (12k chars in, 768 tokens out). Streaming supported (stream: true). No API key, no signup.
Input
| Field | Type | Description |
|---|---|---|
model * | string | Model id - OpenRouter form (openai/gpt-4o-mini) or bare OpenAI form (gpt-4o-mini). GET /v1/models lists the allowlist per tier. |
messages * | array | OpenAI chat messages: [{role, content}] - text and image_url content blocks supported |
max_tokens | number | Output token cap (clamped to the tier maximum) |
zdr | boolean | Optional - true routes only to zero-data-retention providers (also accepted as provider.zdr). Same price; a model with no ZDR provider errors upstream and walks the failover chain. |
cache_control | any | Optional - prompt caching preference. Default ON ({type:"ephemeral"}, 5-minute TTL): repeated prefixes across your turns are served from the provider cache (same price to you). Send false to disable. ttl:"1h" is not offered. |
reasoning | object | Optional - reasoning control for reasoning models: {effort: "none"|"minimal"|"low"|"medium"|"high"|"xhigh"|"max", max_tokens?: int, exclude?: bool, enabled?: bool}. Reasoning tokens count against max_tokens. When omitted, reasoning-by-default models get a low effort on the budget tiers (so the cap is not spent thinking) and the model default on premium. OpenAI's reasoning_effort string is accepted too. |
max_completion_tokens | integer | Optional - alias of max_tokens (newer OpenAI SDKs send this). |
Example output
{
"id": "gen-…",
"object": "chat.completion",
"created": 1750000000,
"model": "openai/gpt-4.1-nano",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "OK"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 1,
"total_tokens": 13
}
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/v1/nano/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"openai/gpt-4.1-nano","messages":[{"role":"user","content":"Reply with exactly: OK"}],"max_tokens":5}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/v1/nano/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"model": "openai/gpt-4.1-nano",
"messages": [
{
"role": "user",
"content": "Reply with exactly: OK"
}
],
"max_tokens": 5
}),
});
Related tools
Chat completions - auto tier (eval-ranked routing)
POST /v1/auto/chat/completionsOpenAI-compatible chat completions with server-side model choice: omit "model" (or send "auto") and the gateway routes t…
try in playground →Grounded chat (web search, OpenAI-compatible)
POST /v1/grounded/chat/completionsOpenAI-compatible chat completions GROUNDED in a live web search on every call: the gateway runs an Exa search (up to 5 …
try in playground →Chat completions (OpenAI-compatible)
POST /v1/chat/completionsOpenAI-compatible chat completions over x402 - point any OpenAI SDK at base_url https://agent402.tools/v1 and pay per ca…
try in playground →