Chat completions
The OpenAI chat completions API, with streaming, tool calls, reasoning, structured output, and image input. This page is the contract; the request field table comes from the gateway itself.
Send the key as a bearer token on every /v1 request, or in the x-api-key header as Anthropic clients do. Keys only work on /v1: they can't sign in to the dashboard or manage other keys.
Authorization: Bearer $WHISKERS_API_KEY
curl https://whiskers.nyuu.dev/v1/chat/completions \
-H "Authorization: Bearer $WHISKERS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash",
"messages": [{"role": "user", "content": "Say hello in five words."}],
"stream": true,
"stream_options": {"include_usage": true}
}'Every field the gateway knows, and what it does with it. Coding tools send vendor extensions and give up on a 400, so a field a model can't use is dropped instead of rejected, and named in the X-Ignored-Parameters response header.
- Required
- Must be sent. Validated, then sent to the model.
- Forwarded
- Validated and sent to the model. A feature the model doesn't have (tools, images, a response format) is 400 unsupported_feature.
- Sampling
- Sent only when the model lists it in
sampling_parameters; otherwise dropped and reported. - Response
- Shapes the response the gateway sends you.
- Alias
- Read as another field. Sending both with different values is 400 invalid_request.
- Reasoning
- One way of asking for reasoning. The first one sent that says something usable wins, in the order listed.
- Ignored
- Accepted and dropped without mention.
- Rejected
- 400 unsupported_parameter: dropping it would change the result or the bill.
Fields not listed here are dropped and named in X-Ignored-Parameters, as are unknown keys inside messages, content parts, and tools (such as messages[].cache_control).
Reasoning
Ask for reasoning in any dialect your tool already speaks: reasoning_effort, reasoning, thinking, enable_thinking, chat_template_kwargs. Levels, weakest first, are none, minimal, low, medium, high, xhigh, and max; the gateway sends the strongest effort the model offers at or below the one asked for. Without a request, a model's default effort applies. X-Reasoning-Effort-Applied names the effort sent.
Reasoning counts as output tokens, visible or not. Models that show their reasoning stream it as reasoning_content.
One choice per request. Usage follows OpenAI's shape, with three additions:
{
"id": "chatcmpl-60000000-0000-4000-8000-000000000001",
"object": "chat.completion",
"created": 1788602400,
"model": "deepseek-v4.1-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello there, nice to meet!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1000,
"completion_tokens": 100,
"total_tokens": 1100,
"prompt_tokens_details": {
"cached_tokens": 400
},
"completion_tokens_details": {
"reasoning_tokens": 20
},
"cached_read_tokens": 400,
"cached_write_tokens": 100,
"credits_charged": "0.00048250"
}
}With stream: true the reply arrives as server-sent events. With stream_options.include_usage, the finish chunk is followed by one chunk with the usage and the final charge, then [DONE].
data: {"id":"chatcmpl-60000000-0000-4000-8000-000000000001","object":"chat.completion.chunk","created":1788602400,"model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{"role":"assistant","content":"Hello there"},"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-60000000-0000-4000-8000-000000000001","object":"chat.completion.chunk","created":1788602400,"model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":null}
data: {"id":"chatcmpl-60000000-0000-4000-8000-000000000001","object":"chat.completion.chunk","created":1788602400,"model":"deepseek-v4.1-flash","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":6,"total_tokens":18,"cached_read_tokens":0,"cached_write_tokens":0,"credits_charged":"0.00002400"}}
data: [DONE]During long pauses the gateway sends : keepalive comments, so proxies don't close the connection.
If the provider fails mid-stream, the gateway sends an error event and closes; the request costs nothing. Disconnecting cancels the upstream request, and a cancelled request costs nothing too.
On models with images, send image_url parts in user messages: an https URL or a base64 data URL (PNG, JPEG, WebP, or GIF). The gateway never fetches or stores images.