CheapRouter API

CheapRouter API Documentation

A compact reference for the public CheapRouter API. The inference base endpoint is https://api.cheaprouter.dev/v1.

Base URL

https://api.cheaprouter.dev/v1

Append endpoint paths after /v1.

Authentication

Bearer cheaprouter_...

Use the same API key from your account.

Catalog

GET /models

List models and supported APIs.

Credits

GET /credits

Check account credits and total usage.

Quick Start

Create a key in the dashboard, save it as an environment variable, and send your first OpenAI-compatible request.

shell
export CHEAPROUTER_API_KEY="cheaprouter_your_key"

curl https://api.cheaprouter.dev/v1/chat/completions \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-mini",
    "messages": [
      { "role": "user", "content": "Reply with exactly: ok" }
    ],
    "max_tokens": 16
  }'

Endpoints

All paths are relative to the base URL. Before generation, fetch /models and choose a model that supports the API you need.

MethodPathUse
GET/modelsAvailable models, pricing, modalities, endpoints
GET/models/countAvailable model count
GET/models/{provider}/{model}/endpointsParameters and streaming support for one model
GET/providersLogical public providers without upstream details
GET/creditsCurrent account credits and total usage
POST/keysCreate a new account API key, including anonymous keys and spend limits
GET/keysList active account keys without raw key values
PATCH/keys/{key_id}/limitSet or clear the spend limit for an account key
DELETE/keys/{key_id}Revoke an account key; requests with that key stop immediately
POST/chat/completionsOpenAI-style chat completions, including streaming and audio input for compatible models
POST/responsesOpenAI Responses API for text tasks
POST/messagesAnthropic-style Messages API
POST/images/generationsImage generation for image-capable models
POST/images/editsImage editing through JSON data URLs or multipart uploads
POST/videos/submitCreate a video task for a video model
GET/videos/tasks/{task_id}Check video task status and outputs

Examples

Model Catalog

Fetch available models and supported endpoints.

shell
export CHEAPROUTER_API_KEY="cheaprouter_your_key"

curl https://api.cheaprouter.dev/v1/models \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY"

Chat Completions

Minimal OpenAI-compatible request.

shell
export CHEAPROUTER_API_KEY="cheaprouter_your_key"

curl https://api.cheaprouter.dev/v1/chat/completions \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-mini",
    "messages": [
      { "role": "user", "content": "Reply with exactly: ok" }
    ],
    "max_tokens": 16
  }'

OpenAI SDK

The same chat endpoint through the official JS SDK.

javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.CHEAPROUTER_API_KEY,
  baseURL: 'https://api.cheaprouter.dev/v1',
});

const completion = await client.chat.completions.create({
  model: 'openai/gpt-5.4-mini',
  messages: [{ role: 'user', content: 'Reply with exactly: ok' }],
  max_tokens: 16,
});

console.log(completion.choices[0]?.message?.content);

Audio Input

Audio inside Chat Completions for models with input_modalities=audio.

shell
export CHEAPROUTER_API_KEY="cheaprouter_your_key"
export AUDIO_BASE64="$(base64 -w 0 ./sample.wav)"

curl https://api.cheaprouter.dev/v1/chat/completions \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.1-pro-preview",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Describe this audio in one sentence." },
          {
            "type": "input_audio",
            "input_audio": { "data": "'"$AUDIO_BASE64"'", "format": "wav" }
          }
        ]
      }
    ],
    "max_tokens": 80
  }'

Responses API

Text Responses request.

shell
curl https://api.cheaprouter.dev/v1/responses \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-mini",
    "input": "Reply with exactly: ok",
    "max_output_tokens": 16
  }'

Messages API

Anthropic-style message format.

shell
curl https://api.cheaprouter.dev/v1/messages \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "max_tokens": 16,
    "messages": [
      { "role": "user", "content": "Reply with exactly: ok" }
    ]
  }'

Images API

Image generation through the CheapRouter API endpoint.

shell
curl https://api.cheaprouter.dev/v1/images/generations \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gemini-3-pro-image-preview",
    "prompt": "A minimal product photo on a white background",
    "n": 1,
    "size": "1024x1024"
  }'

Image Edits API

Image editing through an OpenAI-compatible endpoint.

shell
curl https://api.cheaprouter.dev/v1/images/edits \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -F "model=openai/gpt-image-2-edit" \
  -F "image[]=@input.png" \
  -F "prompt=Replace the background with a clean studio backdrop"

Key Management

Create, list, limit, and revoke keys through the API endpoint.

shell
curl https://api.cheaprouter.dev/v1/keys \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production worker",
    "is_anonymous": false,
    "spend_limit": { "amount_usd": "25", "period": "monthly" }
  }'

curl https://api.cheaprouter.dev/v1/keys \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY"

curl https://api.cheaprouter.dev/v1/keys/{key_id}/limit \
  -X PATCH \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "spend_limit": null }'

curl https://api.cheaprouter.dev/v1/keys/{key_id} \
  -X DELETE \
  -H "Authorization: Bearer $CHEAPROUTER_API_KEY"