HTTP/1.1 402 PAYMENT REQUIRED agent402.base.eth · BASE · SOLANA · POLYGON · ARBITRUM · ROBINHOOD · USDC · USDG
Agent402 / tools / v1-chat-premium

Chat completions — premium tier

$0.50 per call · USDC via x402 · POST /v1/premium/chat/completions

OpenAI-compatible chat completions, premium tier: gpt-5, o3/o4, claude opus — paid per call in USDC over x402. Same wire format as /v1/chat/completions with the largest caps (64k chars in, 8192 tokens out).

Input

FieldTypeDescription
model *stringModel id — OpenRouter form (openai/gpt-4o-mini) or bare OpenAI form (gpt-4o-mini). GET /v1/models lists the allowlist per tier.
messages *arrayOpenAI chat messages: [{role, content}] — text and image_url content blocks supported
max_tokensnumberOutput token cap (clamped to the tier maximum)

Example output

{
  "id": "gen-…",
  "object": "chat.completion",
  "created": 1750000000,
  "model": "anthropic/claude-opus-4",
  "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/premium/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"anthropic/claude-opus-4","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/premium/chat/completions", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "anthropic/claude-opus-4",
    "messages": [
      {
        "role": "user",
        "content": "Reply with exactly: OK"
      }
    ],
    "max_tokens": 5
  }),
});
Wallet-only. This tool reaches the network/browser/storage, so it is paid in USDC via x402 (no proof-of-work tier).

Related tools

Chat completions (OpenAI-compatible)

$0.02 · POST /v1/chat/completions

OpenAI-compatible chat completions over x402 — point any OpenAI SDK at base_url https://agent402.tools/v1 and pay per ca…

Chat completions — pro tier

$0.10 · POST /v1/pro/chat/completions

OpenAI-compatible chat completions, pro tier: gpt-4o, gpt-4.1, claude sonnet, gemini pro, grok — paid per call in USDC o…