Messages auto (Anthropic-compatible)
POST /v1/auto/messagesAnthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url https://agent402.tools/v1/auto and pay $0.01 per call in USDC, no API key, no signup. Same models, caps and price as this tier's /chat/completions route; any model here is served through the Messages wire (Claude natively, others translated). Up to 16,000 input chars and 1024 output tokens; streaming supported. Omit "model" and the gateway routes the prompt to the top-ranked model for its task type; the response adds agent402_router {category, quality, served}.
Input
| Field | Type | Description |
|---|---|---|
model | string | Model id (OpenRouter naming, e.g. anthropic/claude-sonnet-5) - allowlisted per tier; omit (or "auto") on the auto tier |
max_tokens * | integer | Required by the Messages API; clamped to the tier's output cap |
messages * | array | Anthropic messages: {role: user|assistant, content: string | [text|image|tool_use|tool_result blocks]} |
system | string | Optional system prompt (string or text blocks) |
tools | array | Optional client tools {name, description, input_schema}; server/built-in tools are not served |
thinking | object | Optional {type:"enabled", budget_tokens} | {type:"adaptive"} | {type:"disabled"} - thinking tokens are output tokens |
stream | boolean | Anthropic SSE (message_start … message_stop) |
zdr | boolean | Optional - zero-data-retention providers only |
Example output
{
"id": "msg_…",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-sonnet-5",
"content": [
{
"type": "text",
"text": "x402 is an HTTP-native way for agents to pay per request with USDC."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 14,
"output_tokens": 18
}
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/v1/auto/messages \
-H "Content-Type: application/json" \
-d '{"max_tokens":256,"messages":[{"role":"user","content":"Summarize x402 in one sentence."}]}'
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/auto/messages", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "Summarize x402 in one sentence."
}
]
}),
});
Related tools
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, …
try in playground →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 →