Skip to Content
DocumentationChat Completions API

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.api-stock.com/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 Stock { code, data } envelope.

OpenAI SDK

from openai import OpenAI client = OpenAI( api_key="sk-…", base_url="https://api.api-stock.com/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

FieldRequiredDescription
modelYesExact active model ID from the table below.
messagesYesOpenAI message objects in conversation order.
streamNoSet true to receive server-sent event chunks.
temperatureNoSampling temperature supported by the selected model.
top_pNoNucleus sampling value supported by the selected model.
max_tokensNoMaximum number of generated tokens.
toolsNoOpenAI-compatible tool definitions.
tool_choiceNoControls tool selection.
response_formatNoRequests structured output where the model supports it.

Other OpenAI fields are passed through. Advanced-field support can vary by model; an unsupported field returns a protocol-compatible 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.api-stock.com/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. Native SSE sends keep-alive frames while the model works. The CDN may close a connection with 524 after about 100 seconds of inactivity, which may appear as a CORS error in a browser. Some routes buffer the full response before sending SSE. The reserve route for gpt-6.2-astra and gpt-6.2-sol starts sending SSE only after the full upstream response arrives. Long requests on this route can hit the idle timeout with stream: true.

Available models

All models below use the same request contract. See the pricing page for current token rates.

FamilyModel ID
Claudeclaude-fable-5.1
Claudeclaude-fable-5.2
Claudeclaude-haiku-4-5-20251001
Claudeclaude-haiku-5-5
Claudeclaude-opus-4-6
Claudeclaude-opus-4-7
Claudeclaude-opus-4-8
Claudeclaude-opus-5
Claudeclaude-opus-5-5
Claudeclaude-sonnet-4-6
Claudeclaude-sonnet-5
DeepSeekdeepseek-v4-flash
DeepSeekdeepseek-v4-pro
DeepSeekdeepseek-v4.1-flash-1017
Geminigemini-3-flash-preview
Geminigemini-3.5-flash
Geminigemini-3.5-flash-lite
Geminigemini-3.6-flash
Geminigemini-3.7-flash
Geminigemini-3.8-flash
Geminigemini-4-argon
Geminigemini-4-carbon
Geminigemini-4-hydrogen
Geminigemini-4-neon
GLMglm-5.2
GLMglm-5.3
GLMglm-5.4
GLMglm-5.1
GPTgpt-5.5
GPTgpt-5.6-luna
GPTgpt-5.6-sol
GPTgpt-5.6-terra
GPTgpt-6-astra
GPTgpt-6-luna
GPTgpt-6-sol
GPTgpt-6.1-sol
GPTgpt-6.1-terra
GPTgpt-6.2-astra
GPTgpt-6.2-sol
GPTgpt-4o
GPTgpt-4o-mini
GPTgpt-5.2
GPTgpt-5.4-mini
Grokgrok-4.5
Grokgrok-4.6
Grokgrok-4.7
Kimikimi-k2.5
Kimikimi-k2.7-code
Kimikimi-k3
Kimikimi-k3.1-pro
MiniMaxminimax-m2.7
MiniMaxminimax-m3
Qwenqwen3.7-plus
Qwenqwen3.7-max
Qwenqwen3.8-27b
Qwenqwen3.8-omni-flash
Qwenqwen4-max

The runtime source of truth is GET /api/v1/catalog. Billing uses token usage returned by the provider.

claude-haiku-4-5 is an alias for claude-haiku-4-5-20251001.

The grok-4.7 reserve route may report more output tokens than requested, including reasoning tokens. With stream: true and a named function in tool_choice, it sends SSE after the upstream JSON response is complete.

gpt-6.2-astra and gpt-6.2-sol accept text and images through API Stock Chat Completions. To use tools with these models, call a provider’s Responses API directly with its API key. For function calling through API Stock, choose a model with Chat Completions tool support. The reserve provider’s reported input usage includes its system instructions. Above 272,000 input tokens the long-context tariff applies to the entire request.

qwen4-max accepts text and images, supports function tools and JSON Schema, and includes reasoning tokens in completion usage. Use a client-side function for web search.

gemini-4-hydrogen tool calls can include tool_calls[].extra_content.google.thought_signature. When sending a tool result, append the complete assistant message from the previous response to messages and preserve these fields unchanged. Rebuilding tool_calls from only standard fields can drop the signature and break continuation.

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 Stock agent; Chat Completions tool calling is unsupported.

Errors

Authentication, rate-limit, validation, and model errors use an OpenAI-compatible HTTP status and response body. Upstream failures use controlled public messages: provider names, routing details and raw error bodies are not returned, including inside SSE events. Retry 429 and transient 5xx responses with exponential backoff; correct 4xx request errors before retrying.