Skip to content

Messages auto (Anthropic-compatible)

$0.01 per callUSDC via x402POST /v1/auto/messages

Anthropic 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. Send POST /v1/auto/messages with the required fields max_tokens and messages and pay $0.01 per call 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+ and Haiku 5.5, thinking.budget_tokens on older Claude. 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}.

Category: LLM gatewayTags: llm ai inference anthropic-compatible messages-api claude gateway

Try in playground →

Parameters

NameTypeRequiredDescription
modelstringnoModel id (OpenRouter naming, e.g. anthropic/claude-sonnet-5) - allowlisted per tier; omit (or "auto") on the auto tier
max_tokensintegeryesRequired by the Messages API; clamped to the tier's output cap
messagesarrayyesAnthropic messages: {role: user|assistant, content: string | [text|image|tool_use|tool_result blocks]}
systemstringnoOptional system prompt (string or text blocks)
toolsarraynoOptional client tools {name, description, input_schema}; server/built-in tools are not served
thinkingobjectnoOptional {type:"enabled", budget_tokens} | {type:"adaptive"} | {type:"disabled"} - thinking tokens are output tokens; a budget is clamped along with max_tokens to fit the tier output cap. 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. Claude Haiku 5.5 refuses {type:"enabled", budget_tokens} with a 400 (send effort instead). A budget above three quarters of max_tokens is lowered to leave a quarter for the answer (not under 1024), and an answer that still comes back empty is retried once with thinking off where the model runs without it, when the call's price and time allow; either change is named in agent402_reasoning_adjusted
effortstringnoOptional depth control for Claude 4.7+ (Opus 5, Sonnet 5, Fable 5.1) and Claude Haiku 5.5: 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. An effort above low that leaves no room for an answer inside a small max_tokens is sent as low, and an answer that still comes back empty is retried once at the model's lowest effort when the call's price and time allow; either change is named in agent402_reasoning_adjusted {field, requested, used, reason} (the X-Agent402-Reasoning-Adjusted header on a stream)
streambooleannoAnthropic SSE (message_start … message_stop)
zdrbooleannoOptional - zero-data-retention providers only

Example request

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."}]}'

Without payment this returns HTTP 402 Payment Required with the exact price for v1-chat-auto-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
  }
}
FieldTypeAlways presentIn the example
idstringyesmsg_…
typestringyesmessage
rolestringyesassistant
modelstringyesanthropic/claude-sonnet-5
contentarray of objectsyes1 item in the example
stop_reasonstringyesend_turn
usageobjectyes2 fields: input_tokens, output_tokens

From an MCP client

catalog.call {
  "slug": "v1-chat-auto-messages",
  "params": {
    "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-auto-messages; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y agent402-mcp@0.13.32.

Errors and behavior

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?.({ maxAmountPerPayment: "$0.01" }); // refuse any quote above this tool's price
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

Messages base (Anthropic-compatible)

from $0.02POST /v1/messages

Anthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url.

Messages metered (Anthropic-compatible)

from $0.001POST /v1/metered/messages

Anthropic Messages API priced per request from the request itself.

Messages nano (Anthropic-compatible)

from $0.003POST /v1/nano/messages

Anthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url.

Messages premium (Anthropic-compatible)

$0.50POST /v1/premium/messages

Anthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url.

Messages pro (Anthropic-compatible)

from $0.10POST /v1/pro/messages

Anthropic Messages API over x402 - point the Anthropic SDK (or Claude Code / the Agent SDK) at base_url.

Text-to-speech (OpenAI-compatible)

$0.06POST /v1/audio/speech

OpenAI-compatible text-to-speech over x402 - point any OpenAI SDK's audio.speech.create() at base_url.