Docs

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.

Authentication
Authorization: Bearer $WHISKERS_API_KEY
PathWhat it does
POST /v1/chat/completions
Generates one reply, streamed or whole.
POST /v1/messages
Anthropic's Messages API, for Claude Code and Anthropic SDKs. Same models, billing, and limits as chat completions.
POST /v1/messages/count_tokens
Estimates a Messages request's input tokens, without running or charging it.
POST /v1/responses
OpenAI's Responses API, for Codex. Stateless: send the whole conversation each time.
GET /v1/models
Lists the models a key can call, with limits, features, and rates.
GET /v1/models/{id}
One model, or 404 model_not_found.
GET /v1/requests/{id}
A request's final status, tokens, and charge: how a client learns the cost of a streamed or cancelled request.
curl
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.

FieldHandlingDetails
model
Required
—
messages
Required
—
max_completion_tokens
Forwarded
—
max_tokens
Alias
Same as max_completion_tokens
stream
Response
—
stream_options
Response
—
tools
Forwarded
—
tool_choice
Forwarded
—
parallel_tool_calls
Forwarded
—
response_format
Forwarded
—
reasoning_effort
Reasoning
—
reasoning
Reasoning
—
thinking
Reasoning
—
enable_thinking
Reasoning
—
chat_template_kwargs
Reasoning
—
temperature
Sampling
0 to 2
top_p
Sampling
0 to 1
stop
Sampling
—
seed
Sampling
—
presence_penalty
Sampling
-2 to 2
frequency_penalty
Sampling
-2 to 2
user
Ignored
—
safety_identifier
Ignored
—
prompt_cache_key
Ignored
—
store
Ignored
—
metadata
Ignored
—
n
Ignored
Only 1; other values are rejected
logprobs
Ignored
Only false; other values are rejected
modalities
Ignored
Only ["text"]; other values are rejected
top_logprobs
Rejected
—
audio
Rejected
—
functions
Rejected
—
function_call
Rejected
—
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:

FieldMeaning
cached_read_tokens
Input tokens read from the provider's prompt cache, priced at the cache-read rate.
cached_write_tokens
Input tokens written to the cache, priced at the cache-write rate.
credits_charged
What the request cost, in credits, after any sharing discount. A decimal string.
chat.completion
{
  "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].

text/event-stream
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.

HeaderMeaning
X-Request-Id
The request's ID, for GET /v1/requests/{id} and the dashboard.
X-Funding-Source
subscription or prepaid: what pays for this request.
X-Credits-Charged
The final charge in credits, on non-streaming responses.
X-Ignored-Parameters
The fields the gateway dropped, comma-separated.
X-Reasoning-Effort-Applied
The reasoning effort sent to the model.
Retry-After
Seconds to wait, on 429 responses when known.
x-should-retry
Whether retrying the same request can help, on every error. OpenAI's SDKs obey it.

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.