# OnHub AI Chat Completions

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

Generates text completions from a selected LLM (including reasoning-capable models) via an OpenAI-compatible chat interface, billed per call via x402.

## Facts

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

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-ai-chat-completions-d5415e76 -d '<json body>'
```

Example prompt: 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.

## When to prefer this

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.

## Known failure modes

- 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

## 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 assistant's reply message, finish reason (e.g. 'stop'), model name used, and choice index. The content field holds the generated text response.

## 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-ai-chat-completions-d5415e76/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.onhub.ai](https://www.zero.xyz/host/api.onhub.ai/llms.txt)
