{"uid":"cap_Zu-nRr-H2s3BcSv8VgXGl","slug":"llm-gateway-openai-compatible-chat-completions-3e30e897","name":"LLM Gateway – OpenAI-Compatible Chat Completions","description":"OpenAI-compatible chat completions (non-streaming) for any OpenRouter model - GET /v1/models lists them free, with pricing (upstream cost x 1.10). Pay only for what you use: sign a ceiling based on your max_tokens, settle for real usage x 1.10 (min $0.001) once the call completes. Try GET /v1/chat/completions/sample.","url":"https://x402.agentindex.world/v1/chat/completions?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","properties":{"model":{"type":"string","description":"OpenRouter model id from GET /v1/models, e.g. \"openai/gpt-4o-mini\"."},"messages":{"type":"array","items":{"type":"object"},"minItems":1,"description":"OpenAI-format chat messages: [{role, content}, ...]."},"max_tokens":{"type":"integer","description":"Max completion tokens, capped at 4096 - also bounds the x402 upto price ceiling."}}},"responseSchema":{"type":"json","example":{"id":"gen-1790576252-UzfZJjqk0Ld9PGyd1ADA","model":"openai/gpt-4o-mini","usage":{"total_tokens":12,"prompt_tokens":10,"completion_tokens":2},"object":"chat.completion","choices":[{"index":0,"message":{"role":"assistant","content":"OK."},"finish_reason":"stop"}],"x402_receipt":{"upstream":"llm-gateway","latency_ms":612,"model_served":"openai/gpt-4o-mini","price_paid_usdc":0.001}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.67584","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.67584/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.67584","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.67584","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_1Kq1YuxKdE_rk6XPQ2pYC","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.67584","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Runs non-streaming chat completions against any OpenRouter model via an OpenAI-compatible API, billed per-use via x402 micropayments at 1.10× upstream cost.","exampleAgentPrompt":"Ask openai/gpt-4o-mini to summarize the following meeting notes in 3 bullet points, using up to 512 tokens: 'Team discussed Q3 roadmap, agreed on shipping feature X by end of August, and flagged a dependency on the design team.'","exampleUseCases":[{"title":"On-demand LLM in agent pipeline","prompt":"Use the openai/gpt-4o-mini model to classify this customer support ticket as 'billing', 'technical', or 'general' — limit the response to 100 tokens: 'I was charged twice for my subscription this month and need a refund.'"},{"title":"Ad-hoc AI answer without subscription","prompt":"I don't have an OpenAI account — can you call the anthropic/claude-3-haiku model to answer this question in up to 300 tokens: 'What are the main differences between TCP and UDP protocols?'"},{"title":"LLM-powered code generation step","prompt":"Call google/gemma-3-27b-it with up to 1024 tokens and ask it to write a Python function that parses a JSON list of transactions and returns the total amount spent per category."}],"resultDescription":"Returns an OpenAI-format chat completion object with the model's generated message, finish reason, and token usage stats (prompt tokens, completion tokens, total tokens). Billed at actual token usage × 1.10× upstream model cost, minimum $0.001 per call.","failureModes":["Invalid or unknown model ID returns a 400 error","max_tokens exceeds 4096 cap — clamped or rejected","Insufficient USDC balance causes x402 payment failure before inference runs","Malformed messages array (missing role or content) causes validation error","Upstream OpenRouter model unavailability causes 502/503 response","x402 payment ceiling mismatch if max_tokens is too low for actual usage"],"whenToPreferThis":"Choose this endpoint when you need pay-per-call LLM inference without committing to a subscription, want access to the full OpenRouter model catalog (including open-source and proprietary models), need OpenAI-compatible request/response format for easy drop-in use, or are building an agent that must pay for inference programmatically via x402 micropayments on Base.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T00:31:00.348Z","isFirstParty":false,"canonicalSlug":"llm-gateway-openai-compatible-chat-completions-3e30e897"}