Cheaper InferenceA Keak company

Documentation

Build with Cheaper Inference

Everything you need to create a key, choose a model, send requests, and understand billing.

Quick start

  1. Create an account.
  2. Add at least $5 to your wallet. Your first successful funding adds $10 in bonus credit.
  3. Create an API key from the dashboard and copy it once.
  4. Set your OpenAI SDK baseURL to the endpoint below.
  5. Put a supported model name in the model field.
  6. Send your first request and review usage in History.

Base URL

https://api.cheaperinference.com/v1

Authentication

Authorization: Bearer ir_live_YOUR_API_KEY

cURL chat completion

curl https://api.cheaperinference.com/v1/chat/completions \
  -H "Authorization: Bearer ir_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4.6",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

cURL Responses request

curl https://api.cheaperinference.com/v1/responses \
  -H "Authorization: Bearer ir_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. Requests must use store: false. Stored responses, previous_response_id, conversations, background mode, and provider-hosted web or file search are not supported.

JavaScript SDK

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "ir_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!" }]
});

Python SDK

from openai import OpenAI

client = OpenAI(
    api_key="ir_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!"}],
)

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.

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"
}

Kimi K3 reasoning effort

Use reasoning.effort to control how much reasoning Kimi K3 performs. Kimi K3 currently supports low, high, and max. medium is not a native effort level for this model. Set the effort explicitly when consistent behavior matters.

curl https://api.cheaperinference.com/v1/chat/completions \
  -H "Authorization: Bearer ir_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "messages": [{"role": "user", "content": "Solve this carefully."}],
    "reasoning": {"effort": "high"}
  }'

Lower effort is faster and uses fewer output tokens; higher effort gives the model more room for difficult work. Reasoning tokens count as output usage and are billed at the model's output-token rate.

Image generation

curl https://api.cheaperinference.com/v1/images/generations \
  -H "Authorization: Bearer ir_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-pro",
    "prompt": "A clean product render of a banana invoice",
    "n": 1,
    "size": "1024x1024",
    "resolution": "1K",
    "quality": "high",
    "response_format": "url"
  }'

Use /v1/images/generations for every model whose /v1/models entry has type: "image" or capabilities.image_generation: true, including grok-imagine. Image-generation models are not accepted by /v1/responses, /v1/chat/completions, or /v1/completions.

Example: Grok Imagine

curl https://api.cheaperinference.com/v1/images/generations \
  -H "Authorization: Bearer ir_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine",
    "prompt": "A cinematic city at night",
    "n": 1,
    "response_format": "url"
  }'

Nano Banana image output is billed using fixed output-token amounts for the selected resolution. Nano Banana 2 uses 747 tokens at 0.5K, 1,120 at 1K, 1,680 at 2K, and 2,520 at 4K. Nano Banana Pro uses 1,120 tokens at 1K or 2K and 2,000 at 4K.

Vision input

Vision-capable chat models accept OpenAI image_url parts and Anthropic-style base64 image blocks. Use up to 10 images, 5MB per image, 23MB total decoded base64 image data, and a complete serialized JSON body no larger than 31MiB.

Streaming

Models marked Streaming accept "stream": true on 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 ir_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"}
        }
      ]
    }]
  }'

Prompt caching

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.

Temporary vision uploads

For larger base64 payloads, upload each image separately. The private file ID expires after one hour and keeps the forwarded JSON body small. Copy the returned message_content object into the request, then delete the upload early when it is no longer needed.

curl https://api.cheaperinference.com/v1/uploads \
  -H "Authorization: Bearer ir_live_YOUR_API_KEY" \
  -F "file=@tile.png"
curl https://api.cheaperinference.com/v1/chat/completions \
  -H "Authorization: Bearer ir_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "What is shown here?"},
        {
          "type": "image_file",
          "image_file": {"file_id": "img_RETURNED_ID"}
        }
      ]
    }]
  }'
curl -X DELETE \
  https://api.cheaperinference.com/v1/uploads/img_RETURNED_ID \
  -H "Authorization: Bearer ir_live_YOUR_API_KEY"

Available models and pricing

Copy the exact model ID into the model field. Prices and capabilities below are loaded from the live catalog.

Loading models...

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.

A fallback route can have a different rate from the first route. The final customer charge follows the route that successfully serves the request, but it will never exceed 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. Review the pricing and savings history across models, or open an individual model page for its hourly observations over the last 24 hours or 30 days. The exact amount charged for each completed request is available in your dashboard History.

Model catalog API

Use your API key to retrieve currently available models and their current catalog rates. A fallback route can change the final rate for a request, subject to the direct-list-price ceiling above. Filter by type, vision, 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 ir_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.

The catalog identifies modality, endpoint, vision, reasoning, streaming, and image generation 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.

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 responses include the model's token usage. Provider cost and private routing metadata are removed before the response is returned to you.

Cheaper Inference does not store prompt or response bodies in its application database. 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 Trust Center for current security and data-handling information.

Production checklist

  • Load your API key from a server-side environment variable.
  • Use GET /v1/models to 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, and 5xx responses with exponential backoff.
  • Do not retry 400, 401, 402, or 413 without correcting the request. For 402, add funds before retrying.
  • Treat an interrupted stream as incomplete and retry the entire request.
  • Review token usage, spend, and failures in History before increasing traffic.

For the generated public request, response, authentication, and error schemas, open the API reference. Check Status before escalating an availability issue.

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.

Common errors

API failures use an OpenAI-compatible envelope. Use error.code for program logic and keep error.message for logs and operator context.

{
  "error": {
    "message": "Invalid API key.",
    "type": "authentication_error",
    "param": null,
    "code": "invalid_api_key"
  }
}
  • 400 Unsupported model, endpoint, or invalid request body.
  • 401 Invalid or missing API key.
  • 402 / insufficient_balance: add funds in Billing, then retry the request.
  • 403 The API key does not allow the model, client IP, or request.
  • 413 Request body or vision payload is too large.
  • 422 A query or typed request parameter failed validation.
  • 429 A rate, concurrency, or quota limit was reached. Respect the Retry-After response header before retrying.
  • 502 Provider or transport failure after eligible routes were exhausted.
  • 503 No eligible provider route is currently available.
  • 504 The serving provider timed out.

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.
  • Use History to audit usage and spend.

Support

Use the Contact tab for billing, API, or account questions. We typically answer in under 12h.