Quickstart

The endpoint is OpenAI-compatible. Point your existing client at https://cheap-tokens.vercel.app/v1 and send your Cheap Tokens key as the bearer token.

Change two lines

Keep your prompt formats, streaming logic and tool calls. Only the base URL and the key change.

from openai import OpenAI

client = OpenAI(
    base_url="https://cheap-tokens.vercel.app/v1",
    api_key="ct_live_...",
)

response = client.chat.completions.create(
    model="llama-3.1-8b-instruct",
    messages=[{"role": "user", "content": "Summarize this in two sentences: ..."}],
)

Streaming

Set stream: true and read standard OpenAI SSE chunks. The final chunk carries usage.

curl -N https://cheap-tokens.vercel.app/v1/chat/completions \
  -H "Authorization: Bearer ct_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama-3.1-8b-instruct",
    "stream": true,
    "messages": [{"role": "user", "content": "Summarize this in two sentences: ..."}]
  }'

A model list is available at GET https://cheap-tokens.vercel.app/v1/models with the same bearer key.

Region rules

  • Each key is pinned to one region, us or eu, chosen when the key is created.
  • A job only ever runs on a host inside the key's region.
  • If no host in the region claims the job within 8 s, same-region backstop capacity serves it and the receipt says so.
  • Sandbox keys get 25 lifetime test calls with at most 512 output tokens each, at no charge.

Error codes

CodeHTTPWhat it means
invalid_api_key401The bearer key is missing, revoked or unknown.
model_not_found404Slug not in the catalog, or a closed model (gpt-*, claude-*, gemini-*). The response lists the active slugs.
sandbox_limit402The sandbox key passed 25 test calls, or max_tokens is above 512.
insufficient_balance402Balance is below the job's maximum possible cost.
key_cap_reached402The key's monthly cap is reached. The response carries the cap and the reset date.
plan_inactive402A production key with no active paid plan.
concurrency_limit429Too many calls in flight for the plan. Retry-After: 2.
no_capacity_in_region503No host in the key's region picked the job up within 8 s and no backstop was configured. You are not charged.

First time here? Run a test call in the playground with a sandbox key, or browse the model prices.