# Cheaper Inference > A wallet-backed, OpenAI- and Anthropic-compatible inference API. Point an existing SDK at it, keep your code, and pay less per request through routing, caching and prompt optimization. The API is served from https://api.cheaperinference.com/v1. Authenticate with `Authorization: Bearer ci_live_...` or `x-api-key: ci_live_...`; both are accepted on every endpoint. Requests are billed against a prepaid wallet, and every response carries a `cheaper_inference` object saying what it cost and what it saved. This file is the index. The same documentation is available three other ways: - Full text, every section inline: https://cheaperinference.com/llms-full.txt - Searchable JSON: `GET https://api.cheaperinference.com/v1/docs?q=...`; any valid API key, no scope required. Omit `q` for the table of contents. - Human documentation: https://cheaperinference.com/docs, and the API reference at https://cheaperinference.com/api-reference Entries below read `- [Title](link) `id`: summary; keywords`. The `id` is the same handle `/v1/docs` returns and llms-full.txt marks each section with. ## Getting started - [Quickstart](https://cheaperinference.com/docs#start) `quickstart`: CheaperInference is a drop-in OpenAI-compatible API. Point OpenAI-compatible SDKs at https://api.cheaperinference.com/v1 and use a CheaperInference key instead of your provider key.; start, setup, base url, first request, curl, swap - [API keys](https://cheaperinference.com/docs#api-keys) `api-keys`: Keys are created in the dashboard under API keys. New keys begin ci_live_; existing customer keys beginning ir_live_ remain valid after the platform cutover.; key, token, auth, bearer, revoke, scopes, ci_live, ir_live ## API - [Chat completions](https://cheaperinference.com/docs#chat) `chat-completions`: POST https://api.cheaperinference.com/v1/chat/completions accepts the standard OpenAI chat request body: model, messages, temperature, max_tokens, tools and so on. Streaming works unchanged; set "stream": true and read server-sent events exactly as you would from OpenAI.; chat, completions, messages, openai, stream, sse - [Text completions](https://cheaperinference.com/docs#completions) `text-completions`: POST https://api.cheaperinference.com/v1/completions serves the legacy prompt-style interface for older clients. New integrations should use chat completions instead; this endpoint exists for compatibility with code that has not migrated.; completions, prompt, legacy - [Anthropic Messages API](https://cheaperinference.com/docs#messages) `messages`: POST https://api.cheaperinference.com/v1/messages implements the Anthropic Messages surface, and POST https://api.cheaperinference.com/v1/messages/count_tokens returns token counts without running inference. This is what makes Claude Code and other Anthropic-native clients work against CheaperInference with no code…; anthropic, claude, messages, count_tokens, x-api-key - [Responses API](https://cheaperinference.com/docs#responses) `responses`: POST https://api.cheaperinference.com/v1/responses implements the OpenAI Responses API, which is what Codex speaks. Configure Codex with wire_api = "responses" and point base_url at https://api.cheaperinference.com/v1.; responses, codex, openai responses, wire_api - [Listing models](https://cheaperinference.com/docs#models) `models`: GET https://api.cheaperinference.com/v1/models returns every model currently available with its id, capabilities and current pricing. Use it to discover model ids rather than hardcoding them, since the catalog moves.; models, catalog, list, available, ids - [Pricing change feed](https://cheaperinference.com/docs#models-and-pricing) `pricing-changes`: GET https://api.cheaperinference.com/v1/pricing/changes?since=... returns the latest customer-facing model object for each catalog row changed at or after the required RFC 3339 since timestamp; a removal has change_type "removed" and model null. Follow next_cursor while has_more is true, keeping the original since on…; pricing, pricing/changes, price feed, poll, pricing_version, since, cache pricing - [Price ceiling](https://cheaperinference.com/docs#price-ceiling) `price-ceiling`: Add min_discount_percent (0 to 99.99) to a chat completions, completions, messages or responses request to set the minimum discount off list price the request will accept. The gateway checks the value against our published list price, not a price a source claims, and strips the field before forwarding so no upstream…; price ceiling, min_discount_percent, discount, max price, cap, models/supply, min_discount_unavailable - [Zero data retention](https://cheaperinference.com/docs#zero-data-retention) `zdr`: Add zdr: true to a chat completions, completions, messages or responses request to route only through providers that support a zero-data-retention policy. They do not keep your prompts or responses and do not train on them.; zdr, zero data retention, privacy, no retention, data protection, zdr_capacity_unavailable - [Ranking: speed, discount, balance](https://cheaperinference.com/docs#ranking) `ranking`: Add ranking to a chat completions, completions, messages or responses request to choose the order the gateway tries the discounted sources: "discount" (cheapest first, the historic default), "speed" (highest recent speed score first, cost breaking ties), or "balance" (the default: speed score times discount, highest…; ranking, speed, discount, balance, fastest, cheapest, route order, invalid_ranking - [Image generation and editing](https://cheaperinference.com/docs#images-and-vision) `image-generation`: POST https://api.cheaperinference.com/v1/images/generations creates images from a prompt (not Chat Completions); each data entry carries a URL or base64 image data. POST https://api.cheaperinference.com/v1/images/edits edits images, and only works with a model whose capabilities.image_edit is true.; image, images, generate image, edit image, images/generations, images/edits, mask, nano-banana - [Video generation](https://cheaperinference.com/docs#images-and-vision) `video-generation`: POST https://api.cheaperinference.com/v1/videos/generations creates video from a prompt. Generation is buffered while the provider completes the job, so use a client timeout of at least five minutes; the response carries a videos array with URLs or base64 MP4 data.; video, videos, generate video, videos/generations, seedance, audio - [Response feedback](https://cheaperinference.com/docs#feedback) `feedback`: POST https://api.cheaperinference.com/v1/feedback attaches a 1-to-5 score and an optional comment to a previous request, identified by its request id. Feedback is what turns an A/B experiment from a cost comparison into a quality comparison, so send it if you are running experiments.; feedback, score, rating, quality, experiment - [Request and response headers](https://cheaperinference.com/docs#headers) `headers`: Every response carries attribution headers: x-ci-request-id identifies the request for feedback and support, x-ci-tokens-saved is the number of tokens removed before billing, x-ci-saved-usd is the dollar amount saved against list price, and x-ci-techniques lists which optimizations fired. On the request side,…; headers, x-ci, savings, attribution, request id - [Usage reporting](https://cheaperinference.com/docs#usage) `usage-api`: GET https://api.cheaperinference.com/v1/usage/requests returns per-request usage with cursor pagination, and GET https://api.cheaperinference.com/v1/usage/daily returns daily aggregates. Both accept a date range.; usage, spend, reporting, daily, requests, export, cache, cache hit, cache percentage, cached tokens, prompt cache - [Checking your balance](https://cheaperinference.com/docs#account) `balance-api`: GET https://api.cheaperinference.com/v1/account/balance returns the workspace wallet: balance_usd, available_usd, reserved_usd, plus auto_recharge_enabled, threshold_usd and recharge_amount_usd. Spend against available_usd, not balance_usd; the difference is money already held for requests that have not settled, so…; balance, credit, wallet, funds, top up, auto-recharge, available, reserved, how much left - [Error reference](https://cheaperinference.com/docs#errors) `errors`: Errors use OpenAI's shape, so existing error handling works unchanged. 401 means the key is missing, malformed or revoked.; error, 402, 401, 429, 500, insufficient, failed - [Rate limits and retries](https://cheaperinference.com/docs#limits) `rate-limits`: Eligible upstream failures are retried before the error reaches your code. Retry 429 and 5xx responses with exponential backoff; do not retry 4xx other than 429, since the request will fail the same way.; rate limit, 429, retry, backoff, timeout, concurrency ## Billing - [How billing works](https://cheaperinference.com/dashboard/billing) `wallet`: Billing is a prepaid wallet, not a subscription and not an invoice. Each request reserves its worst-case cost up front, then refunds the unused part once the actual token counts are known, so a request can never overdraw the wallet.; wallet, balance, prepaid, credit, charge, cost - [Topping up](https://cheaperinference.com/dashboard/billing) `topping-up`: Top up on the Billing page. The card form is collected in-app by Stripe; there is no redirect to a hosted checkout page.; top up, topup, add funds, card, payment, stripe - [Auto-recharge](https://cheaperinference.com/dashboard/billing) `auto-recharge`: Auto-recharge charges your saved card once when the settled wallet balance reaches a threshold you set. It is the way to stop production traffic failing with 402 when the balance runs out.; auto recharge, automatic, threshold, top up, 402 - [Pricing](https://cheaperinference.com/#pricing) `pricing`: Curated models are billed at a flat 30% below the verified provider list price. Models outside the curated catalog route at the cheapest live seller ask plus a routing markup, and carry no list-price discount claim because the official list price is unknown.; price, cost, discount, 30%, markup, list price ## Optimization - [Choose your starting point](https://cheaperinference.com/docs/optimization#optimization) `optimization`: Optimization brings Prompt Studio, Experiments, and Techniques together. They are connected starting points, not mandatory onboarding steps.; optimization, overview, start, workflow, workspace, scope - [Prompt Studio: prepare and run](https://cheaperinference.com/docs/optimization#prompt-studio) `prompt-studio`: Use Prompt Studio when you have a prompt to improve for a specific task and model. Start with a representative task and define what a useful answer must include.; prompt studio, rewrite, system prompt, user prompt, target model, candidate evaluations, billing - [Review, reuse, and test a Studio result](https://cheaperinference.com/docs/optimization#prompt-studio-results) `prompt-studio-results`: A completed run supplies a candidate prompt to review. Its optimizer scores describe the optimization run; they are not measured production savings or a guarantee of quality on your traffic.; prompt studio, scores, history, copy, handoff, optimized prompt, variables - [Experiments: create control and treatments](https://cheaperinference.com/docs/optimization#experiments) `experiments`: Compare variants using test requests or application traffic sent to an experiment. The workflow is create variants, send requests, review cost, tokens, and feedback, then choose a winner.; experiments, ab test, variants, control, treatment, weights, sticky, random - [Send test requests and application traffic](https://cheaperinference.com/docs/optimization#experiment-traffic) `experiment-traffic`: An experiment needs requests before it can provide evidence. Start with the detail page's Test a variant panel, then use its integration examples to connect the application traffic you want to compare.; experiments, traffic, headers, integration, test request, X-CI-Experiment, X-CI-End-User - [Interpret results and choose a winner](https://cheaperinference.com/docs/optimization#experiment-results) `experiment-results`: Compare cost and token usage alongside task quality. Zero requests means no evidence yet.; experiments, feedback, quality, cost, tokens, promote, winner, pause, resume - [Techniques: review and configure defaults](https://cheaperinference.com/docs/optimization#techniques) `techniques`: Techniques contains optional request optimizations. Available means an implementation can run on eligible requests.; techniques, available, enabled, default, workspace, permissions, owner, admin, safe compression - [Understand technique tradeoffs](https://cheaperinference.com/docs/optimization#technique-tradeoffs) `technique-tradeoffs`: Savings depend on the workload, request eligibility, and technique configuration. Use the live catalog for current availability.; techniques, json, whitespace, context, output budget, concise, routing, cache, risk - [Exact-match response caching](https://cheaperinference.com/docs/optimization#caching) `caching`: Exact-match response caching can reuse an eligible identical deterministic request from the account's private cache instead of making another provider call. It is an optional technique, separate from a provider's prompt-cache usage.; cache, cached, repeat, identical, deterministic, techniques - [Research radar and troubleshooting](https://cheaperinference.com/docs/optimization#technique-research-radar) `technique-research-radar`: Research radar contains source-linked ideas that are not available to run. Discovery or review does not enable a technique.; research, radar, evidence, sources, implementation, unavailable, troubleshooting ## Integrations - [Cursor](https://cheaperinference.com/docs/integrations#cursor) `cursor`: In Cursor, open Settings → Models → OpenAI API Key → Override OpenAI Base URL. Set the base URL to https://api.cheaperinference.com/v1 and the key to your CheaperInference API key.; cursor, editor, ide, override base url - [Claude Code](https://cheaperinference.com/docs/integrations#claude-code) `claude-code`: Set ANTHROPIC_BASE_URL to https://api.cheaperinference.com and ANTHROPIC_API_KEY to your CheaperInference API key, then run claude. No Anthropic account is involved.; claude code, anthropic, cli, ANTHROPIC_BASE_URL - [Codex](https://cheaperinference.com/docs/integrations#codex) `codex`: Add CheaperInference as a model provider in ~/.codex/config.toml with wire_api = "responses", base_url = "https://api.cheaperinference.com/v1", and env_key = "CHEAPER_INFERENCE_API_KEY". Then export that variable with your CheaperInference API key. env_key holds the NAME of the environment variable, not the key…; codex, config.toml, model_provider, responses, env_key, missing environment variable - [OpenClaw](https://cheaperinference.com/dashboard/integrations#openclaw) `openclaw`: OpenClaw talks to CheaperInference as a custom Chat Completions provider. In your OpenClaw configuration, add a "cheaper-inference" provider with baseUrl set to https://api.cheaperinference.com/v1, api set to "openai-completions", and apiKey read from CHEAPER_INFERENCE_API_KEY.; openclaw, agent platform, openai-completions - [Hermes Agent](https://cheaperinference.com/dashboard/integrations#hermes) `hermes`: Run "hermes model", choose "Custom endpoint (self-hosted / VLLM / etc.)", enter https://api.cheaperinference.com/v1 as the base URL, paste your CheaperInference API key, and pick "Chat Completions" as the API mode. For a manual setup, put CHEAPER_INFERENCE_API_KEY in ~/.hermes/.env and add a custom_providers block in…; hermes, hermes agent, custom endpoint, vllm - [OpenCode](https://cheaperinference.com/dashboard/integrations#opencode) `opencode`: Configure OpenCode with an OpenAI-compatible custom provider. Open /connect, choose Other, enter cheaper-inference, and add your key.; opencode, openai-compatible, @ai-sdk/openai-compatible - [OpenWork](https://cheaperinference.com/dashboard/integrations#openwork) `openwork`: OpenWork is an OpenCode-powered desktop agent that reads OpenCode provider config from each workspace's opencode.json. Add a "cheaper-inference" provider there with baseURL pointing at https://api.cheaperinference.com/v1 and env: ["CHEAPER_INFERENCE_API_KEY"] (the env array declares the key; OpenWork stores the…; openwork, desktop agent, opencode schema - [Open WebUI](https://cheaperinference.com/dashboard/integrations#open-webui) `open-webui`: In Open WebUI, open Admin Settings → Connections → OpenAI → Add Connection. Enter https://api.cheaperinference.com/v1 as the base URL and your CheaperInference API key, then save.; open webui, openwebui, chat interface - [Cline](https://cheaperinference.com/dashboard/integrations#cline) `cline`: In Cline (VS Code), choose OpenAI Compatible as the API provider, set the Base URL to https://api.cheaperinference.com/v1, paste your CheaperInference API key, and enter an exact model id such as gpt-5.4. Advanced model settings (image support, tool use, context/output limits) are model-specific; enable them only…; cline, vs code, openai compatible - [Aider](https://cheaperinference.com/dashboard/integrations#aider) `aider`: Aider is a terminal pair programmer that reads OpenAI-compatible envs. Export OPENAI_API_BASE=https://api.cheaperinference.com/v1 and OPENAI_API_KEY to your CheaperInference API key, then run "aider --model openai/gpt-5.4".; aider, pair programmer, openai/, openai_api_base - [LibreChat](https://cheaperinference.com/dashboard/integrations#librechat) `librechat`: Add CHEAPER_INFERENCE_API_KEY to LibreChat's .env, then add a custom endpoint in librechat.yaml with name "Cheaper Inference", baseURL https://api.cheaperinference.com/v1, apiKey read from that env var, and models.fetch true so it discovers ids automatically. Restart LibreChat.; librechat, team chat, custom endpoint - [Continue](https://cheaperinference.com/dashboard/integrations#continue) `continue`: Add a model to Continue's config.yaml with provider: openai, apiBase pointing at https://api.cheaperinference.com/v1, and apiKey set to your CheaperInference API key. Keep useResponsesApi: false so Continue uses the broadly compatible Chat Completions path; the Responses endpoint is targeted at Codex workloads, not…; continue, continue.dev, ide assistant - [OpenAI Node SDK](https://cheaperinference.com/dashboard/integrations#framework-node) `framework-node`: Use the official OpenAI Node SDK unchanged. Construct new OpenAI({ apiKey: process.env.CHEAPER_INFERENCE_API_KEY, baseURL: "https://api.cheaperinference.com/v1" }), then call client.chat.completions.create as normal.; openai, node, javascript, typescript, sdk - [OpenAI Python SDK](https://cheaperinference.com/dashboard/integrations#framework-python) `framework-python`: Use the official OpenAI Python SDK unchanged. Construct OpenAI(api_key=os.environ["CHEAPER_INFERENCE_API_KEY"], base_url="https://api.cheaperinference.com/v1"), then call client.chat.completions.create.; openai, python, sdk - [Vercel AI SDK](https://cheaperinference.com/dashboard/integrations#framework-vercel) `framework-vercel`: Use @ai-sdk/openai-compatible. Call createOpenAICompatible({ name: "cheaper-inference", apiKey: process.env.CHEAPER_INFERENCE_API_KEY, baseURL: "https://api.cheaperinference.com/v1" }), then pass cheaperInference("gpt-5.4") to generateText or streamText.; vercel, ai sdk, @ai-sdk/openai-compatible - [LangChain](https://cheaperinference.com/dashboard/integrations#framework-langchain) `framework-langchain`: Use langchain_openai's ChatOpenAI. Construct ChatOpenAI(model="gpt-5.4", api_key=os.environ["CHEAPER_INFERENCE_API_KEY"], base_url="https://api.cheaperinference.com/v1") and invoke it as normal.; langchain, langchain_openai, chatopenai - [OpenAPI spec](https://cheaperinference.com/api-reference) `openapi`: A machine-readable OpenAPI 3.1 document is served at https://api.cheaperinference.com/openapi.json and checked in at docs/api/openapi.json. Use it to generate a typed client rather than hand-writing request shapes.; openapi, spec, schema, swagger, generate client ## Troubleshooting - [Requests failing with 402](https://cheaperinference.com/dashboard/billing) `troubleshoot-402`: A 402 means the wallet could not cover the request's worst-case reservation. Top up on the Billing page, and turn on auto-recharge so it does not recur.; 402, insufficient, balance, declined, stopped working - [Requests failing with 401](https://cheaperinference.com/dashboard/keys) `troubleshoot-401`: A 401 means the key is missing, malformed or revoked. Check the key is sent as "Authorization: Bearer ..." and has not been revoked on the API keys page.; 401, unauthorized, invalid key, revoked, auth - [Getting 404 from an agent or editor](https://cheaperinference.com/docs/integrations#verify) `troubleshoot-404`: Almost always a base-URL suffix problem. Clients differ: Cursor and Codex want https://api.cheaperinference.com/v1 because they append the path after it, while Claude Code wants https://api.cheaperinference.com because it appends /v1/messages itself.; 404, not found, base url, v1, double v1 - [Savings look lower than expected](https://cheaperinference.com/dashboard/requests) `troubleshoot-no-savings`: Open the request on the Requests page and read its savings receipt, which itemises the provider list price, the marketplace discount and every optimization that fired. Two common explanations: the model is a marketplace-only model, which carries no list-price discount because the official list price is unknown; or…; savings, no savings, attribution, expected, lower