{"uid":"cap_ObSx7etHdQufdb0Vt5gJP","slug":"openrouter-withzero-xyz-openrouter-metered-chat-completion-openai-7c1ab996","name":"OpenRouter Metered Chat Completion (OpenAI-compatible)","description":"OpenAI-compatible chat completion via any OpenRouter model with metered at-cost billing: escrow a worst-case reservation (up to 5 USDC), pay only actual token usage — the difference is refunded after the call. Use this route for long generations, big contexts, and reasoning models; the fixed route caps out much lower. 📖 Full guide: https://openrouter.withzero.xyz/llms.txt","url":"https://openrouter.withzero.xyz/api/v1/chat/completions/metered?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","example":{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Say hello in one sentence."}],"max_tokens":64},"required":["model","messages","max_tokens","stream"],"properties":{"seed":{"type":"integer","maximum":9007199254740991,"minimum":-9007199254740991,"description":"Random seed for deterministic outputs (support varies by model)."},"stop":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}],"description":"Stop sequence(s): generation halts when any is produced."},"model":{"type":"string","minLength":1,"description":"OpenRouter model ID, e.g. \"openai/gpt-4o-mini\", \"anthropic/claude-haiku-4-5\", \"google/gemini-flash-1.5\". Use GET /api/v1/models to list all available models with pricing."},"route":{"type":"string","description":"OpenRouter routing strategy, e.g. \"fallback\". Requires an explicit `models` list so every candidate model can be priced."},"tools":{"type":"array","items":{},"description":"OpenAI-format tool definitions for function calling."},"top_k":{"type":"integer","maximum":9007199254740991,"minimum":0,"description":"Top-k sampling: limit to the k most likely next tokens."},"top_p":{"type":"number","maximum":1,"minimum":0,"description":"Nucleus sampling probability mass 0–1. Alternative to temperature."},"models":{"type":"array","items":{"type":"string"},"description":"Fallback model list for OpenRouter auto-routing. Tried in order if the primary model is unavailable. The price reservation is taken at the most expensive rates across model + models, since any of them may serve the call; the difference is refunded on the metered route."},"stream":{"type":"boolean","const":false,"default":false,"description":"Must be false — streaming is not supported in v1."},"messages":{"type":"array","items":{"type":"object","required":["role","content"],"properties":{"name":{"type":"string","description":"Optional display name for the message author"},"role":{"enum":["system","user","assistant","tool"],"type":"string","description":"Message role: system (instructions), user (human turn), assistant (model turn), or tool (tool result)"},"content":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Message text content, or null for tool-call-only assistant turns"},"tool_calls":{"type":"array","items":{},"description":"For role=assistant: tool calls the model is making"},"tool_call_id":{"type":"string","description":"For role=tool: the tool_call_id this result responds to"}},"additionalProperties":false},"minItems":1,"description":"Conversation history as an array of {role, content} objects. At minimum one user message is required."},"reasoning":{"type":"object","properties":{"effort":{"enum":["none","minimal","low","medium","high","xhigh"],"type":"string","description":"Reasoning effort level. Mutually exclusive with max_tokens."},"enabled":{"type":"boolean","description":"Enable reasoning at the default (medium) effort."},"exclude":{"type":"boolean","description":"Generate reasoning but omit it from the response."},"max_tokens":{"type":"integer","maximum":9007199254740991,"description":"Explicit reasoning token budget.","exclusiveMinimum":0}},"description":"OpenRouter reasoning config for thinking models. Reasoning tokens bill as output tokens and are added to the price reservation.","additionalProperties":false},"logit_bias":{"type":"object","description":"Token ID → bias (-100 to 100) to adjust generation likelihood.","propertyNames":{"type":"string"},"additionalProperties":{"type":"number"}},"max_tokens":{"type":"integer","default":4096,"maximum":9007199254740991,"description":"Maximum output tokens. Controls your spend ceiling — the price reservation is input estimate x input_rate + (max_tokens + reasoning budget) x output_rate. The fixed route rejects requests reserving above its cap; use the metered route for large values.","exclusiveMinimum":0},"transforms":{"type":"array","items":{"type":"string"},"description":"OpenRouter prompt transforms, e.g. [\"middle-out\"] for context compression."},"temperature":{"type":"number","maximum":2,"minimum":0,"description":"Sampling temperature 0–2. Higher = more random. Defaults to model default (usually ~1.0)."},"tool_choice":{"description":"Tool selection strategy: \"auto\", \"none\", \"required\", or a specific tool name."},"response_format":{"type":"object","required":["type"],"properties":{"type":{"type":"string"}},"description":"Output format, e.g. {\"type\":\"json_object\"} to force JSON output.","additionalProperties":false},"presence_penalty":{"type":"number","description":"Penalise tokens that have appeared at all in the context (-2 to 2)."},"frequency_penalty":{"type":"number","description":"Penalise tokens proportional to how often they already appear (-2 to 2)."},"repetition_penalty":{"type":"number","description":"Repetition penalty multiplier (1.0 = no penalty). Some models only."}},"additionalProperties":false},"responseSchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["id","object","created","model","choices","billing"],"properties":{"id":{"type":"string"},"model":{"type":"string"},"usage":{"type":"object","required":["prompt_tokens","completion_tokens","total_tokens"],"properties":{"cost":{"type":"number"},"total_tokens":{"type":"number"},"prompt_tokens":{"type":"number"},"completion_tokens":{"type":"number"}},"additionalProperties":false},"object":{"type":"string"},"billing":{"type":"object","required":["promptTokens","completionTokens","reservedUsdcMicro","settledUsdcMicro","actualUsdcMicro","costBasis"],"properties":{"costBasis":{"enum":["openrouter","rates","estimated"],"type":"string","description":"Where actualUsdcMicro came from: OpenRouter usage accounting > cached per-token rates > character estimate"},"promptTokens":{"type":"number","description":"Actual input tokens consumed"},"actualUsdcMicro":{"type":"string","description":"Best-known actual cost of the call in micro-USDC. On the fixed route this is informational — the charge is settledUsdcMicro."},"completionTokens":{"type":"number","description":"Actual output tokens generated"},"settledUsdcMicro":{"type":"string","description":"Micro-USDC actually charged to the buyer. Fixed route: the up-front worst-case estimate (= reservedUsdcMicro). Metered route: actual usage (= actualUsdcMicro)."},"reservedUsdcMicro":{"type":"string","description":"Worst-case micro-USDC committed before the call"}},"additionalProperties":false},"choices":{"type":"array","items":{"type":"object","required":["index","message","finish_reason"],"properties":{"index":{"type":"number"},"message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string"},"content":{"anyOf":[{"type":"string"},{"type":"null"}]},"tool_calls":{"type":"array","items":{}}},"additionalProperties":false},"logprobs":{},"finish_reason":{"anyOf":[{"type":"string"},{"type":"null"}]}},"additionalProperties":false}},"created":{"type":"number"},"system_fingerprint":{"type":"string"}},"additionalProperties":false},"example":null,"exampleRequest":null,"tags":[],"displayCostAmount":"0.003246","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","requiresHandshake":false,"reviewCount":2,"rating":{"score":"0.67","successRate":"0.99","reviews":2,"stars":"3.7","state":"rated"},"availabilityStatus":"healthy","priceObserved":null,"sessionDeposit":{"amountUsd":"0.00","asset":"USDC"},"pricing":{"kind":"session","summary":"$0.001/call","primary":{"kind":"session","protocol":"mpp","network":"tempo","amountUsd":"0.001","per":"call","confidence":"exact","depositUsd":"0.00"},"accepted":[{"kind":"session","protocol":"mpp","network":"tempo","amountUsd":"0.001","per":"call","confidence":"exact","depositUsd":"0.00"},{"kind":"static","protocol":"mpp","network":"tempo","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_g3i6fuU8iCOkiRFMM57bk","protocol":"mpp","methodType":"crypto","chain":"tempo","mode":"session","costAmount":"0.001","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":5,"planRef":null},{"uid":"pm_VVu3anExlRfPDN5rrVnFj","protocol":"mpp","methodType":"crypto","chain":"tempo","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":"openrouter.withzero.xyz","brandSlug":"openrouter-withzero-xyz-mpp","brandBaseUrl":"https://openrouter.withzero.xyz","brandDocsUrl":null,"whatItDoes":"Sends a chat completion request to any OpenRouter model with metered at-cost billing — escrows up to 5 USDC and refunds the unused portion after the call settles actual token usage.","exampleAgentPrompt":"Use the metered OpenRouter route to send this 10,000-token conversation to anthropic/claude-opus-4-5 with a max of 4096 output tokens and streaming off — I only want to pay for the tokens actually used, not a fixed worst-case amount.","exampleUseCases":null,"resultDescription":"Returns an OpenAI-compatible chat completion response including the generated message content, finish reason, token usage counts (prompt + completion), and a billing object detailing the reserved micro-USDC, settled micro-USDC (actual usage), actual cost, and the cost basis source (OpenRouter accounting, cached rates, or estimate). The difference between the escrowed reservation and actual cost is automatically refunded.","failureModes":["402 Payment Required if insufficient USDC balance to cover the worst-case reservation","400 Bad Request if model ID is invalid or messages array is malformed","400 if stream is set to true (streaming not supported on this route)","503 or 500 if the upstream OpenRouter model is unavailable","timeout for very long reasoning model generations","model not found if the specified OpenRouter model ID does not exist","reservation ceiling exceeded if estimated cost exceeds the 5 USDC maximum escrow limit"],"whenToPreferThis":"Prefer this metered endpoint over the fixed-price route when calling reasoning models, sending large contexts, or expecting long completions where the fixed route's lower cap would be insufficient. It is also ideal when cost predictability via pay-for-actual-usage matters more than the simplicity of a one-shot fixed charge. Use the fixed route for short, predictable completions where the overhead of escrow-and-settle is unnecessary.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":330,"lastUsedAt":"2026-09-30T07:33:30.254Z","lastSuccessfullyRanAt":"2026-09-30T07:33:26.705Z","lastHealthCheckAt":"2026-10-11T04:12:44.230Z","isFirstParty":true,"canonicalSlug":"openrouter-withzero-xyz-openrouter-metered-chat-completion-openai-7c1ab996"}