OpenAI Chat Completions API — Request & Response Reference
Full reference for POST /v1/chat/completions via APIMaster.ai. Covers request body, model selection, streaming, and response format for GPT-5.4, Claude, and DeepSeek models.
Chat Completions
Request
POST https://apimaster.ai/v1/chat/completions
Headers
| Header | Required | Notes |
|---|---|---|
Authorization |
Yes | Bearer YOUR_API_KEY |
Content-Type |
Yes | application/json |
Body (common fields)
| Field | Type | Notes |
|---|---|---|
model |
string | e.g. claude-sonnet-4-6 |
messages |
array | {role, content} |
max_tokens |
number | Max completion tokens |
temperature |
number | Optional |
stream |
boolean | SSE streaming |
Example
curl -s "https://apimaster.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Say hi in one word."}
],
"max_tokens": 64
}'
Gemini thinking levels
On native Gemini channels, gemini-4-argon and gemini-3.8-flash accept top-level reasoning_effort: low, medium, or high. The gateway maps it to native generationConfig.thinkingConfig.thinkingLevel. Argon also maps reasoning_effort: "minimal" to low; Flash 3.8 does not support minimal. Omitting the level preserves upstream defaults; Google's documented default is medium.
{
"model": "gemini-4-argon",
"messages": [{"role": "user", "content": "Explain your answer briefly."}],
"reasoning_effort": "high"
}
Alternatively, omit reasoning_effort and use these request-body fields:
{
"extra_body": {
"google": {
"thinking_config": {"thinking_level": "high", "include_thoughts": true}
}
}
}
- Explicit
thinking_levelaccepts onlylow,medium, orhigh. Unknown levels and unsupported effort values return HTTP 400. - Do not combine
reasoning_effortwiththinking_levelorthinking_budget, even when values agree.include_thoughtsalone can accompany effort. Argon also rejects simultaneous level and budget. - The Python OpenAI SDK merges its
extra_bodyargument into the request body. Preserve the literal outer JSON field withextra_body={"extra_body": {"google": {"thinking_config": {"thinking_level": "high"}}}}. highrequests the highest public reasoning level; token use remains dynamic.max_tokenscaps thinking and answer tokens together, so a tiny limit is unsuitable for verifying levels.- The gateway converts and forwards the setting. Provider enforcement requires channel-specific verification. HTTP 200, reasoning-token counts, and model self-reports alone do not establish the applied level. Responses do not report a verified applied level.
Sources: Google OpenAI compatibility and Gemini thinking levels. Other models and protocols follow their respective adapters.
Non-streaming response
{
"id": "chatcmpl-...",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15
}
}
Streaming
With "stream": true, the body is text/event-stream; lines are data: {json} until data: [DONE].
Status codes
| Code | Meaning |
|---|---|
| 400 | Bad parameters |
| 401 | Auth failed |
| 402 / 403 | Quota or permission |
| 429 | Rate limited |
| 502 / 503 | Upstream error — retry |
