{"uid":"cap_q0ewIQagt4Ka0kXMws_bB","slug":"onhub-ai-chat-completions-d5415e76","name":"OnHub AI Chat Completions","description":"Text completion using the model selected in the request body.","url":"https://api.onhub.ai/v1/chat/completions?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"model":{"type":"string","description":"Optional; must match the model in the selected route."},"stream":{"type":"boolean","const":false,"default":false},"messages":{"type":"array","items":{"type":"object","required":["role","content"],"properties":{"role":{"enum":["system","user","assistant"],"type":"string"},"content":{"type":"string"}},"additionalProperties":false},"minItems":1},"max_tokens":{"type":"integer","default":1024,"maximum":2048,"minimum":1},"temperature":{"type":"number","maximum":2,"minimum":0},"enable_thinking":{"type":"boolean","description":"For reasoning-capable Workers AI models. Defaults to false for GPT-OSS chat reliability."},"reasoning_effort":{"enum":["low","medium","high",null],"type":["string","null"],"description":"For reasoning-capable Workers AI models."}}},"responseSchema":{"type":"json","example":{"model":"openai/gpt-oss-20b","object":"chat.completion","choices":[{"index":0,"message":{"role":"assistant","content":"Hello."},"finish_reason":"stop"}]}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","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.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_9oC7HznPshdzNxjvVX6GL","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Generates text completions from a selected LLM (including reasoning-capable models) via an OpenAI-compatible chat interface, billed per call via x402.","exampleAgentPrompt":"Use the openai/gpt-oss-20b model with a temperature of 0.7 and up to 512 tokens to answer this: 'What are the main differences between REST and GraphQL APIs?' as a helpful assistant.","exampleUseCases":[{"title":"AI-powered customer support reply draft","prompt":"I need you to draft a polite customer support reply using the openai/gpt-oss-20b model — the customer said: 'My order hasn't arrived in 3 weeks and I'm very frustrated.' Keep it under 150 words, temperature 0.5."},{"title":"Code explanation for a developer tool","prompt":"Explain what this Python function does in simple terms using the gpt-oss-20b model with low temperature (0.2) and max 300 tokens: 'def fib(n): return n if n <= 1 else fib(n-1) + fib(n-2)'"},{"title":"Multi-step reasoning with a reasoning model","prompt":"Use the reasoning-capable model with high reasoning_effort and enable_thinking turned on to solve this logic puzzle step by step: 'Alice, Bob, and Carol each have a different pet. Alice doesn't have the cat. Bob doesn't have the dog. Carol has the bird. Who has which pet?'"}],"resultDescription":"Returns an OpenAI-compatible chat completion JSON object containing the assistant's reply message, finish reason (e.g. 'stop'), model name used, and choice index. The content field holds the generated text response.","failureModes":["Invalid or mismatched model name returns an error or unexpected output","max_tokens exceeding 2048 is rejected by schema validation","Streaming (stream: true) is not supported and will be rejected","Payment not provided or insufficient USDC causes x402 payment-required rejection","Empty messages array fails schema validation (minItems: 1)","Very high temperature values may produce incoherent outputs","enable_thinking on non-reasoning models may be ignored or cause errors"],"whenToPreferThis":"Choose this endpoint when you need a pay-per-call LLM completion without managing your own API keys or subscriptions, especially if you want x402 micropayment billing (USDC per call). It is OpenAI-compatible so it integrates easily into existing agent frameworks. Prefer it over managed LLM APIs when you need autonomous agent-friendly payment, or when you want access to reasoning-capable Workers AI models alongside standard chat models.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T01:16:09.387Z","isFirstParty":false,"canonicalSlug":"onhub-ai-chat-completions-d5415e76"}