{"uid":"cap_DDAzBDlTD0bh9-tOSOoxR","slug":"agent402-metered-chat-completions-c46c7abe","name":"Agent402 Metered Chat Completions","description":"OpenAI-compatible chat completions billed per request from what the call costs: the 402 quotes exact-BPE input plus your max_tokens at the model's list price, times 1.15, from $0.001 up to a $2 per-call cap. Any model from the flat tiers (GET /v1/models). Pay the quote over x402 exact, or authorize it as a ceiling over upto and settle actual usage. Set max_tokens to what you need: it is what you pay for.","url":"https://agent402.tools/v1/metered/chat/completions","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"zdr":{"type":"boolean","description":"Optional - true routes only to zero-data-retention providers (OpenRouter provider.zdr); the only provider preference a caller may set."},"model":{"type":"string","description":"Model id - OpenRouter form (openai/gpt-4o-mini) or bare OpenAI form (gpt-4o-mini). GET /v1/models lists the allowlist per tier. Optional: omit it and the tier serves its documented default (x402.defaultModel on /v1/models), named back in agent402_default_model; the price does not change"},"tools":{"type":"array","description":"Optional - OpenAI function tools {type:\"function\", function:{...}}, or a tool namespace {type:\"namespace\", name, tools:[...]} (flattened into its functions). The pro and premium routes also accept the bounded server tools openrouter:web_search, openrouter:web_fetch and openrouter:datetime with server-owned limits (GET /v1/models lists them); stop_server_tools_when and max_tool_calls are refused. A request with a server tool is never served from the prompt cache."},"messages":{"type":"array","description":"OpenAI chat messages: [{role, content}] - text and image_url content blocks supported"},"reasoning":{"type":"object","description":"Optional - {effort: \"none\"|\"minimal\"|\"low\"|\"medium\"|\"high\"|\"xhigh\"|\"max\", max_tokens?, exclude?, enabled?}. Reasoning tokens count against max_tokens. Omitted: low effort on the budget tiers, the model default on premium. reasoning_effort (string) is accepted as an alias."},"max_tokens":{"type":"number","description":"Output token cap (clamped to the tier maximum)"},"cache_control":{"description":"Optional - prompt caching preference. Default ON ({type:\"ephemeral\"}, 5-minute TTL): repeated prefixes across your turns are served from the provider cache (same price to you). Send false to disable. ttl:\"1h\" is not offered."},"max_completion_tokens":{"type":"integer","description":"Optional - alias of max_tokens (newer OpenAI SDKs send this)."}}},"responseSchema":{"type":"json","example":{"id":"gen-…","model":"openai/gpt-4o-mini","usage":{"total_tokens":13,"prompt_tokens":12,"completion_tokens":1},"object":"chat.completion","choices":[{"index":0,"message":{"role":"assistant","content":"OK"},"finish_reason":"stop"}],"created":1750000000}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_lUOXXHn4FTNOiCsPmlAyf","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"OpenAI-compatible chat completions endpoint that bills per request based on exact BPE token usage plus max_tokens at model list price, paid via x402 protocol","exampleAgentPrompt":"Using gpt-4o-mini, summarize this article for me in about 200 words — pay per call with x402 and make sure zero-data-retention is on: [article text here]","exampleUseCases":[{"title":"Agentic tool-calling pipeline","prompt":"Run a chat completion with openai/gpt-4o using function tools for my weather and calendar functions, set max_tokens to 512, and pay for just this one call via x402 — I don't want a subscription."},{"title":"Reasoning model for hard math","prompt":"Use o3-mini with high reasoning effort and max_tokens 1024 to solve this calculus problem step by step, billed per call: [problem text]."},{"title":"Zero-data-retention compliance task","prompt":"Send this legal document summary through gpt-4o with zero-data-retention enabled and max_tokens 300 — I need to make sure the provider never stores the text, and I'll pay per request."}],"resultDescription":"An OpenAI-compatible chat completion response object including generated message content, tool call payloads if requested, token usage counts (prompt, completion, reasoning), finish reason, and model metadata. The x402 payment flow provides an exact cost quote before the call executes.","failureModes":["Model not on allowlist for tier — returns 400 with model error","x402 payment quote rejected or underpaid — returns 402 with required payment details","max_tokens exceeds tier ceiling — clamped silently or rejected","ZDR requested but no ZDR provider available for chosen model — upstream error, failover attempted","Server tool limits exceeded (pro/premium only) — returns 400","Prompt cache miss on server-tool requests — served fresh, no cache","Upstream provider timeout or error — propagated as 5xx"],"whenToPreferThis":"Choose this endpoint when you need OpenAI-compatible chat completions without a subscription, want per-call micropayment billing via x402, require zero-data-retention routing, need access to multiple model providers (OpenAI, Anthropic, etc.) through a single interface, or are building an agentic pipeline that must account for exact token costs before executing each LLM call.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-16T00:50:34.976Z","isFirstParty":false}