Chat Completions — OneHub
OpenAI-compatible chat completions. Supports both streaming and non-streaming responses.
Docs
Docs Quick Start Authentication SDK Setup Available Models Rate Limits Chat Completions Streaming List Models Embeddings Image Generation Text to Speech Speech to Text Billing & Wallet Webhooks ErrorsChat Completions
POST https://www.onehub.design/v1/chat/completions
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier, e.g. openai/gpt-5-nano |
messages | array | Yes | Array of message objects with role and content |
stream | boolean | No | Set to true for SSE streaming. Default: false |
temperature | number | No | Sampling temperature (0–2). Default: 1 |
max_tokens | number | No | Maximum tokens to generate. Default: 4096 |
top_p | number | No | Nucleus sampling parameter. Default: 1 |
stop | string / array | No | Stop sequences (up to 4) |
frequency_penalty | number | No | Penalty for repetition (−2 to 2). Default: 0 |
presence_penalty | number | No | Penalty for new topics (−2 to 2). Default: 0 |
reasoning_effort | string | No | For OpenAI reasoning models: low, medium, high |
tools | array | No | Function tools for tool calling |
response_format | object | No | {"type": "json_object"} for JSON mode |
Example
curl https://www.onehub.design/v1/chat/completions \
-H "Authorization: Bearer sk-onehub-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing."}
],
"temperature": 0.7,
"max_tokens": 500
}'
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1730000000,
"model": "anthropic/claude-sonnet-5",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Quantum computing uses qubits..." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 18, "completion_tokens": 120, "total_tokens": 138 }
}
Tool calling
OneHub passes through OpenAI-compatible tool definitions, so function calling works with any model that supports it:
{
"model": "openai/gpt-5",
"messages": [{ "role": "user", "content": "What is the weather in Paris?" }],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"parameters": { "type": "object", "properties": { "location": { "type": "string" } } }
}
}],
"tool_choice": "auto"
}
Streaming support and formats are covered in Streaming.