Quick start
- Create an account and top up your balance.
- Create an API key under Dashboard → API keys. It starts with
ct_live_and is shown once. - Set the base URL to
https://cheaptokens.pw/v1in your SDK or tool and send a request.
from openai import OpenAI
client = OpenAI(
base_url="https://cheaptokens.pw/v1",
api_key="YOUR_API_KEY",
)
reply = client.chat.completions.create(
model="gpt-6-luna",
messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://cheaptokens.pw/v1",
apiKey: "YOUR_API_KEY",
});
const reply = await client.chat.completions.create({
model: "gpt-6-luna",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(reply.choices[0].message.content);
curl https://cheaptokens.pw/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"messages": [{"role": "user", "content": "Hello!"}]
}'
# macOS / Linux export ANTHROPIC_BASE_URL="https://cheaptokens.pw" export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY" claude --model claude-sonnet-5-5 # Windows PowerShell $env:ANTHROPIC_BASE_URL = "https://cheaptokens.pw" $env:ANTHROPIC_AUTH_TOKEN = "YOUR_API_KEY" claude --model claude-sonnet-5-5
Authentication
Send your key as a bearer token. The Anthropic-style x-api-key header is also accepted.
Authorization: Bearer ct_live_...
Keep keys on your server. Don't put them in browser code, mobile apps or public repositories. If a key leaks, disable it in the dashboard and create a new one.
Endpoints
| Endpoint | Format | Use it for |
|---|---|---|
POST /v1/chat/completions | OpenAI Chat Completions | Every text model |
POST /v1/responses | OpenAI Responses | GPT models, Codex, agent tools |
POST /v1/messages | Anthropic Messages | Claude models, Claude Code |
POST /v1/images/generations | OpenAI Images | Create an image |
POST /v1/images/edits | OpenAI Images (multipart) | Edit images |
GET /v1/models | OpenAI Models | List available model IDs |
Which endpoints each model supports is listed on the models page.
Claude Messages
Claude models can be called in the native Anthropic format. Point the Anthropic SDK at https://cheaptokens.pw (without /v1).
import anthropic
client = anthropic.Anthropic(
base_url="https://cheaptokens.pw",
api_key="YOUR_API_KEY",
)
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)Streaming
Set "stream": true. Responses are sent as server-sent events in the same format as the original API. For Chat Completions we add a final usage chunk to the stream so the request can be billed exactly; the official SDKs handle it automatically.
Images
curl https://cheaptokens.pw/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-2.5-sunburst", "prompt": "A lighthouse at dawn, watercolor"}'Images are billed at a flat price per image, shown on the models page. The response contains a PNG as base64 in data[0].b64_json. To edit an image, send multipart/form-data to /v1/images/edits with model, prompt and one or more image files (up to 16 files, 25 MB each).
Tool setup
Every tool needs the same three things: the base URL, your API key and a model ID. Pick your tool for exact steps, or use the setup wizard to get snippets for your operating system and model.
| Setting | Value | Used by |
|---|---|---|
| OpenAI base URL | https://cheaptokens.pw/v1 | Codex, Cursor, Cline, Roo Code, Continue, OpenCode, Aider and most others |
| Anthropic base URL | https://cheaptokens.pw | Claude Code and other tools that speak the Claude Messages format |
| API key | ct_live_... | All tools |
Billing
- Your balance is prepaid and held in US dollars. Top up with crypto under Dashboard → Billing.
- Each request costs
(input tokens × input price + output tokens × output price) ÷ 1,000,000. Both prices are on the models page. - When a request starts we hold an estimate of its cost. When it finishes we charge the exact amount and release the rest.
- Failed requests are not charged.
- If a stream is cut off before the model reports usage, the request is billed from an estimate and marked as estimated in your history.
- You can set a spend limit on any API key.
Rate limits
Each API key can send a limited number of requests per minute. Above the limit you get HTTP 429 with rate_limit_exceeded; wait a few seconds and retry. Contact [email protected] if you need a higher limit.
Errors
| HTTP | Code | What to do |
|---|---|---|
| 400 | invalid_request | The model rejected the request. Check the parameters and message format. |
| 400 | context_length_exceeded | Shorten the input or lower max_tokens. |
| 401 | invalid_api_key | Check the key and that it is enabled. |
| 402 | insufficient_quota | Top up your balance. |
| 402 | key_limit_reached | Raise or remove the key's spend limit. |
| 404 | model_not_found | Use a model ID from /v1/models. |
| 429 | rate_limit_exceeded | Slow down and retry. |
| 502 | upstream_error | The model provider failed. Retry. |
| 503 | provider_unavailable | The model is temporarily unavailable. Retry shortly. |
Errors on /v1/messages use the Anthropic error format; all other endpoints use the OpenAI format. Include the x-request-id response header when you contact support.