Chat Completions
Creates a chat completion for the provided messages. Supports streaming, function calling, vision, multimodal inputs, structured outputs (response_format), tool selection (tool_choice), semantic caching (cache + cache_key header), Anthropic prompt caching (cache_control on message content blocks), multi-model routing (models), request tagging (request_tags), free-tier requests (:free slug and fastrouter/free), and reasoning tokens for supported models (OpenAI o-series, Grok, Gemini thinking, Anthropic). Compatible with OpenAI SDK.
Free tier
Two ways to run a request on the free tier instead of billing credits:
:freeslug — append:freeto any opted-in model ID (e.g.openai/gpt-4o:free). The request is served from a per-(organization, model) daily quota instead of your credit balance. The suffix is stripped before routing, so the responsemodelfield returns the base model.fastrouter/free— a virtual router that picks a random eligible free model for you. The pool is filtered by endpoint support, request capabilities (vision when image content is present, tool calling whentoolsare present, structured outputs whenresponse_formatis set), and remaining daily quota.fastrouter/freedoes not accept a trailing suffix —fastrouter/free:freeandfastrouter/free:flexare rejected with 400.
The default quota is 10 requests per day per organization per model, reset at UTC midnight; individual models may be configured with a different limit. Free-tier requests never consume billing credits, even for paid organizations. Not every model is available on the free tier — :free is opt-in per model.
Free-tier error codes
Status
code
Meaning
400
free_slug_disabled
The model exists but is not enabled for :free.
400
no_free_model_available
fastrouter/free found no eligible free model for this request's requirements.
400
invalid_request_error
A trailing suffix was used on fastrouter/free (e.g. fastrouter/free:free).
404
model_not_found
The base model (after stripping :free) is not in the catalog.
429
free_quota_exhausted
Daily free-tier quota exhausted; includes quota_limit, quota_used, reset_at and a Retry-After header.
FastRouter API Key. Get yours at https://fastrouter.ai
Format: Authorization: Bearer YOUR_API_KEY
Model ID in format 'provider/model'. Examples: openai/gpt-5.1, google/gemini-3-pro-preview, anthropic/claude-4.5-sonnet.
Supports shortcut suffixes, e.g. openai/gpt-4o:thinking (high reasoning effort) and openai/gpt-4o:free (free tier).
Free tier:
<provider>/<model>:free— serve this request from the daily free-tier quota (default 10 req/day/org/model, reset at UTC midnight) instead of billing credits. Only models opted in to:freeare accepted: an unknown base model returns 404model_not_found, an opted-out model returns 400free_slug_disabled, and an exhausted quota returns 429free_quota_exhausted. The suffix is stripped before routing, so the responsemodelis the base model.fastrouter/free— virtual free-tier router: FastRouter picks a random eligible free model that supports this endpoint and the request's capabilities (vision, tools,response_format) and still has quota left. Returns 400no_free_model_availablewhen nothing qualifies. It does not accept a trailing suffix (fastrouter/free:free,fastrouter/free:flex→ 400).
anthropic/claude-4.5-sonnetOptional list of model IDs for multi-model routing. FastRouter can route across these models in order. Supports shortcut syntax (e.g. openai/gpt-4o:thinking to enable high reasoning effort, openai/gpt-4o:free to serve a fallback entry from the free-tier quota). Can be used alongside a single model.
["openai/gpt-4o","anthropic/claude-4.5-sonnet"]Optional tags to attach to the request for logging, analytics, and filtering.
["production","feature-chat"]Controls randomness in responses. Lower values (0-0.7) make output more focused and deterministic. Higher values (0.8-2) make output more creative and random.
1Example: 0.7Maximum number of tokens to generate in the completion. Limits the length of the response.
1000Nucleus sampling parameter. Alternative to temperature. Lower values make output more focused.
1Example: 0.9Penalizes repeated tokens based on frequency. Positive values reduce repetition.
0Example: 0Penalizes tokens that have appeared. Positive values encourage new topics.
0Example: 0Enable streaming responses for real-time output. When true, responses are sent as Server-Sent Events (SSE).
falseExample: trueStop sequences where the model will stop generating. Can be a string or array of strings.
["\\n","END"]Array of tool/function definitions
Controls which tool (if any) the model calls. Accepts a string (auto, none, required) or an object to force a specific tool.
autoControls tool usage: auto (model decides), none (disable tools), or required (force a tool call).
Image aspect ratio for Nano Banana (google/gemini-2.5-flash-image). Supported ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
3:2Possible values: Natural-language description for audio generation (ace-step/prompt-to-audio). Describe the audio, music, or ambient sound to generate.
A lofi hiphop song with a chill vibe about a sunny day on the boardwalk.Duration of the audio clip in seconds for text-to-audio generation (ace-step/prompt-to-audio). Optional parameter.
5Successful chat completion response
Unique identifier for the completion
chatcmpl-123Object type, always 'chat.completion' or 'chat.completion.chunk' for streaming
chat.completionThe bare model name used for the completion (without the provider prefix). The routed provider is returned separately in usage.provider.
gpt-5-miniThe service tier used to process the request (when applicable).
defaultGuardrail evaluation results attached by FastRouter, when guardrails are enabled.
Citations/sources returned by the model (e.g. for web-search-enabled models). null when there are none.
Bad Request - Invalid parameters.
Free-tier cases:
free_slug_disabled—:freewas used on a model that is not enabled for the free tier.no_free_model_available—fastrouter/freefound no eligible free model for this request's requirements.invalid_request_error— a trailing suffix was used onfastrouter/free.
Invalid Credentials - Your API key is invalid, missing, or disabled. Check your credentials.
Note: the 401 error body uses code, message, param, and type (there is no status field), and type is invalid_request_error.
Model not found. Returned when the base model — after stripping a :free suffix — is not in the catalog.
Rate Limited - You have exceeded your request limits (TPM/RPM), or the daily free-tier quota for a :free / fastrouter/free request is exhausted (free_quota_exhausted). Free-tier responses include a Retry-After header with the seconds until the quota resets, plus quota_limit, quota_used, and reset_at in the body.
Internal Server Error
POST /api/v1/chat/completions HTTP/1.1
Host: api.fastrouter.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 96
{
"model": "openai/gpt-5.1",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}{
"id": "fr_441cb234-dd59-4ace-96c0-53782b9dfb38",
"object": "chat.completion",
"model": "gpt-5-mini",
"service_tier": "default",
"guardrails": {},
"citations": null,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hi there, friend.",
"annotations": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 270,
"total_tokens": 283,
"completion_tokens_details": {
"reasoning_tokens": 256
},
"prompt_tokens_details": {
"cached_tokens": 0
},
"cost": 0.00054325,
"chat_id": "fr_441cb234-dd59-4ace-96c0-53782b9dfb38",
"provider": "openai"
}
}Last updated
