# OnHub Chat Completions API

> OnHub Chat Completions API is a paid API for AI agents from x402.onhub.ai, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-12).

Pay-per-request LLM text inference endpoint using OpenAI-compatible chat completions format, billed per call in USDC on Base

## Facts

- Endpoint: POST https://x402.onhub.ai/v1/chat/completions?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-12
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/onhub-chat-completions-api-d3f27ef2
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_J-vxF4cIUdPCooRh_uHZT

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability onhub-chat-completions-api-d3f27ef2 -d '<json body>'
```

Example prompt: Using OnHub's pay-per-request inference, send this conversation to the gpt-oss-20b model with a max of 512 tokens and temperature 0.7: system says 'You are a concise assistant', and the user asks 'Summarize the key differences between TCP and UDP in two sentences.'

## When to prefer this

Choose this endpoint when you want OpenAI-compatible chat completions billed as micropayments in USDC on Base with no subscription commitment — ideal for agentic pipelines that need pay-per-request economics, crypto-native payment rails, or want to avoid API key management. Prefer over standard OpenAI or Anthropic APIs when building crypto-native agents or when cost predictability per call matters more than model variety.

## Known failure modes

- Payment not provided or insufficient USDC balance — 402 Payment Required returned
- Model name mismatch with the selected route — request may fail or route incorrectly
- messages array empty or missing required role/content fields — 400 Bad Request
- max_tokens exceeds 2048 limit — validation error
- stream set to true — rejected as only non-streaming (const false) is supported
- Temperature outside 0-2 range — validation error
- Network or Workers AI backend unavailability — 500 or timeout

## How this service works

Text completion using the model selected in the request body.

## Output

Returns an OpenAI-compatible chat completion JSON object containing the model name, an array of choices each with an assistant message and finish reason (e.g. 'stop'), and the object type 'chat.completion'. No streaming — response is returned as a complete JSON payload after inference.

## Request schema (JSON Schema)

```json
{
 "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."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "model": "openai/gpt-oss-20b",
  "object": "chat.completion",
  "choices": [
   {
    "index": 0,
    "message": {
     "role": "assistant",
     "content": "Hello."
    },
    "finish_reason": "stop"
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/onhub-chat-completions-api-d3f27ef2/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.onhub.ai](https://www.zero.xyz/host/x402.onhub.ai/llms.txt)
