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
| 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 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
524after 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 forgpt-6.2-astraandgpt-6.2-solstarts sending SSE only after the full upstream response arrives. Long requests on this route can hit the idle timeout withstream: true.
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.1 |
| Claude | claude-fable-5.2 |
| Claude | claude-haiku-4-5-20251001 |
| Claude | claude-haiku-5-5 |
| Claude | claude-opus-4-6 |
| Claude | claude-opus-4-7 |
| Claude | claude-opus-4-8 |
| Claude | claude-opus-5 |
| Claude | claude-opus-5-5 |
| Claude | claude-sonnet-4-6 |
| Claude | claude-sonnet-5 |
| DeepSeek | deepseek-v4-flash |
| DeepSeek | deepseek-v4-pro |
| DeepSeek | deepseek-v4.1-flash-1017 |
| Gemini | gemini-3-flash-preview |
| Gemini | gemini-3.5-flash |
| Gemini | gemini-3.5-flash-lite |
| Gemini | gemini-3.6-flash |
| Gemini | gemini-3.7-flash |
| Gemini | gemini-3.8-flash |
| Gemini | gemini-4-argon |
| Gemini | gemini-4-carbon |
| Gemini | gemini-4-hydrogen |
| Gemini | gemini-4-neon |
| GLM | glm-5.2 |
| GLM | glm-5.3 |
| GLM | glm-5.4 |
| GLM | glm-5.1 |
| 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 |
| GPT | gpt-6.2-astra |
| GPT | gpt-6.2-sol |
| GPT | gpt-4o |
| GPT | gpt-4o-mini |
| GPT | gpt-5.2 |
| GPT | gpt-5.4-mini |
| Grok | grok-4.5 |
| Grok | grok-4.6 |
| Grok | grok-4.7 |
| Kimi | kimi-k2.5 |
| Kimi | kimi-k2.7-code |
| Kimi | kimi-k3 |
| Kimi | kimi-k3.1-pro |
| MiniMax | minimax-m2.7 |
| MiniMax | minimax-m3 |
| Qwen | qwen3.7-plus |
| Qwen | qwen3.7-max |
| Qwen | qwen3.8-27b |
| Qwen | qwen3.8-omni-flash |
| Qwen | qwen4-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.