HTTP/1.1 402 PAYMENT REQUIRED agent402.base.eth · BASE · SOLANA · POLYGON · ARBITRUM · MONAD · CELO · AVALANCHE · SEI · OPTIMISM · STELLAR · ALGORAND · ROBINHOOD · USDC · USDG
Agent402 / tools / llm-pro

LLM inference (Pro)

$0.100 per call · USDC via x402 · POST /api/llm-pro

LLM inference proxy (Pro tier) - GPT-4o or GPT-4.1. Supports vision (up to 2 image URLs) and structured output (response_format: json_object or json_schema). No API key needed; pay per call via x402. Input capped at 16k chars, output at 2048 tokens.

Input

FieldTypeDescription
model *stringModel ID - gpt-4o or gpt-4.1
messages *arrayArray of {role, content} objects. content can be a string or array of {type:'text',text} and {type:'image_url',image_url:{url,detail}} blocks
max_tokensnumberMax output tokens (default 1024, cap 2048)
response_formatobjectOptional: {type:"json_object"} or {type:"json_schema",json_schema:{name,schema}}
temperaturenumberSampling temperature (0-2)
top_pnumberNucleus sampling (0-1)
stopstringStop sequence(s)

Example output

{
  "model": "gpt-4o",
  "provider": "openai",
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 8,
    "total_tokens": 20
  },
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ]
}

Try it - see the 402 challenge (free)

curl -i -X POST https://agent402.tools/api/llm-pro \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Say hello in one sentence."}],"max_tokens":64}'

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/api/llm-pro", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "Say hello in one sentence."
      }
    ],
    "max_tokens": 64
  }),
});
Wallet-only. This tool reaches the network/browser/storage, so it is paid in USDC via x402 (no proof-of-work tier).

Related tools

LLM inference

$0.010 · POST /api/llm

LLM inference proxy - send an OpenAI-format chat/completions request and get a response from GPT-4o-mini. Supports visio…

LLM inference (Premium)

$0.500 · POST /api/llm-premium

LLM inference proxy (Premium tier) - o3 or o3-mini reasoning models. Supports vision (up to 2 image URLs) and structured…

Image generation

$0.030 · POST /api/image-gen

Generate an image from a text prompt using GPT Image 2 (low quality, 1024x1024). No API key needed; pay per call via x40…