Documentation
LowCostRouter accepts the same requests as the OpenAI, Anthropic and Gemini APIs. Change the base URL, use your LowCostRouter key and keep the rest of your code.
Quick start
- Sign in with Telegram, or with an email and password.
- Create an API key in the dashboard. You can do it before topping up.
- Top up your balance with crypto. Requests need a balance above zero.
- Send a request to the base URL of your SDK, with your key:
- OpenAI format
https://api.lowcostrouter.com/v1- Anthropic format
https://api.lowcostrouter.com- Gemini format
https://api.lowcostrouter.com
from openai import OpenAI
client = OpenAI(
base_url="https://api.lowcostrouter.com/v1",
api_key="YOUR_API_KEY",
)
reply = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)
Only the highlighted lines change.
Authentication
Send your key in any of the headers the SDKs use. Keys start with lcr_. Keep them secret: anyone with your key can spend your balance. You can revoke a key in the dashboard at any time.
# OpenAI style
Authorization: Bearer lcr_your_key
# Anthropic style
x-api-key: lcr_your_key
# Gemini style (or ?key=lcr_your_key in the URL)
x-goog-api-key: lcr_your_keyOpenAI format
POST /v1/chat/completions accepts the Chat Completions body: messages, tools, response_format, temperature and the rest. Every model works here, including Claude, Gemini and Grok.
Set stream to true to receive server-sent events. Add stream_options.include_usage to get token usage in the last chunk.
curl https://api.lowcostrouter.com/v1/chat/completions \
-H "Authorization: Bearer $LOWCOSTROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-sol",
"stream": true,
"stream_options": {"include_usage": true},
"messages": [{"role": "user", "content": "Hello!"}]
}'Anthropic format
POST /v1/messages accepts the Messages body for Claude models, with tools, extended thinking and prompt caching. Send anthropic-version (2023-06-01 is used if you don't) and anthropic-beta when you need beta features.
curl https://api.lowcostrouter.com/v1/messages \
-H "x-api-key: $LOWCOSTROUTER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'Gemini format
POST /v1beta/models/{model}:generateContent returns the whole response, and :streamGenerateContent streams it (add ?alt=sse for server-sent events). In the google-genai SDK, set http_options base_url to https://api.lowcostrouter.com.
curl "https://api.lowcostrouter.com/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse" \
-H "x-goog-api-key: $LOWCOSTROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"parts": [{"text": "Hello!"}]}]}'Editors, agents and SDKs
Most tools read the standard SDK environment variables or have a base URL setting. Point them at LowCostRouter and use your key.
# OpenAI SDKs and tools built on them
export OPENAI_BASE_URL=https://api.lowcostrouter.com/v1
export OPENAI_API_KEY=lcr_your_key
# Anthropic SDKs and tools built on them
export ANTHROPIC_BASE_URL=https://api.lowcostrouter.com
export ANTHROPIC_API_KEY=lcr_your_keyLong requests and streaming
We don't limit how long a request runs: long generations and agent runs stay connected for as long as the model works.
During long pauses a stream carries keepalive lines that SDKs skip: ": ping" in the OpenAI format, "event: ping" in the Anthropic format and an empty line in the Gemini format. Without streaming, a slow response may start with spaces before the JSON, which JSON parsers ignore.
Models and prices
Put the exact model name from the models page into the model field. Prices are in US dollars per million tokens, separately for input, output, cache reads and cache writes.
See models and pricesHow charging works
A request is charged when it finishes, by the tokens the model used: input, output, cache reads and cache writes, each at its own price.
A request needs a balance above zero. A long request may take the balance slightly below zero; the next one then waits for a top-up.
The dashboard shows your balance, payments and recent requests with what each one cost.
Errors
Errors come back in the format of the API you called, with these HTTP statuses:
| Status | What it means |
|---|---|
400 | The request is invalid, or the model isn't available. |
401 | The API key is missing, wrong or revoked. |
402 | Your balance is zero or below. Top up in the dashboard. |
429 | Too many requests at once (8 per account), or the model is busy. Retry after a pause. |
502 | The model provider failed to answer. Retry later. |
503 | The service is temporarily unavailable. Retry later. |
HTTP/1.1 402 Payment Required
{
"error": {
"message": "Insufficient balance. Top up at https://lowcostrouter.com/en/app",
"type": "insufficient_quota",
"code": null
}
}Limits
Up to 8 requests per account run at the same time. There is no limit on how long a request runs or on how many requests you send per day.