Documentation
CheapLM gives you Claude-compatible API access through one API key. It works with both the Anthropic Messages API and the OpenAI Chat Completions API, so you can plug it into SDKs, editors, agents, and automation tools that support a custom base URL.
Base URL: https://api.cheaplm.xyz/v1
Models: Claude Opus 4.6, Opus 4.5, Sonnet 4.6, Sonnet 4.5, Sonnet 4, Haiku 4.5
Works with: Cursor, Claude Code, VS Code extensions, OpenAI SDK, Anthropic SDK, and cURL
Quick Start
Get started with CheapLM in minutes. First, get your API key from your account dashboard.
Anthropic format
curl https://api.cheaplm.xyz/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-cl-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 512,
"messages": [
{"role": "user", "content": "Say hello from CheapLM."}
]
}'OpenAI-compatible format
curl https://api.cheaplm.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-cl-YOUR_KEY" \
-d '{
"model": "claude-sonnet-4",
"messages": [
{"role": "user", "content": "Say hello from CheapLM."}
]
}'Authentication
Authenticate your requests using your API key in the x-api-key header or as a Bearer token in the Authorization header.
# Anthropic-compatible (recommended)
curl https://api.cheaplm.xyz/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-cl-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
# OpenAI-compatible
curl https://api.cheaplm.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-cl-YOUR_KEY" \
-d '{
"model": "claude-sonnet-4",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'Available Models
CheapLM supports all Claude models with both OpenAI and Anthropic naming conventions. Use the shorter IDs (with dots) for new integrations.
| Model | Model ID | Max Input | Max Output | Thinking | Vision |
|---|---|---|---|---|---|
| Claude Opus 4.6 | claude-opus-4.6 | 200K | 32K | Yes | Yes |
| Claude Opus 4.5 | claude-opus-4.5 | 200K | 32K | Yes | Yes |
| Claude Sonnet 4.6 | claude-sonnet-4.6 | 200K | 8192 | Yes | Yes |
| Claude Sonnet 4.5 | claude-sonnet-4.5 | 200K | 8192 | Yes | Yes |
| Claude Sonnet 4 | claude-sonnet-4 | 200K | 16K | Yes | Yes |
| Claude Haiku 4.5 | claude-haiku-4.5 | 200K | 8192 | No | Yes |
Pricing (USD per 1M tokens)
| Model | Input | Cache Write | Cache Read (90% off) | Output |
|---|---|---|---|---|
claude-opus-4.6 | $5.00 | $5.00 | $0.50 | $25.00 |
claude-opus-4.5 | $5.00 | $5.00 | $0.50 | $25.00 |
claude-sonnet-4.6 | $3.00 | $3.00 | $0.30 | $15.00 |
claude-sonnet-4.5 | $3.00 | $3.00 | $0.30 | $15.00 |
claude-sonnet-4 | $3.00 | $3.00 | $0.30 | $15.00 |
claude-haiku-4.5 | $1.00 | $1.00 | $0.10 | $5.00 |
Balance is in USD. Every $1 you pay buys $30 of API value. See Billing for pricing.
Messages API
Anthropic-compatible Messages endpoint. Supports streaming, system prompts, tools, and extended thinking.
https://api.cheaplm.xyz/v1/messagesCore request fields
modelrequiredModel ID: claude-opus-4.6, claude-sonnet-4.6, claude-haiku-4.5, etc.
messagesrequiredArray of message objects with role (user/assistant) and content (string or content blocks for multimodal)
max_tokensrequiredMaximum response tokens to generate
systemoptionalSystem prompt (string or content blocks)
temperatureoptionalSampling temperature 0-2 (default: 1.0)
toolsoptionalTool definitions for function calling
streamoptionalSet true for SSE streaming, false for normal response
thinkingoptionalExtended thinking: { "type": "enabled", "budget_tokens": 8192 }
Example request
curl https://api.cheaplm.xyz/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-cl-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 1024,
"system": "You are a concise coding assistant.",
"messages": [
{"role": "user", "content": "Explain recursion in one paragraph."}
]
}'Example response
{
"id": "msg_01XFD...",
"type": "message",
"role": "assistant",
"content": [
{ "type": "text", "text": "Recursion is when a function calls itself..." }
],
"model": "claude-sonnet-4",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 150,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}Key notes:
- Stable short model IDs (claude-sonnet-4) are recommended
- Streaming: set
stream: true - Non-streaming: set
stream: false - Per-key restrictions may block specific models, streaming, or IPs before the request reaches the model
Chat Completions (OpenAI-compatible)
Use this endpoint if you're integrating with tools that expect the OpenAI Chat Completions API. Note: model availability can differ from /v1/messages. If a model returns "not available", call GET /v1/models and pick one of the returned IDs.
curl https://api.cheaplm.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-cl-YOUR_KEY" \
-d '{
"model": "claude-sonnet-4.5",
"messages": [
{"role": "user", "content": "Hello!"}
],
"max_tokens": 256
}'Models
Use GET /v1/models to list available model IDs for OpenAI-compatible calls. For detailed pricing info, use GET /v1/models/info.
curl https://api.cheaplm.xyz/v1/models \
-H "Authorization: Bearer sk-cl-YOUR_KEY"Streaming
Streaming is supported on the Anthropic-compatible /v1/messages endpoint via Server-Sent Events (SSE). OpenAI-style streaming on /v1/chat/completions is not currently supported.
curl https://api.cheaplm.xyz/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-cl-YOUR_KEY" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 256,
"stream": true,
"messages": [{"role": "user", "content": "Write a haiku about databases"}]
}'Errors
Different endpoints return slightly different error shapes (OpenAI vs Anthropic compatibility). When in doubt: check HTTP status + the error field.
// Example (OpenAI-compatible)
{
"error": {
"message": "Model \"...\" is not available.",
"type": "invalid_request_error",
"code": 400
}
}Rate Limits
We apply anti-abuse rate limits on signup/login and may apply additional throttles for free-tier usage. Limits can change over time.
Extended Thinking
Extended thinking is supported by Opus and Sonnet models. Pass the thinking parameter to enable it:
{
"model": "claude-opus-4.6",
"max_tokens": 4096,
"thinking": {
"type": "enabled",
"budget_tokens": 8192
},
"messages": [{"role": "user", "content": "..."}]
}CheapLM filters out thinking blocks from streamed responses for client compatibility. The thinking budget is controlled entirely client-side — set higher values for more complex reasoning.
Python SDK
Use AWstore with either the official Anthropic SDK or the OpenAI SDK.
Anthropic SDK
pip install anthropicimport anthropic
client = anthropic.Anthropic(
api_key="sk-cl-YOUR_KEY",
base_url="https://api.cheaplm.xyz/v1"
)
message = client.messages.create(
model="claude-sonnet-4",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain recursion in one paragraph."}
]
)
print(message.content[0].text)Anthropic streaming
with client.messages.stream(
model="claude-sonnet-4",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku."}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)OpenAI SDK
pip install openaifrom openai import OpenAI
client = OpenAI(
api_key="sk-cl-YOUR_KEY",
base_url="https://api.cheaplm.xyz/v1"
)
response = client.chat.completions.create(
model="claude-sonnet-4",
messages=[{"role": "user", "content": "Hello from CheapLM"}]
)
print(response.choices[0].message.content)TypeScript SDK
Use AWstore with either the Anthropic TypeScript SDK or the OpenAI SDK.
Anthropic SDK
npm install @anthropic-ai/sdkimport Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "sk-cl-YOUR_KEY",
baseURL: "https://api.cheaplm.xyz/v1",
});
const message = await client.messages.create({
model: "claude-sonnet-4",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain TypeScript generics." }],
});
console.log(message.content[0].type === "text" ? message.content[0].text : "");Anthropic streaming
const stream = client.messages.stream({
model: "claude-sonnet-4",
max_tokens: 1024,
messages: [{ role: "user", content: "Write a poem." }],
});
for await (const event of stream) {
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
process.stdout.write(event.delta.text);
}
}OpenAI SDK
npm install openaiimport OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-cl-YOUR_KEY",
baseURL: "https://api.cheaplm.xyz/v1",
});
const response = await client.chat.completions.create({
model: "claude-sonnet-4",
messages: [{ role: "user", content: "Hello from CheapLM" }],
});
console.log(response.choices[0].message.content);cURL Examples
Anthropic API request
curl https://api.cheaplm.xyz/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-cl-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Write a fizzbuzz in Python."}
]
}'Anthropic API streaming
curl https://api.cheaplm.xyz/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-cl-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
--no-buffer \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 1024,
"stream": true,
"messages": [
{"role": "user", "content": "Tell me a short story."}
]
}'OpenAI-compatible request
curl https://api.cheaplm.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-cl-YOUR_KEY" \
-d '{
"model": "claude-sonnet-4",
"messages": [
{"role": "user", "content": "Hello from CheapLM"}
]
}'System endpoints
# List models
curl https://api.cheaplm.xyz/v1/models
# Model info and pricing
curl https://api.cheaplm.xyz/v1/models/info
# Health check
curl https://api.cheaplm.xyz/healthIDE Integration
CheapLM works with popular AI coding assistants. Configure them to use our API endpoint.
Claude Code
# Set environment variables
export ANTHROPIC_API_KEY="sk-YOUR_KEY"
export ANTHROPIC_BASE_URL="https://api.cheaplm.xyz"
# Or use config file
claude config set apiKey sk-YOUR_KEY
claude config set baseUrl https://api.cheaplm.xyz
# Then run
claudeCursor
- Open Cursor Settings → API keys
- Turn on OpenAI API Key → paste your CheapLM API key
- Turn on OpenAI Base URL → set to
https://api.cheaplm.xyz/v1
Recommended models: claude-opus-4.6, claude-sonnet-4.6, claude-haiku-4.5
Continue
Edit ~/.continue/config.json
{
"models": [
{
"title": "Claude Opus 4.6",
"provider": "anthropic",
"model": "claude-opus-4.6",
"apiKey": "sk-cl-YOUR_KEY",
"apiBase": "https://api.cheaplm.xyz/v1"
}
]
}Cline (VS Code)
Open the Cline extension settings and configure:
- Select Anthropic as the provider
- Set API Key:
sk-YOUR_KEY - Set Base URL:
https://api.cheaplm.xyz/v1 - Choose your model
Roo Code
Open Roo Code settings and configure:
- Select Anthropic as provider
- Enter your API key and base URL:
https://api.cheaplm.xyz - Select the model to use
OpenCode
export ANTHROPIC_API_KEY="sk-YOUR_KEY"
export ANTHROPIC_BASE_URL="https://api.cheaplm.xyz/v1"
opencodeAny Anthropic-Compatible Tool
For any tool that supports Anthropic API, set these two values:
- Base URL:
https://api.cheaplm.xyz/v1 - API Key:
sk-YOUR_KEY
Any OpenAI-Compatible Tool
For any tool that supports OpenAI API, set these two values:
- Base URL:
https://api.cheaplm.xyz/v1 - API Key:
sk-YOUR_KEY
Use model names like claude-sonnet-4, claude-opus-4.6, etc.
Reseller Transfer API
Transfer balance from your account to another user. Useful for resellers who buy API value in bulk and distribute it to clients.
Endpoint
POST /api/user/transfer
x-api-key: sk-cl-YOUR_API_KEY
Content-Type: application/json
{
"toUsername": "client-username",
"amount": 100
}Parameters
| Field | Type | Description |
|---|---|---|
toUsername | string | The recipient's CheapLM username |
amount | number | Dollar amount to transfer from your balance |
Response
{
"success": true,
"amount": 100,
"from": "reseller-account",
"to": "client-username",
"senderNewBalance": 450.50,
"receiverNewBalance": 100.00
}cURL Example
curl -X POST https://cheaplm.xyz/api/user/transfer \
-H "x-api-key: sk-cl-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"toUsername": "client-username", "amount": 100}'Important Notes
- Transfers are instant and atomic — either both accounts update or neither does
- You cannot transfer to yourself
- The recipient must already have a CheapLM account
- Amount is deducted from your balance and added to the recipient's
- Rate limited to prevent abuse
Error Responses
| Status | Error | Meaning |
|---|---|---|
400 | Insufficient balance | You don't have enough balance for this transfer |
404 | User not found | The recipient username doesn't exist |
400 | Cannot transfer to yourself | toUsername matches your own username |
401 | Unauthorized | Invalid or missing authentication token |
Simple, Transparent Pricing
Pick an amount. Every $1 buys you $30 of API value.
You pay
$10
You get
$305
Need help? Contact us at support@cheaplm.xyz