{"uid":"cap_IuupBVL4KTBOPxLzEF-G0","slug":"chat-completion-billed-per-token-metered-402-6eec3bb6","name":"Chat Completion Billed Per Token (Metered 402)","description":"Chat completion billed per token: the 402 quotes your input tokens plus your declared max_tokens, and you pay for what the call actually uses. OpenAI-compatible, no signup, no API key.","url":"https://llmrt-companion.manhliemcn4euwlu.workers.dev/chat-metered-402?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET","HEAD","DELETE"],"type":"string"},"queryParams":{"type":"object","required":["order_id"],"properties":{"prompt":{"type":"string"},"system":{"type":"string"},"order_id":{"type":"string"},"max_tokens":{"type":"string"}},"additionalProperties":false}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.000142","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.000142/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.000142","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.000142","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_cuk5J0zWtqbsmqsb5D-wz","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.000142","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"OpenAI-compatible chat completion endpoint that uses x402 pay-per-token billing, charging only for actual tokens consumed based on a pre-quoted cost.","exampleAgentPrompt":"Complete this prompt using the metered chat endpoint — 'Explain the difference between supervised and unsupervised learning in plain English' — with a max_tokens budget of 300 and bill me only for what's actually used.","exampleUseCases":[{"title":"Budget-controlled copywriting assistant","prompt":"Use the pay-per-token chat endpoint to rewrite this product description in a friendly tone: 'Our vacuum cleaner uses cyclonic technology.' Keep it under 150 tokens so I'm not overbilled."},{"title":"On-demand coding help without a subscription","prompt":"I need a quick explanation of how Python decorators work — use the metered LLM endpoint with max 200 tokens so the cost stays small, and don't require me to sign up for anything."},{"title":"Automated FAQ answer generation","prompt":"For each of these three customer questions about our return policy, generate a short answer using the token-billed chat API with a max of 100 tokens each, so I can see exactly what I'm paying per response."}],"resultDescription":"Returns an OpenAI-compatible chat completion response including the generated text, model name used, and token usage breakdown (prompt tokens, completion tokens, total), with the charge reflecting only the tokens actually consumed rather than the quoted maximum.","failureModes":["Payment not completed or x402 order_id missing — returns 402 with a token-count quote before payment","max_tokens not declared — may result in unbounded billing or rejection","Prompt too long for model context window — returns error with token limit details","Workers AI upstream timeout — returns 5xx with no completion","Invalid or expired order_id — payment rejected and completion not returned"],"whenToPreferThis":"Choose this endpoint when you want LLM chat completions with true pay-per-token economics via x402 micropayments — ideal for agents that need cost-predictable inference without pre-purchasing credits or holding an API key. Prefer over flat-rate endpoints when prompt length varies widely and you want to avoid overpaying for short completions. Best suited for automated pipelines that can handle x402 payment handshake flows.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-15T06:38:05.750Z","isFirstParty":false,"canonicalSlug":"chat-completion-billed-per-token-metered-402-6eec3bb6"}