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 the upstream provider error.

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. 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.

FamilyModel ID
Claudeclaude-fable-5
Claudeclaude-opus-5
Claudeclaude-sonnet-5
DeepSeekdeepseek-v4-flash
DeepSeekdeepseek-v4-pro
Geminigemini-3.5-flash
Geminigemini-3.5-flash-high
Geminigemini-3.6-flash
GLMglm-5.2
GPTgpt-5.5
GPTgpt-5.6-luna
GPTgpt-5.6-sol
GPTgpt-5.6-terra
Grokgrok-4.5
Grokgrok-4.6
Kimikimi-k2.7-code
Kimikimi-k3
MiniMaxminimax-m3
Qwenqwen3.7-plus

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

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.