Quick start
- Create an account.
- Add at least $25 to your wallet.
- Create an API key from the dashboard and copy it once.
- Set the base URL for your SDK or app to the compatible endpoint below.
- Put a supported model name in the
modelfield. - Send your first request and review usage in the dashboard.
Using an AI app?
Use the step-by-step Codex guide for the Responses API, the Cursor guide for Ask and Agent, or the Claude Code guide for the Anthropic-compatible Messages API. The integration directory covers other supported apps.
Base URLs
OpenAI-compatible
https://api.cheaperinference.com/v1
Anthropic-compatible
https://api.cheaperinference.com
Anthropic SDKs and Claude Code append /v1/messages themselves. Set ANTHROPIC_BASE_URL with no /v1 suffix: adding it produces /v1/v1/messages and a 404. See the Claude Code setup guide.
Authentication
Send Authorization: Bearer ci_live_YOUR_API_KEY.
The Messages endpoints also accept X-Api-Key.
Chat completion
One language setting updates every example on this page.
curl https://api.cheaperinference.com/v1/chat/completions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-opus-4.6", "messages": [{"role": "user", "content": "Hello!"}] }'from openai import OpenAIclient = OpenAI( api_key="ci_live_YOUR_API_KEY", base_url="https://api.cheaperinference.com/v1",)response = client.chat.completions.create( model="claude-opus-4.6", messages=[{"role": "user", "content": "Hello!"}],)import OpenAI from "openai";const client = new OpenAI({ apiKey: "ci_live_YOUR_API_KEY", baseURL: "https://api.cheaperinference.com/v1"});const response = await client.chat.completions.create({ model: "gpt-5.4", messages: [{ role: "user", content: "Hello!" }]});cURL Responses request
curl https://api.cheaperinference.com/v1/responses \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4", "input": "Hello!", "store": false, "stream": true }'The stateless Responses compatibility layer supports Codex streaming, function calls, and custom local tools such as apply_patch. store is accepted and ignored: we send store: false upstream whatever you send, and responses cannot be retrieved later through the API. Whether we keep request content is a separate setting: see zero data retention below. Stored responses, previous_response_id, conversations, background mode, and provider-hosted web or file search are not supported.
Pro reasoning
To use Pro, send a POST request to /v1/responses with store: false and reasoning.mode: "pro". Set reasoning.effort separately to control how much reasoning the model does. Pro requires the Responses endpoint. Chat Completions returns HTTP 400 for Pro requests.
curl https://api.cheaperinference.com/v1/responses \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.6-luna", "input": "Explain why the sum of two odd numbers is always even.", "store": false, "reasoning": {"mode": "pro", "effort": "medium"}, "max_output_tokens": 1024, "stream": false }'The models gpt-5.6-luna, gpt-5.6-terra, gpt-5.6-sol and gpt-6-astra support Pro mode. Set stream: true to receive output as it arrives, or stream: false to receive one complete response. These models use standard mode when reasoning.mode is omitted.
For gpt-5.5-pro, gpt-5-pro, gpt-5.2-pro, gpt-5.4-pro and o3-pro, the model ID already selects Pro. Omit reasoning.mode and set stream: false. These models do not support streaming. Other catalog ids ending in -pro are ordinary entries served on the endpoints their supported_endpoints list, not Pro routes.
Your price, provider, region and data-retention settings still apply. The provider must also support the features in your request. If no compatible Pro provider is available, the API returns HTTP 503 without charging you. A provider response that does not confirm Pro is rejected without a charge. Other OpenAI Pro model IDs, model IDs with a date suffix, and Pro reasoning replay are not yet supported. This includes requesting reasoning.encrypted_content.
Pro can take longer and use more tokens than standard mode. Billing includes the total input and output tokens used across its model work, so input_tokens can exceed your original prompt's token count. The gpt-5.5-pro model has its own pricing.
For streaming requests, read the final event as well as the HTTP status. A stream can start with HTTP 200 and later report an error. Pro streams are charged only when a valid final response confirms Pro and includes token usage.
Claude reasoning and thinking
To request Claude thinking through Chat Completions, send reasoning_effort: "high" or reasoning: { "effort": "high" }, with a sufficient output limit such as max_tokens: 8192. These spellings are aliases; conflicting values return 400. Effort support depends on the model and serving provider. When thinking is requested through native Messages translation, Sonnet 4.6 and Opus 4.6 use adaptive thinking by default; Haiku 4.5 uses a manual thinking budget. Explicit native thinking and output_config settings take precedence over portable effort.
Manual thinking requires an integer budget of at least 1,024 tokens, strictly below max_tokens or max_completion_tokens. The bridge never raises your output limit. Where supported, reasoning.max_tokens selects a manual budget; adaptive-only models reject that portable budget. For automatic manual budgets, minimal uses 10% of the output limit, low 20%, medium 50%, high 80%, and xhigh/max 95%, with a 1,024-token floor and 128,000-token ceiling. Leave room for the answer, for example max_tokens: 8192. Invalid budgets return 400 before a provider request is submitted.
Use n: 1 and modern tools, tool_choice, tool_calls and tool-result messages. Legacy functions, function_call and function-role history return 400 for Claude requests using thinking or explicit caching. Active thinking allows auto or none tool_choice; a forced named tool or required tool choice is rejected. Sampling support is model-specific: omit temperature, top_p and top_k on models that do not support them. The Chat-to-native bridge caps temperature values above 1 at 1 to match Anthropic Chat compatibility.
Claude Chat thinking summaries are hidden by default, including on cache hits. To include them, explicitly send include_reasoning: true or reasoning.exclude: false. reasoning.exclude: true or include_reasoning: false always hides the summary, even when another visibility control opts in, without disabling thinking or changing token billing. Requesting reasoning effort alone does not opt in to visibility. Chat requests using a native Messages route translate thinking and cache controls while still returning Chat JSON or server-sent events (SSE); visible summaries appear in message.reasoning_content for buffered JSON and delta.reasoning_content for streams. Adaptive thinking can skip a simple task, so an empty summary does not prove the effort was ignored. Native /v1/messages clients use thinking and output_config and receive the Messages response format, including thinking blocks requested for replay.
Pi: Claude reasoning and prompt caching
Pi does not automatically add cache markers for a custom cheaper-inference provider. In Pi builds supporting compat.cacheControlFormat, set it to "anthropic" in the model entry of ~/.pi/agent/models.json. This guidance was checked against upstream Pi on 2026-09-28; older installed versions can have different options. Set CHEAPER_INFERENCE_API_KEY in Pi's environment, merge the example into your existing configuration, and choose a catalog model available to your key on /v1/chat/completions.
For Pi versions without cacheControlFormat, omit that option and add provider headers: { "x-ci-prompt-cache": "on" } alongside baseUrl. The gateway then marks unmarked requests. cacheRetention controls Pi's marker retention; it does not enable marker support for an unrecognized provider. Its default is short, and none stops Pi adding markers but does not cancel an x-ci-prompt-cache: on header. PI_CACHE_RETENTION=long alone does not enable caching.
With reasoning: true, supportsReasoningEffort: true and an enabled thinking level, thinkingFormat: "openai" sends reasoning_effort. Cheaper Inference also accepts reasoning.effort from clients that send that format. Enabling effort does not guarantee visible thinking or cache hits.
Pi's anthropic-messages adapter is a separate native integration. Use https://api.cheaperinference.com without /v1 as its base URL; it appends /v1/messages and sends native thinking and output_config controls. Preserve that adapter's model-specific thinking and replay configuration. The Chat example below uses https://api.cheaperinference.com/v1 instead.
{ "providers": { "cheaper-inference": { "baseUrl": "https://api.cheaperinference.com/v1", "api": "openai-completions", "apiKey": "${CHEAPER_INFERENCE_API_KEY}", "models": [ { "id": "claude-opus-4.6", "reasoning": true, "input": [ "text", "image" ], "compat": { "cacheControlFormat": "anthropic", "supportsReasoningEffort": true, "thinkingFormat": "openai" } } ] } }}Check your installed version against Pi's custom model documentation and Chat adapter options.
API reference
Every endpoint, header, and error code, with runnable request builders. The generated code updates as you edit the fields, so it is useful to read and copy whether or not you are signed in. The sections after it cover topics this reference does not, and go deeper on a few it only summarises.
Running a request needs an account, because the call bills to a wallet. Sign in to enable the live request builders. Everything else below is readable and copyable now.
One language setting updates every example.
Make the first request
Keep your OpenAI SDK and change the base URL plus API key. Generated snippets use a prefix placeholder unless you choose to include a newly created key.
Base URL
https://api.cheaperinference.com/v1API keys
Create separate credentials for applications, reporting jobs, and environments. You can copy your saved keys from the API keys page. Older keys may require your saved copy.
Run inference
Allows model requests that can spend wallet balance. The API scope is inference.
Read usage and spend
Allows usage reports and pricing-change reads. The API scope is usage:read.
Limit access
Restrict a key by model, IP range, expiration, request rate, concurrency, or monthly spend.
Chat completions
Send messages in the OpenAI chat format. Turn streaming on in Request controls to inspect the server-sent event response.
Try chat completions
Edit the prompt and controls. The generated code updates with every field.
Loading available models…
No published list price for this model. Savings show optimization only.
Leave optional controls empty to use provider defaults. Availability and effective sampling can vary by serving provider.
Request controls
Return server-sent events as tokens arrive.
Send X-CI-Concise: 1 for a shorter response.
Send X-CI-Route: auto for eligible prompts.
Output monitor
Live response
Sign in to run this request
The request and its generated code are complete and copyable now. Running the prompt against gemini-3.7-flash needs an account, because the call bills to a wallet.
Sign in to try itEstimated cost · $0.000000 · Standard pricing · Discount unavailable
POST /chat/completions
Choose an available model to generate a request.Text completions
Use the legacy prompt field for clients that still call the completions endpoint. The same pricing and optimization pipeline applies.
Try text completions
Set an output budget to keep the test inexpensive. Leave optional sampling controls empty to use provider defaults.
Loading available models…
No published list price for this model. Savings show optimization only.
Leave optional controls empty to use provider defaults. Availability and effective sampling can vary by serving provider.
Request controls
Return server-sent events as tokens arrive.
Send X-CI-Concise: 1 for a shorter response.
Send X-CI-Route: auto for eligible prompts.
Output monitor
Live response
Sign in to run this request
The request and its generated code are complete and copyable now. Running the prompt against gemini-3.7-flash needs an account, because the call bills to a wallet.
Sign in to try itEstimated cost · $0.000000 · Standard pricing · Discount unavailable
POST /completions
Choose an available model to generate a request.Image generation
Choose an image model and describe the image you want. The response uses the OpenAI Images shape and the playground previews returned URLs or base64 images.
Generate an image
The generated cURL and SDK examples use the image endpoint and a media-compatible payload.
Loading available models…
No published list price for this model. Savings show optimization only.
Output monitor
Live response
Sign in to run this request
The request and its generated code are complete and copyable now. Running the prompt against gemini-3.7-flash needs an account, because the call bills to a wallet.
Sign in to try itEstimated cost · $0.000000 · Standard pricing · Discount unavailable
POST /images/generations
Choose an available model to generate a request.Video generation
Video generation is buffered while the provider completes the job. The example requests a five-second 720p clip and allows up to five minutes.
Generate a video
Returned video URLs and base64 MP4 data are playable in the output monitor.
Loading available models…
No published list price for this model. Savings show optimization only.
Output monitor
Live response
Sign in to run this request
The request and its generated code are complete and copyable now. Running the prompt against gemini-3.7-flash needs an account, because the call bills to a wallet.
Sign in to try itEstimated cost · $0.000000 · Standard pricing · Discount unavailable
POST /videos/generations
Choose an available model to generate a request.Anthropic Messages API
POST /messages. Use Anthropic-compatible messages, streaming, vision, and client-side tools with a Cheaper Inference key. Token counting is available at POST /messages/count_tokens.
X-Api-Key or a Bearer token. Claude Code executes tools locally and returns tool results to this endpoint.Open the Claude Code setup guideResponses API
POST /responses. The stateless Responses compatibility layer supports streaming, function calls, and local tools for Codex clients. store is accepted and ignored; replies always report store: false.
wire_api = "responses" and point its base URL at this API's /v1 path.Open the Codex setup guideTry Responses
The selected model controls streaming availability. Dedicated Pro models use a complete, non-streaming response.
Loading available models…
No published list price for this model. Savings show optimization only.
Leave optional controls empty to use provider defaults. Availability and effective sampling can vary by serving provider.
Request controls
Return server-sent events as tokens arrive.
Send X-CI-Concise: 1 for a shorter response.
Send X-CI-Route: auto for eligible prompts.
Output monitor
Live response
Sign in to run this request
The request and its generated code are complete and copyable now. Running the prompt against gemini-3.7-flash needs an account, because the call bills to a wallet.
Sign in to try itEstimated cost · $0.000000 · Standard pricing · Discount unavailable
POST /responses
Choose an available model to generate a request.Models
GET /models. Fetch every model currently available. Curated models carry verified list pricing. Marketplace models use the cheapest seller ask plus the configured routing fee and claim no list-price discount.
List available models
Curated catalog models plus the current marketplace feed.
import OpenAI from "openai";const client = new OpenAI({ apiKey: "ci_live_your_key...", baseURL: "https://api.cheaperinference.com/v1",});const models = await client.models.list();for (const model of models.data) console.log(model.id);Response feedback
POST /feedback. Attach a 1 to 5 score to a request on your account. Experiment results use this signal to compare variants.
const response = await fetch("https://api.cheaperinference.com/v1/feedback", { method: "POST", headers: { "Authorization": "Bearer ci_live_your_key...", "Content-Type": "application/json", }, body: JSON.stringify({ "request_id": "req_...", "score": 5, "comment": "Accurate answer" }),});console.log(await response.json());Headers
Request headers choose optional experiment and optimization behavior. Response headers identify what ran and what it saved.
Request headers
| Header | Description |
|---|---|
| X-CI-Experiment | Opts this request into a running experiment. Set the value to the slug shown on the Experiments page. |
| X-CI-End-User | Your stable, non-sensitive user id. For sticky assignment, the same id stays on the same variant. |
| X-CI-Concise | Set to 1 to opt into concise output. |
| X-CI-Route | Set to auto to opt into model routing. |
Response headers
| Header | Description |
|---|---|
| x-ci-request-id | Request id for logs and feedback. |
| x-ci-tokens-saved | Input tokens removed or avoided. |
| x-ci-saved-usd | Savings in USD, reported to six decimal places. |
| x-ci-techniques | Comma-separated optimization technique ids. |
| x-ci-experiment-variant | The assigned variant name. Present only when X-CI-Experiment matched a running experiment. |
| x-ci-cache | hit when exact-match caching served the response. |
Usage reporting
GET /usage. Read request-level history or daily aggregates with a key that has the Read usage and spend permission. Reporting-only keys cannot run inference.
GET /usage/requests
Per-request token counts, billed cost, status, model, latency, and cursor pagination.
GET /usage/daily
Daily request and spend totals across an optional date range, including zero-usage dates.
Rate limits and retries
CheaperInference does not publish a fixed account-level request quota today. Marketplace sellers can return 429 responses when capacity changes.
Retry safely
Use exponential backoff with jitter. Respect Retry-After when the upstream response includes it.
Bound each call
Set max_tokens on every request. The dashboard examples default to 128.
No failed-request charge
Provider errors are recorded for diagnosis, but wallet settlement only runs after a successful response.
Machine-readable spec and integration guides
The OpenAPI document is generated from the service and checked in CI, so it cannot drift from what these endpoints actually do.
OpenAPI 3.1 document
Every /v1 endpoint, its parameters and every error status. Point a client generator at it. No API key required.
Claude Code
Anthropic Messages. Set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY.
Codex
OpenAI Responses. Add a model provider with wire_api = "responses".
Cursor
OpenAI Chat Completions. Override the base URL in Settings → Models.
Guides and detail
Topics the reference above does not cover, and deeper notes on the ones it summarises.
Optimization
Improve a prompt, compare alternatives, or configure optional processing. The Optimization guide explains each workflow, its billing and traffic scope, and how to evaluate results.
- Prompt Studio: prepare a task, run candidate evaluations, review scores, and reuse the rewritten prompt.
- Experiments: create variants, send traffic, collect feedback, and promote a winner for experiment requests.
- Techniques: understand tradeoffs, test overrides, and manage workspace defaults.
Available models and pricing
Copy the exact model ID into the model field. Every model we serve, with its current price and capabilities, is on the live model catalog. Each GET /v1/models item also includes an aliases array with the vendor-qualified id, including vendor-specific version punctuation, so migrations do not need a hand-maintained map. IDs absent from this catalog return HTTP 404.
How pricing and routing work
For every request, Cheaper Inference ranks the eligible provider routes by estimated cost and starts with the lowest-cost route available for that model and request. If that provider is unavailable, has insufficient capacity, or fails before output begins, the gateway automatically tries the next-lowest-cost eligible route. Your public model ID and API response format remain unchanged.
We fix the rate of each request when we accept it, at the catalog rate in effect at that moment. If the request then falls back to another route, the rate does not change: you pay for what the request actually used, at no more than that rate, whichever route served it. The rate never exceeds the model maker's applicable direct API list price. Cheaper Inference adds no separate routing surcharge; the settled API rate is all-in.
Provider prices can change over time. The exact amount charged for each completed request is available in your dashboard.
Model catalog API
Use your API key to retrieve currently available models and their current catalog rates. A request is charged at the rate in effect when it is accepted, even if it falls back to another route. Filter by type (for example text, embedding or transcription), vision, video, reasoning, streaming, or provider to find models that meet a workload's requirements.
curl 'https://api.cheaperinference.com/v1/models?type=text&vision=true&streaming=true' \ -H 'Authorization: Bearer ci_live_YOUR_API_KEY'Token rates are USD per 1 million tokens. Fixed media rates use media_input_unit_price and media_unit_price per unit. For tiered models, use pricing.above_threshold when the request exceeds input_token_price_threshold.
Model prices do not change on a fixed customer-facing schedule: they can change when an upstream rate or an eligible route changes. Do not treat a locally cached rate as the final charge for a request. Use these response fields to validate a cache:
pricing_versionis a SHA-256 version of the returned, API-key-filtered catalog. An unchanged value means that catalog is unchanged.pricing_checked_atis the UTC time of the latest successful provider-price check.pricing_updated_atis the latest UTC time at which the customer-facing price changed among the returned models.
Pricing change feed
curl 'https://api.cheaperinference.com/v1/pricing/changes?since=2026-07-29T00:00:00Z' \ -H 'Authorization: Bearer ci_live_YOUR_API_KEY'since is a required RFC 3339 timestamp. The endpoint returns the latest current customer-facing model object for each catalog row changed at or after that time. A removal has change_type: "removed" and model: null. Follow next_cursor while has_more is true; keep the original since value on every page.
{ "object": "pricing.changes", "pricing_version": "sha256:8f4c...", "pricing_checked_at": "2026-07-29T14:32:10Z", "pricing_updated_at": "2026-07-29T14:31:52Z", "data": [{ "model_id": "gpt-5.4", "change_type": "updated", "changed_at": "2026-07-29T14:31:52Z", "model": { "id": "gpt-5.4", "object": "model", "type": "text", "endpoint": "/v1/chat/completions", "pricing": { "currency": "USD", "input_per_million": "1.250000", "cache_read_input_per_million": "0.125000", "cache_write_input_per_million": "1.250000", "output_per_million": "10.000000" } } }], "has_more": false, "next_cursor": null}There is no pricing webhook at this time. Poll this feed, process changes idempotently by model_id and changed_at, then use the newest changed_at as the next since value. Because since is inclusive, the boundary change may be returned again. Periodically compare pricing_version with GET /v1/models to reconcile the full cache.
The catalog identifies modality, endpoint, vision, video, reasoning and streaming support. Tool calling, structured output, context limits, and accepted optional parameters can still vary by model and serving provider; verify the exact request shape before production use.
Parameters
OpenAI-compatible parameters
Chat requests use the OpenAI Chat Completions shape. Common fields such as temperature, top_p, max_tokens, max_completion_tokens, stop, tools, tool_choice, response_format, and reasoning are forwarded to the selected model.
Support and interpretation are model-specific. An unsupported parameter may be ignored or rejected by the serving provider, so test the exact model and request shape before moving production traffic.
Anthropic-compatible parameters
Messages requests accept model, messages, max_tokens, system, stream, temperature, top_p, stop_sequences, tools, tool_choice, and thinking. Use exact model IDs from GET /v1/models rather than Anthropic aliases.
Tools and structured output
Models that support tool calling accept the standard OpenAI tools and tool_choice fields. Models that support JSON output accept response_format, including json_object or a JSON schema where the model supports it.
"response_format": { "type": "json_object"}Price ceiling
Add min_discount_percent to a chat completions, completions, messages, or responses request. The value sets the minimum discount off list price that the request will accept.
The field takes a number from 0 to 99.99. The gateway checks the value against our published list price for the model. It never checks it against a price claimed by a supply source. The gateway removes the field from the request body before it forwards the request, so no upstream provider sees it.
curl https://api.cheaperinference.com/v1/chat/completions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4", "messages": [{"role": "user", "content": "Hello!"}], "min_discount_percent": 40 }'Only supply priced at or under the ceiling can serve the request. The gateway checks the input rate and the output rate separately. A source must clear the ceiling on both rates to qualify. The gateway also caps the bill for the request at list price times (1 − min_discount_percent / 100) for each rate, even when the serving source would allow a higher charge.
When no supply currently clears the ceiling, the request fails. The gateway does not fall back to a source priced above the ceiling.
Errors
400/invalid_min_discount:min_discount_percentis not a number, or it is outside 0–99.99.400/list_price_unknown: the gateway has no list price for this model, so it cannot check a ceiling.503/min_discount_unavailable: no supply is currently priced at or under the ceiling. Lowermin_discount_percentor retry later.
{ "error": { "message": "No supply for gpt-5.4 currently meets min_discount_percent=40 (a required discount of at least 40%; customer ceiling $1.80 in / $9.00 out per 1M tokens; upstream list $3.00 / $15.00). Lower min_discount_percent or retry later.", "type": "api_error", "param": null, "code": "min_discount_unavailable" }}Check available supply first
Use GET /v1/models/supply to count sources that currently clear a ceiling for a model, before you send a real request.
curl 'https://api.cheaperinference.com/v1/models/supply?model=gpt-5.4&min_discount_percent=40' \ -H "Authorization: Bearer ci_live_YOUR_API_KEY"{ "object": "model.supply", "model": "gpt-5.4", "min_discount_percent": 40, "list_input_per_million": "3.00", "list_output_per_million": "15.00", "max_input_per_million": "1.80", "max_output_per_million": "9.00", "supply_buffer_percent": 4, "candidate_count": 3, "candidates": ["primary", "network_a", "network_b"], "primary_market_offers": 2, "primary_market_min_discount_percent": null, "note": "Candidates use the current admission filter for a representative non-streaming chat request (about 1,000 input tokens and up to 1,000 output tokens), including this account's privacy and supply restrictions. Other request shapes, health and fill are not guaranteed."}candidate_count is the number of sources priced under the ceiling right now. max_input_per_million and max_output_per_million are the capped billing rates for this ceiling. primary_market_offers counts distinct primary-market providers among the eligible candidates, including zero when none qualify. A candidate count above zero reports current pricing only. It does not guarantee provider health or a successful fill.
For the full parameter and schema reference, see the API reference.
Zero data retention
ZDR means zero data retention. The ZDR toggle on the model catalog, the zdr request field, and the ?zdr=true query parameter all refer to this section.
Add zdr: true to a chat completions, completions, messages, or responses request. The gateway then routes the request only through providers that support a zero-data-retention policy. A zero-data-retention provider does not keep your prompts or responses and does not train on them.
Zero data retention is also how you opt out of retention by Cheaper Inference. Without it, we may retain the content of your requests (such as prompts, files and outputs) as described in the privacy policy. With it, we do not retain the content and keep only the request metadata needed for billing and operations. Turning it on applies to new requests and does not delete content already retained, and closing your account does not delete it either. A deletion request through the privacy form does.
curl https://api.cheaperinference.com/v1/chat/completions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-5", "messages": [{"role": "user", "content": "Hello!"}], "zdr": true }'The gateway removes the field from the request body before it forwards the request. The flag adds to the Data Protection setting on your account: turn that on to make every request zero-data-retention without sending the field. A request cannot switch the account setting off with zdr: false. The per-request flag can only add the constraint, never remove it.
PII and provider agreements
ZDR controls retention; it does not detect, mask, or anonymize personally identifiable information (PII). Cheaper Inference does not provide automatic PII redaction before forwarding inference requests. If your policy requires it, remove or pseudonymize sensitive data in your application before sending the request, including tool results and attachments. Billing and operational metadata, such as request IDs, timestamps, token counts, and costs, is still retained.
An existing agreement with a model developer does not by itself establish coverage for requests purchased through Cheaper Inference. Confirm the serving account, model, enabled features, retention terms, and approved providers with your contract owner before sending regulated data. ZDR eligibility and an approved provider list are separate requirements. For an example of product-specific coverage, see Anthropic's ZDR scope.
What the ZDR price is
A ZDR request excludes every provider that does not support a zero-data-retention policy. The pool is smaller, so the price is usually higher than the standard price for the same model. The catalog shows the ZDR price when you switch on the ZDR only toggle, and GET /v1/models?zdr=true returns the same view.
It is not a surcharge or a separate rate card. Your standard price comes from whichever discounted source is cheapest, and the marketplace is usually that source. A ZDR request cannot be filled there. So the ZDR price is what the cheapest zero-data-retention-capable source would bill for the same model, which is the rate the request actually settles at. Both numbers are still capped at the provider's published list price, so a ZDR request is never billed above list.
curl 'https://api.cheaperinference.com/v1/models?zdr=true' \ -H "Authorization: Bearer ci_live_YOUR_API_KEY"Errors
400/invalid_zdr:zdris not a boolean.503/zdr_capacity_unavailable: no provider with zero-data-retention support currently serves the model, so the gateway refuses the request before it is sent upstream. Choose another ZDR-capable model or wait for capacity. If zero data retention is required by your organization, keep the constraint enabled; the gateway must fail rather than use a provider outside that policy.
Use GET /v1/models/supply?model=…&zdr=true to count the zero-data-retention sources for a model before you send a real request.
Ranking: speed, discount, balance
Several discounted sources can usually serve one request: the marketplace, seller networks, and direct providers. The gateway tries them in order until one succeeds, within a time limit. Only when none of them can serve the request in time does it fall back to other available capacity. Add ranking to a chat completions, completions, messages, or responses request to choose the order of the discounted sources. Every eligible source is ranked the same way, fallback capacity included.
curl https://api.cheaperinference.com/v1/chat/completions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4", "messages": [{"role": "user", "content": "Hello!"}], "stream": true, "ranking": "speed" }'"discount": the lowest expected cost per answer first. Each source's cost is weighed against how often it fails, so a cheap source that fails often can rank below a dearer one that answers."speed": the fastest expected full answer first: the source's recent time to first output plus its output speed for the expected answer length, also weighed against how often it fails."balance"(default): expected cost, reliability and time to first token together. A slow first token adds a small premium to a source's cost, so speed decides between sources of similar cost.
All three read the gateway's own recent traffic on the same model, not a fixed list of "fast" providers. Reliability counts server errors, timeouts and broken streams, weighted towards the last few minutes, with the last day as a baseline. A source that answers 429 (rate limited) is set aside for a few minutes. A source with little recent traffic is still tried from time to time, so new capacity gets measured. A conversation stays on the source that holds its prompt cache while that source keeps answering.
Speed and discount are not a trade-off. The fastest source for a model is often also one of the cheapest, so "speed" can pick the same route as "discount", and "discount" does not promise a slower answer. The field says how the gateway ranks the candidates given the recent telemetry. It does not add or remove candidates, and it does not change the price: the rate is fixed when the request is accepted, whichever source serves it.
The gateway removes the field from the request body before it forwards the request. Combine it freely with min_discount_percent and zdr: those two decide which sources are eligible, ranking decides the order among them.
Errors
400/invalid_ranking:rankingis not one ofspeed,discount,balance.
Images and vision
Vision input
Vision-capable chat models accept OpenAI image_url parts and Anthropic-style base64 image blocks. Check capabilities.vision in GET /v1/models before sending one.
Streaming
Models marked Streaming accept "stream": true on Messages, chat, text completion, and Responses endpoints. Streams use server-sent events, and wallet usage is settled when the stream completes. The gateway can retry and change routes before output begins. After the first event is delivered, a failed partial stream cannot be replaced transparently; retry the complete request.
Runnable vision request
Use an HTTPS image URL or a base64 data URL in an OpenAI image_url content part:
curl https://api.cheaperinference.com/v1/chat/completions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4", "messages": [{ "role": "user", "content": [ {"type": "text", "text": "Describe this image."}, { "type": "image_url", "image_url": {"url": "https://example.com/image.png"} } ] }] }'Large images: temporary uploads
A request body may be at most 4.5 MB in total, and base64 inflates a file by about a third. A conversation carrying several photographs reaches that ceiling quickly, and the limit is enforced before the request reaches this API, so an oversized body is refused without a usable error.
POST /v1/uploads lifts each image out of the request. Upload the file on its own - the 4.5 MB limit then applies per image rather than to the whole conversation - and reference the returned img_ id in the message. Images may be PNG, JPEG, WebP or GIF, up to 4 MB each. The upload requires a key with the inference scope, and is refused on accounts with zero data retention enabled.
curl https://api.cheaperinference.com/v1/uploads \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -F "file=@photo.png;type=image/png"# {"id": "img_Ic_FdF-4bAcTLcWcai85R4p2", "object": "vision_upload",# "content_type": "image/png", "bytes": 482318,# "expires_at": "2026-01-01T12:00:00.000Z"}Reference the id where the image would otherwise go. The Anthropic Messages form is shown here; on Chat Completions use {"type": "image_file", "image_file": {"file_id": "img_..."}}, and on Responses use {"type": "input_image", "file_id": "img_..."}.
curl https://api.cheaperinference.com/v1/messages \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-opus-5", "max_tokens": 512, "messages": [{ "role": "user", "content": [ { "type": "image", "source": {"type": "file", "file_id": "img_Ic_FdF-4bAcTLcWcai85R4p2"} }, {"type": "text", "text": "Describe this image."} ] }] }'Uploads expire, and the image is deleted. An upload lasts one hour, after which the stored image is removed from our storage and the id stops working. It is meant for the request you are about to send, not as image hosting. Delete one sooner with DELETE /v1/uploads/{id}.
The limit is 100 at a time, not 100 in total. An upload that has expired, or that you deleted, frees its slot immediately, so a steady workload never reaches the cap. Exceeding it returns 429. The img_ id is resolved when the request is forwarded, so a provider never receives it, and an expired or unknown id is refused rather than silently dropped.
When a model will not take an image URL. Some models are only served by providers that require the image bytes in the request. Sending an image_url to one of those is answered with 400 and "param": "image_url". Send the image as a data: URL, or upload it as above; both work on every vision model.
PDF input
Send a PDF in the same request as your prompt. Chat Completions takes {"type": "file", "file": {"filename": "a.pdf", "file_data": "data:application/pdf;base64,..."}}. Responses takes {"type": "input_file", "filename": "a.pdf", "file_data": "data:application/pdf;base64,..."} or an input_file with file_url. Anthropic Messages takes a document block with a base64 source (media_type application/pdf), a url source, or a text source. A document block also accepts title, context, citations and cache_control.
curl https://api.cheaperinference.com/v1/chat/completions -H "Authorization: Bearer ci_live_YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "claude-opus-5", "messages": [{ "role": "user", "content": [ {"type": "file", "file": {"filename": "report.pdf", "file_data": "data:application/pdf;base64,JVBERi0x..."}}, {"type": "text", "text": "Summarise this document."} ] }] }'For a PDF link, we download the file before routing. The link must be an https address on a public host. A request may carry at most 10 links and 10 MB of PDF in total, counted once for each place a link appears. A link that fails is refused with 400; send the PDF as base64 instead. The 4.5 MB request body limit still applies to base64 data.
Only models that read PDFs serve the request. We send a PDF only to a model and route that read it. If none is available, the request is refused with 400 and unsupported_parameter. Uploaded file ids (file_id) are not supported and are refused with 400. You are billed on the input tokens the model counts for the document.
Large conversations: compressed request bodies
The 4.5 MB ceiling is measured on the wire, not after decoding, so compressing the body moves the limit rather than working around it. A long conversation that is refused uncompressed is accepted gzipped, and text compresses heavily - prompts of several megabytes routinely leave on the wire at a fraction of their size.
Send Content-Encoding: gzip and we inflate the body before parsing it. zstd, deflate and br are accepted too, one encoding at a time. Keep Content-Type: application/json as it is: it describes the body you wrote, not how it was encoded for transport.
# Write the request body, then send it gzipped.jq -n --arg text "$(cat long-conversation.txt)" '{ model: "claude-opus-5", max_tokens: 1024, messages: [{role: "user", content: $text}]}' | gzip > body.json.gzcurl https://api.cheaperinference.com/v1/chat/completions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -H "Content-Encoding: gzip" \ --data-binary @body.json.gzAccepted on POST /v1/chat/completions, /v1/completions, /v1/responses, /v1/messages, /v1/messages/count_tokens, /v1/images/generations and /v1/videos/generations. Multipart image edits and the non-inference endpoints read their bodies directly and expect them uncompressed.
Compressing every request is fine. There is no size threshold to check and no reason to switch it on conditionally: an already-small body stays small, and the inflate cost is immaterial beside model latency. A body that inflates past 20 MB is refused with 413 - on /v1/messages/count_tokens that inflated ceiling is 4.5 MB - and an encoding we do not recognise is refused with 415.
Request compression is lossless: it preserves context and image fidelity and does not reduce token usage. The compressed body must still fit within 4.5 MB. Zstd requests have a maximum 32 MiB decoder window; malformed or truncated streams return 400 and excessive windows return 413.
Open your integration setup and copy the setup prompt to configure verified compression for your installed version. Existing users must rerun setup once. OpenCode v2 supports native gzip; SDK examples include scoped gzip transports. Other harnesses may have no verified setting for a custom endpoint. CI accepting zstd does not make Codex send it automatically. A successful small request verifies the connection, not compression.
Generate an image
Image-generation models use POST /v1/images/generations, not Chat Completions. The response contains data entries with either a URL or base64 image data.
curl https://api.cheaperinference.com/v1/images/generations \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "nano-banana", "prompt": "A tiny observatory on a mossy hill at blue hour", "n": 1 }'Edit an image
Use POST /v1/images/edits only with a model whose capabilities.image_edit value is true in GET /v1/models. Multipart requests accept one to ten PNG, JPEG, or WebP source images and an optional PNG mask; decoded sources plus the mask may total at most 20 MiB. An unsupported edit is refused and is never converted into a text-to-image generation.
curl https://api.cheaperinference.com/v1/images/edits \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -F "model=gpt-image-2" \ -F "prompt=Replace the background with a quiet library" \ -F "image=@source.png;type=image/png" \ -F "mask=@mask.png;type=image/png"The JSON extension accepts source HTTP(S) URLs in input_references. Cheaper Inference passes those URLs only to compatible providers and never downloads them itself. Masks must remain PNG uploads or PNG data URLs so their semantics cannot be silently dropped by a provider route.
Generate a video
Video models use POST /v1/videos/generations. Generation is buffered while the provider completes the job, so use a client timeout of at least five minutes. The response contains avideos array with URLs or base64 MP4 data. Models such as seedance-2.0 and seedance-2.5 take a resolution of 480p, 720p or 1080p; check the model's catalog entry for the resolutions it serves.
curl https://api.cheaperinference.com/v1/videos/generations \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ --max-time 300 \ -d '{ "model": "seedance-2.0", "prompt": "A paper boat drifting through a neon-lit rain puddle", "duration": 5, "resolution": "720p", "n": 1 }'Fetch results again
If your client timed out or lost the answer, the files are not gone. Image, video and speech results are kept for 7 days, except for zero data retention requests. Call GET /v1/generations/<request_id> with the request_id from the answer, or the x-ci-request-id response header, and you get a download link for each file. Links expire after 1 hour; call again for fresh ones. DELETE /v1/generations/<request_id> removes the files immediately.
curl https://api.cheaperinference.com/v1/generations/REQUEST_ID \ -H "Authorization: Bearer ci_live_YOUR_API_KEY"Ask a decision model
Decision models such as jev-1.13 answer typed questions about one input with probabilities instead of text. UsePOST /v1/decisions with the OpenAI Decisions shape: a string or user messages as input, and aquestions array of predicate (yes or no),choice (pick one of 2 to 255 values) andscore (rate against 2 to 10 ordered levels) questions. Answers come back in request order. You are billed on input tokens only, and streaming is not supported. The OpenAI SDKs call this asclient.decisions.create(...) with only a base URL change.
curl https://api.cheaperinference.com/v1/decisions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "jev-1.13", "input": "I was charged twice and cannot sign in to request a refund.", "questions": [ { "type": "predicate", "name": "refund", "instructions": "Does the customer ask for a refund?" }, { "type": "choice", "name": "team", "instructions": "Which team should handle this?", "choices": [ { "value": "billing", "description": "Charges, invoices and refunds" }, { "value": "account", "description": "Sign-in and account access" } ] }, { "type": "score", "name": "urgency", "instructions": "How urgent is this?", "levels": [{ "label": "low" }, { "label": "medium" }, { "label": "high" }] } ] }'Transcribe or translate audio
Speech-to-text models turn audio into text. UsePOST /v1/audio/transcriptions with the OpenAI shape: a multipart file (flac, m4a, mp3, mp4, mpeg, mpga, oga, ogg, wav or webm) and a model, plus optionallanguage, prompt,temperature, timestamp_granularities[] andresponse_format (json, text, srt, vtt or verbose_json).POST /v1/audio/translations answers in English. List the models with GET /v1/models?type=transcription; a model's supported_endpoints says whether it also translates.
You are billed per second of audio at the model's list price minus your discount, and the charge is in the x-ci-billed-cost-usd response header. A request body can be at most 4.5 MB. For a larger file, up to 25 MB, send file_url with a public https link instead of file, and we download it. Streaming is not supported. The OpenAI SDKs work with only a base URL change.
curl https://api.cheaperinference.com/v1/audio/transcriptions \ -H "Authorization: Bearer ci_live_YOUR_API_KEY" \ -F model="whisper-large-v3-turbo" \ -F file="@meeting.mp3" \ -F response_format="srt"from openai import OpenAIclient = OpenAI(base_url="https://api.cheaperinference.com/v1", api_key="ci_live_YOUR_API_KEY")with open("meeting.mp3", "rb") as audio: transcript = client.audio.transcriptions.create(model="whisper-large-v3-turbo", file=audio)print(transcript.text)# Audio in any language, answered in English:with open("interview.m4a", "rb") as audio: english = client.audio.translations.create(model="whisper-large-v3-turbo", file=audio)Generate speech
Text-to-speech models turn text into one audio file. Use POST /v1/audio/speech with the OpenAI shape: a model, the input text and a voice. List the models with GET /v1/models?type=speech. You are billed per input character, and the charge is in the x-ci-billed-cost-usd response header. Streaming is not supported. The OpenAI SDKs work with only a base URL change.
curl https://api.cheaperinference.com/v1/audio/speech -H "Authorization: Bearer ci_live_YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "tts-1", "input": "Your order has shipped.", "voice": "alloy"}' --output speech.mp3Voice sessions over a WebSocket
Live voice models hold a conversation on one WebSocket. Connect to GET /v1/realtime?model=<id> with Authorization: Bearer <key> and send JSON events: session-update first, then conversation-item-create and response-create. The server answers with session-created, the response deltas, response-done and error. A model serves it when its supported_endpoints in GET /v1/models list /v1/realtime.
A session is one request. max_session_usd (0.01 to 25, default 1) is held from your balance when the session opens and is the most it can cost. Each finished response is metered in the units the model is priced in, such as text and audio tokens or audio seconds, and the session settles once when it closes. A session ends when you close it, when the limit is reached, or after about 13 minutes. A refusal before the upgrade is a JSON error with the usual codes; a refusal during the session is an error event, then a close with code 1008 (refused) or 1011 (upstream failure).
websocat -H "Authorization: Bearer ci_live_YOUR_API_KEY" "wss://api.cheaperinference.com/v1/realtime?model=gpt-realtime-mini&max_session_usd=0.50"{"type": "session-update", "config": {"instructions": "Answer in one sentence."}}{"type": "conversation-item-create", "item": {"type": "text-message", "role": "user", "text": "What is the capital of France?"}}{"type": "response-create"}gpt-live-1 uses OpenAI's Live events at GET /v1/live/sessions. The first event is session.start with session.model; then send session.input_audio.append with base64 PCM16 audio at 24 kHz, at playback speed, and session.close to end. You are billed per voice second, which session.closed reports in usage.seconds.
websocat -H "Authorization: Bearer ci_live_YOUR_API_KEY" "wss://api.cheaperinference.com/v1/live/sessions"{"type": "session.start", "session": {"model": "gpt-live-1", "audio": {"format": {"type": "audio/pcm", "rate": 24000}}}}{"type": "session.input_audio.append", "audio": "<base64 PCM16 audio>"}{"type": "session.close"}Create embeddings
Embedding models turn text into vectors. Use POST /v1/embeddings with the OpenAI shape: a model and an input that is a string, an array of token ids, or an array of 1 to 2048 of these. Set encoding_format to float (the default) or base64, and dimensions to shorten the vector on a model that supports it. List the models with GET /v1/models?type=embedding. You are billed on the input tokens the model counts. Streaming is not supported. The OpenAI SDKs work with only a base URL change.
curl https://api.cheaperinference.com/v1/embeddings -H "Authorization: Bearer ci_live_YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "YOUR_EMBEDDING_MODEL", "input": ["first text", "second text"], "encoding_format": "float" }'from openai import OpenAIclient = OpenAI(base_url="https://api.cheaperinference.com/v1", api_key="ci_live_YOUR_API_KEY")result = client.embeddings.create(model="YOUR_EMBEDDING_MODEL", input=["first text", "second text"])print(len(result.data), len(result.data[0].embedding))Rerank documents
Rerank models score documents against a query. Use POST /v1/rerank with the Cohere shape: a model, a query, 1 to 1000 documents and an optional top_n. The Cohere SDKs work with only a base URL change, and POST /v2/rerank takes the Cohere v2 shape. List the models with GET /v1/models?type=rerank. You are billed on the input tokens or the search units the model counts, as its price states.
curl https://api.cheaperinference.com/v1/rerank -H "Authorization: Bearer ci_live_YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "rerank-v3.5", "query": "How do I reset my password?", "documents": ["Billing runs monthly.", "Reset your password from the sign-in page.", "We ship worldwide."], "top_n": 2 }'Prompt caching
Claude requests can carry cache_control on the request, tools, messages and supported content blocks. The Chat-to-Messages bridge preserves supported cache controls during translation. x-ci-prompt-cache: on adds breakpoints to an unmarked Claude request at the system/tools prefix and the last eligible conversation block. Existing explicit markers and lifetimes remain the caller's policy. Explicitly choosing passthrough in the header or workspace rule adds no markers. When neither is set and the key uses the default passthrough mode, automatic markers depend on the serving route. Choose on for consistent marker behavior. Use x-ci-prompt-cache: off or a workspace rule of off to remove explicit cache controls. Implicit caching can still apply. Zero data retention (ZDR) preserves the chosen prompt caching mode and disables exact-response caching.
Enable Require prompt caching for a key from Dashboard → API keys → Limits → Prompt caching, then click Save limits. For API configuration, send {"prompt_cache_mode":"require"} to PUT /v1/keys/self/techniques.
Require defaults marker behavior to on. It restricts requests with explicit cache controls, or requests with effective mode on and at least 1,024 estimated prompt tokens, to routes verified to write and read a cache. The request header and workspace policy still control marker behavior. Requests with effective mode off use ordinary routing.
The request must still meet min_discount_percent. The API returns 503 min_discount_unavailable when the price misses the requested floor, or 503 prompt_cache_unavailable when no verified route can serve the request under its constraints. A new prefix still needs a cache write before it can be reused.
Send a distinct, stable x-ci-prompt-cache-session value for each conversation to request consistent routing affinity. A nonempty header takes precedence over prompt_cache_key. Affinity is separate from provider cache storage and does not guarantee the same provider or a cache hit. A cache marker requests caching; reuse still requires an identical eligible prefix, the model's minimum length, a successful cache write, and matching provider scope and retention window. Changing tools, system instructions or reasoning settings can change the prefix.
Measure reuse from reported cache-read and cache-write token usage. GET /v1/usage/daily reports cache_hit_pct only across requests whose upstream reports cache usage; null means unknown, not zero. A successful request, an affinity hit, or visible reasoning is not evidence of a prompt-cache hit. Exact-response caching is a separate optional optimization that replays a stored answer without a provider generation.
For streamed Chat Completions, set stream_options.include_usage to true to receive reported cache counts in the usage chunk. Send x-ci-stream-receipt: 1 to receive the settled cost in cheaper_inference.billing.billed_cost_usd in the final receipt.
cache_control is passed through when supported by the selected model. Cache reads and writes use imported model-specific rates when available. If no cache-read rate is available, cached reads use 10% of the normal input rate; cache writes without a separate rate use the normal input rate.
cURL Anthropic Messages request
Available to all users: every Cheaper Inference account can use these endpoints with an active API key that has Inference scope. No Anthropic account or separate enablement is required. Normal wallet balance, model access, and API-key limits still apply.
Compatibility scope: this integration implements POST /v1/messages and POST /v1/messages/count_tokens. It is not the complete Anthropic platform API; unsupported features are listed below.
Shown in cURL; this example has no OpenAI JavaScript form.
curl https://api.cheaperinference.com/v1/messages \ -H "X-Api-Key: ci_live_YOUR_API_KEY" \ -H "Anthropic-Version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-opus-4.8", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello!"}] }'from anthropic import Anthropicclient = Anthropic( api_key="ci_live_YOUR_API_KEY", base_url="https://api.cheaperinference.com",)message = client.messages.create( model="claude-opus-4.8", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}],)POST /v1/messages accepts the Anthropic Messages shape and returns an Anthropic-style message. It supports buffered and streamed text, system content, vision blocks, client-side tools and tool results, multi-turn replay, stop sequences, tool choice, usage accounting, and extended-thinking request hints. Streams use Anthropic event names such as message_start, content_block_delta, message_delta, and message_stop.
Use POST /v1/messages/count_tokens with the same model, system, messages, and tools fields for an estimated input_tokens count. Counting does not submit an inference request or charge the wallet.
Client-side tools work because Claude Code executes them locally and returns tool_result blocks. Anthropic-hosted server tools, Message Batches, Files, and signed thinking-block replay are not compatibility targets. Thinking settings can guide an eligible model, but responses do not expose Anthropic-signed thinking blocks.
For the complete environment setup and model mapping, use the Claude Code integration guide.
Errors and limits
Billing and wallet
- Wallet balance is checked before a request starts.
- Usage is deducted after a completed request.
- Add funds manually or enable auto-recharge.
Security and keys
- Store API keys in environment variables, not frontend code.
- Create separate keys for production and testing.
- Configure model, IP, expiration, rate, concurrency, daily quota, and monthly budget controls from API Keys.
- Revoke exposed keys immediately.
Common errors
OpenAI-compatible endpoints use the envelope below. The Messages endpoints return Anthropic's {"type":"error","error":{...}} shape instead. Use the error type for program logic and keep the message for logs and operator context.
{ "error": { "message": "Invalid API key.", "type": "authentication_error", "param": null, "code": "invalid_api_key" }}400/invalid_request: unsupported model, endpoint, or invalid request body. Check the JSON body, model id, and required fields. A media model sent to a text endpoint, a text model sent to a media endpoint, or a dedicated Pro model sent anywhere but/v1/responsesgets a message naming the endpoint to use; other endpoint restrictions are not checked in advance, so checkendpointandsupported_endpointsinGET /v1/models.400/unsupported_parameter,unexpected_parameterorinvalid_parameter: no route for the model accepts a field in the request, such as a reasoning setting it does not support.paramnames the field. Remove or change it; retrying unchanged fails the same way.400/context_length_exceededoroutput_limit_exceeded: shorten the prompt, or lower the output cap for the endpoint:max_output_tokenson Responses,max_tokenson Messages and Chat Completions, ormax_completion_tokenswhere the Chat model requires it.401/invalid_api_key: invalid or missing API key. Create or rotate a key, then update the Bearer token.402/insufficient_balance: add funds in Billing, then retry the request.403/model_not_allowed: the API key does not allow the model, client IP, or request. The policy is set per key on the API keys page; see Key policies.403/end_user_blocked: the model provider blocked an end user for a usage-policy violation. The message names the end user from your request. Send a distinctsafety_identifier(oruser, ormetadata.user_idon Messages) for each of your end users, so that a block applies to that end user only and not to your whole account.404/request_not_found: feedback can only target a request on your own account.413Request body or vision payload is too large. A single request body may be at most 4.5 MB on the wire, and a temporary vision upload at most 4 MB. Base64 inflates a file by about a third, so a 3.5 MB image no longer fits inline. Send images by URL or throughPOST /v1/uploads, and send a long conversation withContent-Encoding: gzip, which is measured compressed and so raises the effective ceiling to 20 MB of JSON. An uncompressed body over the limit is rejected before it reaches the API, so it is not billed and does not appear in your request history.422A query or typed request parameter failed validation.429/rate_limit_error: a rate, concurrency, or quota limit was reached. Retry with exponential backoff and jitter, and respect theRetry-Afterresponse header before retrying.502/upstream_error: provider or transport failure after eligible routes were exhausted. The request is recorded but not charged.503No eligible provider route is currently available.504The serving provider timed out.
Reliability
Automatic retries and fallback
Network failures and HTTP 404, 408, 409, 425, 429, and 5xx responses are retried once. Other 4xx responses are not retried; when another route is eligible, the gateway immediately tries it in price order. Your request keeps the same public model ID and response format.
This failover happens automatically for provider capacity, availability, and transport failures. Validation, authentication, insufficient-balance, and oversized-payload errors still require a change from the caller.
Usage and response privacy
Successful buffered responses include the model's token usage, a top-level request_id and a billing object with the exact settled customer charge. Messages and Responses streams carry both on their terminal event; Chat Completions and Completions streams carry neither, so reconcile those from the request id header. The request ID is also returned in the X-Cheaper-Inference-Request-Id header, and in x-ci-request-id. Provider cost and private routing metadata are removed before the response is returned to you.
{ "usage": { "prompt_tokens": 1234, "completion_tokens": 321, "total_tokens": 1555, "cost": 0.012345, "cost_details": { "upstream_inference_cost": 0.012345 } }, "request_id": "77fb54b7-249a-477d-bbb4-fb2d331a86b1", "billing": { "status": "settled", "billed_cost_usd": "0.012345", "currency": "USD" }}usage.cost and usage.cost_details.upstream_inference_cost both report the exact all-in customer charge after settlement. From the caller's perspective Cheaper Inference is the upstream inference service; the private amount paid to the selected serving provider is not exposed. billing.billed_cost_usd is the persisted amount deducted for that request after routing and settlement. Chat Completions and Completions streams carry no billing fields and no billing headers; reconcile those from the x-ci-request-id response header. Responses API streams include it in the final response.completed object. Messages streams include it on the final message_delta event. A failed or unsettled request does not report a billed amount.
White-label keys. Turn on White-label for a key on the API keys page and its responses contain no identifying information: no x-ci-* headers, no X-Cheaper-Inference-Request-Id, no billing field, no usage.cost or usage.cost_details, and no :x-ci-model-ttft-ms stream comment, and wallet errors do not link to the dashboard. The request ID is still returned, as request_id in the body and in the x-request-id header; quote it to support. Usage, spend and billing in your dashboard are unchanged.
Unless zero data retention is on, Cheaper Inference may retain the content of your requests, such as prompts, files, and the outputs returned. Turn on zero data retention to opt out. Prompts are forwarded to the provider that serves the request, and provider-side handling is subject to that provider's applicable terms. Prompt caching may also create provider-side cached state. Request metadata needed for billing and operations is retained, including model, endpoint, token counts, charged amount, status, and a sanitized failure reason. Review the privacy policy for the full statement.
Service status
The status page shows whether the API and dashboard are working right now, open incidents, planned maintenance, and past incidents. Subscribe there to get an email when we publish an incident, an update to one, or planned maintenance.
Timeouts
Per-request limits
Streaming (SSE) and non-streaming requests have the same request limit. They run through the same endpoints and are not capped differently.
A request may run for up to 795 seconds on /v1/chat/completions, /v1/messages, /v1/completions and /v1/responses, and up to 295 seconds on the image and video endpoints. A request still running when it reaches that limit is ended and returns an error, so treat the limit as a ceiling rather than an allowance you can plan to use.
Set your client timeout to match
Most HTTP clients and SDKs default to far less than these limits and will give up while the request is still running. Set your own timeout no lower than the longest response you expect.
Latency and TTFT
Every page, report and API field uses these two definitions, which are the usual industry definitions.
Time to first token (TTFT)
From our API receiving your request to the first output token, reasoning included: network, routing, provider queue and prompt prefill. Measured on streamed requests only; a non-streamed request has no TTFT. Field: time_to_first_token_ms.
Latency
From our API receiving your request to the last byte of the response. Roughly TTFT plus output tokens divided by generation speed. Field: total_latency_ms.
Aggregates report the median (p50) with p90 beside it, over settled requests. Timings have a long tail, so an average would be pulled up by a few slow requests. routing_overhead_ms is the time before the request reached the provider that served it, failed attempts included, and routing_overhead_ms + model_time_to_first_token_ms = time_to_first_token_ms. Streamed responses also carry the provider's own TTFT as an SSE comment, :x-ci-model-ttft-ms=<ms>.
Usage and billing API
Reports by API key or member
In Reports, select a date range and use API keys to view consumption and spend for one or more keys. Revoked keys remain available for historical reporting. The totals and CSV, Excel, and PDF exports use the same key, member, and model filters.
Owners, admins, and members granted Team reports access can use Members to select a workspace or individual members. Usage is attributed to the key's owner, so give each person their own key to track them separately. A shared key cannot identify which person sent a request. Scheduled deliveries retain their configured scope; changing these report filters does not change a subscription.
Usage reporting is workspace-wide and accepts the same API-key authentication as inference. Create a key with Usage reporting only access in API Keys when the reporting system should not be able to submit inference requests or spend wallet funds. Add api_key_id to restrict either endpoint to one key.
How long request history is kept
Individual request records are kept for 45 days. After that the per-request detail is no longer available in the dashboard or the API, and only daily aggregates are shown.
Within 45 days, GET /usage/requests returns each request on its own and Dashboard → Requests lists them. Anything built from individual requests follows the same 45 days, including GET /usage/team-savings and its /requests drill-down.
Totals come from the daily aggregates instead, so they reach further back: GET /usage/daily, GET /account/usage, GET /account/savings, the dashboard charts and Reports cover the whole period the aggregates hold.
Export before the window closes if you need a longer history. GET /usage/requests gives the per-request grain: request id, model, endpoint, status, token counts, cost, latency and TTFT. It does not return error text, so capture that from the response at the time if you need to keep it. CSV exports from Reports are day and day-by-model totals rather than individual requests, so they are not a substitute for the per-request export.
Asking for a request past the window is not an error, and it does not mean we have no record of having served it. Asking by id with GET /usage/requests?request_ids=… returns the ids that did not come back in missing_request_ids, alongside any that did. Ids that aged out, ids that were never yours and ids that never existed all appear there and are deliberately indistinguishable, so a client reconciling old receipts should treat that list as no longer available rather than as never happened.
The response also carries retention_days beside missing_request_ids. Individual ids are never marked as expired, because that would reveal whether an id exists. You know when you made each request, so compare its age against retention_days to see which absences your own records already explain.
Submitting feedback with POST /v1/feedback for a request past the window returns 404 request_not_found, for the same reason and with the same ambiguity. Daily and day-by-model totals for the period are unaffected and remain available indefinitely, so spend and volume questions can still be answered after the per-request detail is gone.
This is not the same as zero data retention. The 45 days applies to the request records shown here, such as a request's model, cost and token counts. Zero data retention governs whether your prompts and responses are kept, by the provider and by us: without it we may retain them as described in the privacy policy.
Token usage fields
Every response reports the token counts the serving model returned; nothing is padded or estimated. Field names follow the endpoint you called, not the provider that served it.
- Cache reads and writes. Chat Completions reports them in
usage.prompt_tokens_details, ascached_tokensandcache_write_tokens; both are part ofprompt_tokens. Responses reportscached_tokensinusage.input_tokens_details, and some routes report it asusage.cached_tokens. It is part of the input count./v1/messageskeeps Anthropic'scache_read_input_tokensandcache_creation_input_tokens, counted separately frominput_tokens. - Reasoning. For most reasoning models,
completion_tokens(output_tokens) includes reasoning as well as the visible answer, so a short reply can carry a large count. The breakdown appears incompletion_tokens_details.reasoning_tokenswhen the model reports it. Some providers report reasoning only there and leave it out ofcompletion_tokens, so the aggregate can be smaller than what was billed; billing always includes reasoning. Not every model reports the breakdown on every response, so a missing field does not mean no reasoning happened. Reasoning is billed as output. Lower the reasoning effort or the endpoint's output cap (max_output_tokenson Responses,max_tokenson Messages and Chat Completions,max_completion_tokenswhere the Chat model requires it) to spend less.
Request history
curl 'https://api.cheaperinference.com/v1/usage/requests?start_at=2026-07-01T00:00:00Z&end_at=2026-08-01T00:00:00Z&limit=100' \ -H 'Authorization: Bearer ci_live_YOUR_API_KEY'start_atandend_atare optional RFC 3339 timestamps. The start is inclusive and the end is exclusive.api_key_idoptionally filters to a key owned by the same workspace.limitaccepts 1–100 and defaults to 100.cursoraccepts the previous page'snext_cursor. Results are newest first.
{ "object": "list", "scope": "workspace", "data": [{ "request_id": "77fb54b7-249a-477d-bbb4-fb2d331a86b1", "api_key_id": 19, "api_key_name": "production", "model": "gpt-5.4", "endpoint": "/v1/chat/completions", "status": "settled", "prompt_tokens": 1234, "completion_tokens": 321, "cache_read_input_tokens": 0, "cache_write_input_tokens": 0, "total_tokens": 1555, "billed_cost_usd": "0.012345", "currency": "USD", "total_latency_ms": 1890, "time_to_first_token_ms": 420, "created_at": "2026-07-29T14:30:00Z", "completed_at": "2026-07-29T14:30:02Z" }], "has_more": false, "next_cursor": null}billed_cost_usd is non-null only when status is settled. Request history intentionally excludes prompts, generated content, provider cost, private route names, and profit or margin data.
Daily spend
curl 'https://api.cheaperinference.com/v1/usage/daily?start_at=2026-07-01T00:00:00Z&end_at=2026-08-01T00:00:00Z' \ -H 'Authorization: Bearer ci_live_YOUR_API_KEY'- When dates are omitted, the endpoint returns the preceding 30 days through the current time.
- Every calendar date in the range is returned, including dates with zero requests.
{ "object": "usage.daily", "scope": "workspace", "currency": "USD", "start_at": "2026-07-01T00:00:00Z", "end_at": "2026-08-01T00:00:00Z", "total_requests": 820, "settled_requests": 811, "spend_usd": "148.420015", "prompt_tokens": 1043200, "cached_tokens": 786400, "cache_reported_request_count": 811, "cache_hit_pct": 75.4, "daily_spend": [{ "date": "2026-06-30", "request_count": 24, "settled_request_count": 24, "spend_usd": "3.910042", "prompt_tokens": 30500, "cached_tokens": 22100, "cache_reported_request_count": 24, "cache_hit_pct": 72.5 }]}Daily spend sums persisted charges for settled requests only. Therefore, total_requests can be greater than settled_requests.
Balance
curl 'https://api.cheaperinference.com/v1/account/balance' \ -H 'Authorization: Bearer ci_live_YOUR_API_KEY'{ "object": "account.balance", "currency": "USD", "balance_usd": 124.50, "available_usd": 118.02, "reserved_usd": 6.48, "auto_recharge_enabled": true, "threshold_usd": 25.00, "recharge_amount_usd": 100.00, "workspace_name": "Acme", "funded_by_owner": false}Spend against available_usd, not balance_usd. The difference is reserved_usd: money already held against requests that have not settled yet, so the balance on its own overstates what can still be spent. This endpoint needs the account:read scope; a usage-only key receives a 403.
API-key access
inferencepermits inference requests.usage:readpermits request history, daily spend, and pricing-change reads.account:readpermits balance and account reads.GET /v1/modelsaccepts any valid API key.- Use a reporting-only key for billing exports and monitoring systems.
Account
Ask us anything
The Ask us anything button in the dashboard header opens a panel with two tabs, split by what they can see:
- Docs searches only this documentation. Ask about setup, API behavior, billing rules, models, error codes, or troubleshooting. It never reads your account, keys, or balance, and if the docs do not cover a question it says so.
- My account reads your own workspace data: balance, usage, savings, experiments, techniques, and keys, plus the docs for how-to questions. Ask for a readout of spend or savings, compare what a model would cost you, or change a setting. It changes only what you ask it to.
Both tabs accept screenshots and files (PDF, CSV, Excel) attached to a question.
Connecting Slack, Discord, and Telegram
Connect a chat platform from the Reports page in the dashboard. Slack and Discord connect through the platform's own authorization flow; Telegram opens a direct chat with the bot through your personal link, and a separate link adds the bot to a group. Connecting creates a direct-message channel addressed to you, and each channel keeps its own notification and report settings.
Notifications and scheduled reports
A connected channel can receive the savings report on a schedule (daily, weekly, or monthly, at the hour and day you choose) and event notifications, on by default and adjustable per channel:
- Low wallet balance, while auto-recharge is off.
- Spend anomalies, and an organization spend limit being reached.
- An expiring payment card.
- Pricing alerts, when a recently used minimum discount is no longer met by current pricing.
- Experiment updates: started, paused, resumed, completed, winner promoted.
- Technique changes: promoted, enabled, disabled.
The email savings digest is configured separately on the Reports page.
Asking the bot about your account
The bot on every connected platform is the same account assistant as the My account tab. Type balance, usage, or info for an instant answer, or ask anything in plain language: it reads your account, searches this documentation, and can set up or change the report schedule, adjust which events the channel receives, and send a report immediately. Figures are for the workspace's billing account, changes apply only to the channel you are chatting in, and the bot never moves money or changes billing. Questions are rate limited per hour.
MCP server
Connect your coding tool to https://api.cheaperinference.com/mcp over Streamable HTTP. Clients such as Codex, Claude Code and Cursor can open Cheaper Inference in your browser to approve access, then return to the coding tool. See the connection guide.
For an API-key setup, send a scoped key in the Authorization or X-Api-Key header. This example uses a placeholder for the key.
{ "mcpServers": { "cheaper-inference": { "type": "http", "url": "https://api.cheaperinference.com/mcp", "headers": { "Authorization": "Bearer ci_live_YOUR_KEY" } } }}VS Code uses the server under servers in .vscode/mcp.json. For a static key, Windsurf uses serverUrl in place of url and Claude Desktop can use mcp-remote. Remove a static credential from the server entry before switching it to browser sign-in.
The key decides what is listed. A key carries only the scopes turned on for it on the API keys page, and the tool list follows: a tool whose scope the key lacks is not offered.
- Docs, any key:
search_docs. - Models and pricing, Read usage and spend (
usage:read):list_models,compare_model_cost,get_pricing_changes. - Account, Read account data (
account:read):get_balance,get_usage,get_savings,get_account_info,list_api_keys,list_experiments,get_experiment,list_techniques,list_channels. - Changes, Change account settings (
account:write):set_technique,create_api_key,revoke_api_key,set_channel_schedule,set_channel_events,send_report_now,start_topup. A top-up returns a checkout link; the payment happens on that page, never inside the tool. - Prompt Studio, Read Prompt Studio (
prompt-studio:read):prompt_studio_check_prompt,prompt_studio_get_capabilities,prompt_studio_list_runs,prompt_studio_get_run,prompt_studio_get_job_status. Checking a prompt is free and runs no model; a finished run returns the optimized prompt-set to put back into your code. - Prompt Studio runs, Run Prompt Studio (
prompt-studio:write, and the key needs inference):prompt_studio_optimize_promptstarts a zero-shot optimization. This spends money: the run bills the key's wallet, the same as a run started from Prompt Studio in the dashboard. The tool asks the client to check the prompt first, show you the estimate and its upper bound (1.5 times the estimate), and get your go-ahead. The estimate is not a cap; a run that costs more than estimated is still billed. - Code hosts, Read connected repositories (
repos:read):repos_get_connections,repos_request_access,repos_read_file. Open pull requests (repos:write):repos_connectandprompt_studio_open_pull_request, which puts a run's optimized prompt-set back into the file it came from on a new branch and opens the pull request. Nothing is ever written to your default branch: every change is a pull request for you to review. These work on the repositories you connect on Integrations (a GitHub App you install on the repositories you choose, or the checkbox on a GitHub sign-up). The MCP never asks for the connection on its own: only when you ask for remote repository work and nothing is connected does it ask, and if it cannot tell where your code lives (GitHub, GitLab, Bitbucket) the link lets you pick. A coding agent with a checkout needs none of this; theprompt_studio_apply_runprompt edits the file and opens the pull request locally.
No other tool spends the wallet, and none runs inference on your behalf. Listings name each row with a short handle (exp_3f9a1b2c) that later calls accept, as does part of the name. Add ?read_only=1 to the URL to drop every tool that changes something. A key restricted to IP ranges is refused here with a 403, because the tools reach the API from our servers; use an unrestricted key for the MCP. Refused calls count against the same abuse shield as the chat bots, so a client that keeps probing for other accounts is blocked.
Key policies
Every API key carries its own policy, set on the API keys page: scopes, allowed models, an IP allowlist, an expiry date, per-minute, per-day and concurrent request limits, a monthly budget, a routing priority and provider pins. A request that a policy refuses answers 403 or 429 with a message naming the rule; Common questions lists the messages and the field behind each.
Closing your account
Close your account from Settings → Profile, under "Permanently close account". It requires a sign-in within the last 10 minutes, typing your account email exactly, and confirming that any positive prepaid balance is forfeited. A workspace you own that still has other members blocks closure until you transfer ownership in Team settings. Closure cannot be undone: API keys and sessions are revoked immediately, saved payment data is deleted, and personal data is anonymized. Closing does not delete stored request content; to have it deleted, ask through the privacy support form. Signing in later with the same email starts a brand-new, empty account, and that first sign-in shows a notice saying the previous account was deleted, so a missing balance or history is never a surprise.
Cursor compatibility
Cursor Ask and Agent can use OpenAI-family models through the OpenAI base-URL override. In Cursor Settings → Models, add a dedicated Cheaper Inference key, enable Override OpenAI Base URL, and enter https://api.cheaperinference.com/v1. Select an exact model ID from the live catalog, then verify both a short Ask prompt and one harmless Agent edit.
Cursor sends Agent tool traffic through Chat Completions. The gateway normalizes the current streamed ApplyPatch tool shape and the older Responses-shaped BYOK request format. Cursor's override is global for OpenAI-family models; tab completion, Claude- and Gemini-family models, and other Cursor-hosted features do not use this connection.
Use key scope, model, rate, spend, and expiration controls. Do not restrict the key to your workstation IP because Cursor sends these requests from its own service. See the complete Cursor setup and troubleshooting guide.
Production checklist
- Load your API key from a server-side environment variable.
- Use
GET /v1/modelsto confirm the model is available and supports the required modality. - Set an explicit client timeout appropriate for long model generations.
- For direct HTTP clients, retry transport errors,
429, and5xxresponses with exponential backoff. - Do not retry
400,401,402, or413without correcting the request. For402, add funds before retrying. - Treat an interrupted stream as incomplete and retry the entire request.
- Review token usage, spend, and failures in the dashboard before increasing traffic.
- Subscribe to the status page so you hear about incidents and planned maintenance.
For the generated public request, response, authentication, and error schemas, open the API reference.
Common questions
Specific cases that come up often. The sections above describe the flow; these answer the question as it is usually asked.
OmniRoute vs Cheaper Inference
OmniRoute is a separate open source (MIT) gateway that runs on your own machine, installed from the npm package omniroute or as a Docker image, and pools third-party free tiers you sign up for yourself behind one local endpoint, http://localhost:20128/v1. Cheaper Inference is the hosted API at https://api.cheaperinference.com/v1: a prepaid wallet, discounted curated models and marketplace routing, nothing to install.
Cheaper Inference backs OmniRoute as an Open Source Friend, and OmniRoute supports it as a provider: enter your ci_live_ key in OmniRoute's provider settings and the models appear as cheaperinference/<model id>, with Chat Completions, Responses, vision, tool calling and image models. OmniRoute's own installation and quick start are in the OmniRoute repository.
Free models and free tier
No free tier and no subscription: every request is paid per token from a prepaid wallet at the model's current rate. A model is marked free (is_free: true) when its rate to you is zero: either its maker lists it at no charge, or a supplier sells it at zero and Cheaper Inference never charges above the supplier's rate. GET /v1/models?free=true returns the current set, a single entry today, and it changes. To spend less, sort the model catalog or GET /v1/models by price, send simple work to smaller models, and use the Optimization techniques that cut tokens on every request.
Finding model ids: speech, image, video, uncensored, dated builds
- Text-to-speech models:
GET /v1/models?type=speech. Image:type=image. Video:type=video. Embeddings:type=embedding. - Uncensored or abliterated models: search the Models page by name; every entry currently served is listed there.
The catalog changes daily, so GET /v1/models is the list; Models and pricing describes its fields and the other filters. A dated suffix such as deepseek-v4.1-flash-1017 is a pinned build: the undated id follows the maker's current pointer, the dated id keeps that build. A model listed yesterday and missing today was delisted or renamed, so read ids from the live list rather than hardcoding them.
Cheaper model for simple requests in Claude Code or per key
There is no per-task model map and no model group to point a key at. The model you send is the model that is served, so Claude Code uses the model its own settings select (the --model flag, ANTHROPIC_MODEL, or the ANTHROPIC_DEFAULT_*_MODEL variables), and Cursor, Codex and the other tools use the id chosen in their model picker.
Four controls change what is served without changing your code:
- The Simple-Query Model Routing technique under Optimization → Techniques routes eligible simple requests to a configured cheaper model for the whole workspace, and can be requested per request with the
X-CI-Route: autoheader. - The ranking request field orders the discounted routes for the chosen model by speed, discount or balance.
- Allowed models, per key on the API keys page, limits which ids a key may send.
- Routing priority, per key on the same page, sets the key's default ranking.
Check the resulting model and quality on your own tasks before relying on routing.
MCP server or CLI
The MCP server at https://api.cheaperinference.com/mcp supports browser sign-in and scoped API keys. It gives your coding tool account, usage and Prompt Studio capabilities. Use https://api.cheaperinference.com/v1 for OpenAI-compatible inference in your application.
Tools not in the integrations list
Any tool that lets you set a custom OpenAI-compatible provider works the same way:
- Base URL:
https://api.cheaperinference.com/v1 - API key: a
ci_live_key from the API keys page - Model: an exact id from
GET /v1/models
That covers Kilo Code, Antigravity, Zcode, CLIProxyAPI, Roblox Studio plugins that call OpenAI-style APIs, PowerShell or curl scripts, and VS Code extensions other than the ones with their own guide. Tools that call Anthropic-style APIs set ANTHROPIC_BASE_URL to https://api.cheaperinference.com with no path, as the Claude Code guide shows. Test with a one-line prompt and confirm the request appears on the Requests page. The ChatGPT app and other hosted chat products cannot be pointed at a different API. For a tool that is still unclear, use Ask us anything in the dashboard header.
API key not allowed to use model, or restricted IP addresses
Both messages come from the policy on the API key itself, which the key's owner sets on the API keys page:
- Allowed models: a key limited to some models answers
403/model_not_allowedfor every other id. - IP allowlist (addresses or ranges such as
203.0.113.0/24): requests from any other address answer403. - Expiry date: an expired key answers
401. - Requests per minute, Requests per day, Concurrent requests and Monthly budget (USD): each answers
429with aRetry-Afterheader and a message naming the limit. - Scopes are separate: a key without the Run inference scope answers
403to every inference request.
Open the key, widen or clear the field, and retry; a new key starts with no policy. If you do not own the key, ask the workspace owner or admin who created it.
Usage per key, tokens used and reports
- Reports: spend, savings and tokens for a date range, with an API key filter so one key's usage can be read on its own, and CSV, Excel and PDF exports.
- Requests: every request with its model, tokens, cost and savings receipt.
- Billing: the wallet and every charge and top-up.
- In code:
GET /v1/usage/requestsandGET /v1/usage/dailywith a key that has theusage:readscope; see Usage and billing API.
402 with money still in the wallet
Each request reserves funds before it runs, and a 402 means the wallet could not cover that reservation even though the balance is above zero. What is reserved depends on the request:
- A buffered request (
stream: false), and a stream whose output cannot be metered as it arrives, reserves the worst case: the input plus the largest output the request allows, at the model's rate. A highmax_tokensormax_output_tokensraises it. - A streamed text request is admitted with the input plus up to 2,048 output tokens, and the hold is extended while the answer streams. Lowering the output cap does not change its admission; the wallet has to cover the input plus roughly a thousand output tokens.
The reservation is released and only the actual usage is charged once the response completes. To clear it: top up, shorten the prompt, or for buffered requests lower the output cap or choose a cheaper model. Auto-recharge keeps the wallet above the level that triggers this.
FUNCTION_PAYLOAD_TOO_LARGE or 413
FUNCTION_PAYLOAD_TOO_LARGE is the hosting platform's name for a request body over 4.5 MB, measured on the wire. It appears most often when a file is embedded inline in the JSON body as base64 text, which makes it about a third larger than the file.
- Images: upload each one on its own with the temporary image upload endpoint (PNG, JPEG, WebP or GIF, up to 4 MB each) and reference the returned id in the message.
- PDFs: pass a URL instead of base64 data,
file_urlon Responses or aurlsource on Messages; see PDF input. - Audio: the transcription and translation endpoints take the file as multipart form data, which does not inflate it, but the 4.5 MB limit still applies to the whole request.
- Large text-only requests: compress the body with
Content-Encoding: gzip.
The limit is per request, not per account.
Cancelling a pending top-up
There is nothing to cancel, and nothing is charged until a payment clears. A top-up link opened from Ask us anything is a Stripe Checkout session: Stripe closes it on its own 24 hours after it was created, and the pending entry stops being payable. A card payment started on the Billing page uses the in-app card form instead; closing the form before confirming charges nothing, and the pending entry closes when the attempt is paid, fails or is cancelled. An underpaid crypto top-up is different: it stays in processing until Stripe expires it; use Ask us anything if the deposit has not appeared after a few days.
Dashboard language
The dashboard and the documentation are in English only, and there is no language setting. The Ask us anything assistant and the support team answer in the language you write in, and the API accepts prompts in any language the chosen model supports.