Messages pro (Anthropic-compatible)
POST /v1/pro/messagesAnthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url https://agent402.tools/v1/pro and pay $0.10 per call in USDC, no API key, no signup. Send POST /v1/pro/messages with the required fields max_tokens and messages and pay quoted per request from $0.10 over x402 or MPP (there is no free tier). It returns a JSON object with id, type, role, model, content and 2 more.
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). Depth: `effort` (low..max) on Claude 4.7+, thinking.budget_tokens on older Claude. Up to 48,000 input chars and 4096 output tokens; streaming supported. Omit "model" and the tier serves openai/gpt-4o (named back in agent402_default_model); the price does not change.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
model | string | no | Model id (OpenRouter naming, e.g. anthropic/claude-sonnet-5) - allowlisted per tier; omit (or "auto") on the auto tier |
max_tokens | integer | yes | Required by the Messages API; clamped to the tier's output cap |
messages | array | yes | Anthropic messages: {role: user|assistant, content: string | [text|image|tool_use|tool_result blocks]} |
system | string | no | Optional system prompt (string or text blocks) |
tools | array | no | Optional client tools {name, description, input_schema}; server/built-in tools are not served |
thinking | object | no | Optional {type:"enabled", budget_tokens} | {type:"adaptive"} | {type:"disabled"} - thinking tokens are output tokens. On Claude 4.7+ (Opus 5, Sonnet 5, Fable 5.1) thinking is adaptive and `effort` is the depth control; a budget_tokens value is advisory there |
effort | string | no | Optional depth control for Claude 4.7+ (Opus 5, Sonnet 5, Fable 5.1): low | medium | high | xhigh | max, validated against the model's own list (GET /v1/models). Not accepted on Haiku 4.5 and older, which take thinking.budget_tokens instead |
stream | boolean | no | Anthropic SSE (message_start … message_stop) |
zdr | boolean | no | Optional - zero-data-retention providers only |
Example request
curl -i -X POST https://agent402.tools/v1/pro/messages \
-H "Content-Type: application/json" \
-d '{"model":"anthropic/claude-sonnet-5","max_tokens":256,"messages":[{"role":"user","content":"Summarize x402 in one sentence."}]}'
Without payment this returns HTTP 402 Payment Required with the exact price for v1-chat-pro-messages; any x402 v2 or MPP client pays it and retries.
Example response
{
"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
}
}
| Field | Type | Always present | In the example |
|---|---|---|---|
id | string | yes | msg_… |
type | string | yes | message |
role | string | yes | assistant |
model | string | yes | anthropic/claude-sonnet-5 |
content | array of objects | yes | 1 item in the example |
stop_reason | string | yes | end_turn |
usage | object | yes | 2 fields: input_tokens, output_tokens |
From an MCP client
catalog.call {
"slug": "v1-chat-pro-messages",
"params": {
"model": "anthropic/claude-sonnet-5",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "Summarize x402 in one sentence."
}
]
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for v1-chat-pro-messages; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
max_tokensandmessagesare required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool runs a model, so it has no proof-of-work tier. A prepaid card-credits key (
Authorization: Bearer a402_...) also pays it. - Model-backed: the answer is generated by a model, so the same input can produce different wording.
- Priced per request: the 402 quotes this body, between $0.10 and $0.5.
- Flat per call for the models this tier serves. A body naming another flat tier's model (nano, base, pro, premium) is quoted at that tier's price in the 402 and served under that tier; model "auto" is quoted and served as the auto tier. The answer names the tier in agent402_tier. The live 402 is always the price.
- A
GETorHEADto /v1/pro/messages returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB and a streamed response are not replayed).
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();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/v1/pro/messages", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"model": "anthropic/claude-sonnet-5",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "Summarize x402 in one sentence."
}
]
}),
});
Related tools
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…
Messages base (Anthropic-compatible)
POST /v1/messagesAnthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url https://agent402…
Messages metered (Anthropic-compatible)
POST /v1/metered/messagesAnthropic Messages API billed per request from what the call costs: the 402 quotes exact-BPE input (system + messages + …
Messages nano (Anthropic-compatible)
POST /v1/nano/messagesAnthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url https://agent402…
Messages premium (Anthropic-compatible)
POST /v1/premium/messagesAnthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url https://agent402…
Text-to-speech (OpenAI-compatible)
POST /v1/audio/speechOpenAI-compatible text-to-speech over x402 - point any OpenAI SDK's audio.speech.create() at base_url https://agent402.t…