Chat Completions API
All active language models use the same OpenAI-compatible request and response flow. Change only the model value to switch between GPT, Claude, Gemini, DeepSeek, Grok, and the other available families.
Endpoint
POST /api/v1/chat/completions
Minimal request
curl -X POST https://api.apihubs.ru/api/v1/chat/completions \
-H "Authorization: Bearer $API_STOCK_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"messages": [
{ "role": "user", "content": "Explain exponential backoff in one sentence." }
]
}'The response is the standard OpenAI Chat Completions response without an API Hubs { code, data } envelope.
OpenAI SDK
from openai import OpenAI
client = OpenAI(
api_key="sk-…",
base_url="https://api.apihubs.ru/api/v1",
)
response = client.chat.completions.create(
model="gpt-5.6-sol",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)Request parameters
| Field | Required | Description |
|---|---|---|
model | Yes | Exact active model ID from the table below. |
messages | Yes | OpenAI message objects in conversation order. |
stream | No | Set true to receive server-sent event chunks. |
temperature | No | Sampling temperature supported by the selected model. |
top_p | No | Nucleus sampling value supported by the selected model. |
max_tokens | No | Maximum number of generated tokens. |
tools | No | OpenAI-compatible tool definitions. |
tool_choice | No | Controls tool selection. |
response_format | No | Requests structured output where the model supports it. |
Other OpenAI fields are passed through. Advanced-field support can vary by model; an unsupported field returns the upstream provider error.
When a request falls back to an Anthropic provider, json_schema is sent
through its structured-output API with the schema unchanged. For
json_object, the complete final answer is checked before delivery. On this
fallback route, a streaming JSON-object answer is buffered before its SSE
chunks are sent. Tool calls and truncated or refused responses keep their
normal finish reasons. Availability still depends on the model and provider.
Streaming
Set stream: true and consume standard data: SSE frames. The stream ends with data: [DONE]. Streaming and non-streaming requests use the same model IDs and billing flow.
curl -N -X POST https://api.apihubs.ru/api/v1/chat/completions \
-H "Authorization: Bearer $API_STOCK_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"stream": true,
"messages": [
{ "role": "user", "content": "Explain exponential backoff in one sentence." }
]
}'To receive token usage on a streamed request, add "stream_options": { "include_usage": true }; the counts arrive in a final chunk after the last content delta.
Prefer streaming for long or reasoning-heavy responses. A non-streaming request holds the connection open with no bytes until the whole answer is ready, and reasoning models can take well over a minute. The CDN in front of the API caps an idle proxied connection at roughly 100 seconds and then returns a
524— with no CORS headers, so in a browser it surfaces as a misleading CORS error rather than a timeout. Streaming keeps bytes flowing, so the connection never goes idle and the limit does not apply. The dashboard playground always streams for this reason.
Available models
All models below use the same request contract. See the pricing page for current token rates.
| Family | Model ID |
|---|---|
| Claude | claude-fable-5 |
| Claude | claude-fable-5.1 |
| Claude | claude-opus-5 |
| Claude | claude-opus-5-5 |
| Claude | claude-sonnet-5 |
| Claude | claude-sonnet-5-5 |
| DeepSeek | deepseek-v4-flash |
| DeepSeek | deepseek-v4-pro |
| Gemini | gemini-3.5-flash |
| Gemini | gemini-3.6-flash |
| Gemini | gemini-3.7-flash |
| Gemini | gemini-3.8-flash |
| GLM | glm-5.2 |
| GLM | glm-5.3 |
| GPT | gpt-5.5 |
| GPT | gpt-5.6-luna |
| GPT | gpt-5.6-sol |
| GPT | gpt-5.6-terra |
| GPT | gpt-6-astra |
| GPT | gpt-6-luna |
| GPT | gpt-6-sol |
| GPT | gpt-6.1-sol |
| GPT | gpt-6.1-terra |
| Grok | grok-4.5 |
| Grok | grok-4.6 |
| Kimi | kimi-k2.7-code |
| Kimi | kimi-k3 |
| MiniMax | minimax-m3 |
| Qwen | qwen3.7-plus |
The runtime source of truth is GET /api/v1/catalog. Billing uses token usage returned by the provider.
gpt-6.1-terra supports text and streaming here, with a current provider
limit of 12,800 output tokens. Its native tool calling uses Responses API
through the API Hubs agent; Chat Completions tool calling is unsupported.
Errors
Authentication, rate-limit, validation, and provider errors use the OpenAI-compatible HTTP status and response body. Retry 429 and transient 5xx responses with exponential backoff; correct 4xx request errors before retrying.