LiteLLM on one prepaid key
Give LiteLLM one RelaySwitch API key instead of an account per provider: the SDK and the proxy both reach Claude, GPT, Gemini and the open models through https://api.relayswitch.io/v1, billed per token from a balance you top up by card or crypto.
A LiteLLM API key setup normally means one key per provider and a billing account behind each. With RelaySwitch it is one key: prefix the model id with openai/, set api_base to https://api.relayswitch.io/v1, and LiteLLM treats the whole catalog as one OpenAI-compatible endpoint. Every model bills the same prepaid balance at the per-token price on its model page.
This guide covers both ways people run LiteLLM: the Python SDK call, and the proxy with a config.yaml that other tools point at. The config block is generated from the live catalog, so the ids in it exist today. The field names follow LiteLLM's OpenAI-compatible provider docs (read 2026-10-28).
01What you need
- Python 3.10 or newer with LiteLLM installed. The SDK and the proxy are separate extras:bash1
pip install litellm # the SDK2pip install 'litellm[proxy]' # the proxy server - A RelaySwitch key. Sign in with an email code at the console and create one. Keys start with
sk-relay-. Export it asRELAYSWITCH_API_KEY; both code blocks below read it from there. - A balance. Top-ups start at $10 by Card or in USDT, USDC, BTC, ETH, SOL. Pay as you go, no subscription, no KYC. The console chat gives you 12 free turns a day before the first top-up; LiteLLM requests bill the balance.
02LiteLLM API key setup in the SDK
The SDK needs three things per call: the model id behind openai/, the base URL and the key. LiteLLM's docs say the openai/ prefix routes to /chat/completions on whatever api_base you give it, and that api_base should end in /v1.
import osimport litellm response = litellm.completion( model="openai/claude-sonnet-5-5", # openai/ = any OpenAI-compatible endpoint api_base="https://api.relayswitch.io/v1", api_key=os.environ["RELAYSWITCH_API_KEY"], messages=[{"role": "user", "content": "Say ok."}],)print(response.choices[0].message.content)Claude ids answer the OpenAI format here, so openai/claude-sonnet-5-5 is correct even though the model is Anthropic's. There is no anthropic/ prefix to set and no second key. To change models, change the id after the prefix; the key and base stay.
03The proxy: config.yaml model_list
The proxy maps a client-facing model_name to a litellm_params block with the real target. The os.environ/RELAYSWITCH_API_KEY value tells LiteLLM to read the key from the environment at start, so the file holds no secret. drop_params under litellm_settings makes the proxy drop a parameter a model rejects instead of failing the request (drop_params docs, read 2026-10-28).
model_list: - model_name: claude-sonnet-5-5 litellm_params: model: openai/claude-sonnet-5-5 api_base: https://api.relayswitch.io/v1 api_key: os.environ/RELAYSWITCH_API_KEY - model_name: claude-opus-5-5 litellm_params: model: openai/claude-opus-5-5 api_base: https://api.relayswitch.io/v1 api_key: os.environ/RELAYSWITCH_API_KEY - model_name: gpt-6.1-sol litellm_params: model: openai/gpt-6.1-sol api_base: https://api.relayswitch.io/v1 api_key: os.environ/RELAYSWITCH_API_KEY - model_name: gemini-4-argon litellm_params: model: openai/gemini-4-argon api_base: https://api.relayswitch.io/v1 api_key: os.environ/RELAYSWITCH_API_KEY - model_name: deepseek-v4-pro litellm_params: model: openai/deepseek-v4-pro api_base: https://api.relayswitch.io/v1 api_key: os.environ/RELAYSWITCH_API_KEY - model_name: glm-5.3 litellm_params: model: openai/glm-5.3 api_base: https://api.relayswitch.io/v1 api_key: os.environ/RELAYSWITCH_API_KEY litellm_settings: drop_params: trueExport the key and start the proxy:
export RELAYSWITCH_API_KEY="sk-relay-..."litellm --config config.yaml# Proxy running on http://0.0.0.0:4000Then any OpenAI-compatible client talks to the proxy. The quick start (read 2026-10-28) uses a placeholder api_key on the client; the proxy adds the real key from the config.
import openai client = openai.OpenAI(api_key="anything", base_url="http://0.0.0.0:4000")response = client.chat.completions.create( model="claude-sonnet-5-5", # the model_name alias from config.yaml messages=[{"role": "user", "content": "Say ok."}],)print(response.choices[0].message.content)If the proxy is reachable by anyone but you, set general_settings.master_key (it must start with sk-) and clients send that as their key. See LiteLLM's virtual keys page (read 2026-10-28); the full config reference is on the proxy config page.
04Which model ids to use
Any id on the Models page works after openai/. The id is the slug in the model page URL, not the display name. The 6 in the config above cover the usual spread:
| model_name | Model | Context |
|---|---|---|
claude-sonnet-5-5 | Claude Sonnet 5.5 | 1,000,000 |
claude-opus-5-5 | Claude Opus 5.5 | 1,000,000 |
gpt-6.1-sol | GPT-6.1 Sol | 1,050,000 |
gemini-4-argon | Gemini 4 Argon | 1,048,576 |
deepseek-v4-pro | DeepSeek V4 Pro 0423 | 1,048,576 |
glm-5.3 | GLM 5.3 | 1,000,000 |
Context in tokens, read from the live catalog when this page was built.
GET https://api.relayswitch.io/v1/models with your key returns every id it can call, which is the list to generate a longer model_list from.
05Price per token
LiteLLM's own cost tracking multiplies tokens by the developer list prices in its model map. The charge here is the RelaySwitch rate, which the console's Usage page shows per request. These are the live rates for the models in the config:
| Model | Input | Cached | Output | Developer list in / out |
|---|---|---|---|---|
| Claude Sonnet 5.5 | $1.20 (40% under) | $0.075 | $3.00 (70% under) | $2.00 / $10.00 |
| Claude Opus 5.5 | $2.80 (30% under) | $0.15 | $10.00 (50% under) | $4.00 / $20.00 |
| GPT-6.1 Sol | $0.60 (70% under) | $0.06 | $3.00 (70% under) | $2.00 / $10.00 |
| Gemini 4 Argon | $0.60 (70% under) | $0.06 | $3.00 (70% under) | $2.00 / $10.00 |
| DeepSeek V4 Pro 0423 | $0.792 (40% under) | $0.0264 | $2.376 (40% under) | $1.32 / $3.96 |
| GLM 5.3 | $0.3276 (70% under) | $0.068 | $1.0296 (70% under) | $1.092 / $3.432 |
USD per million tokens, read from the RelaySwitch catalog when this page was built. Developer list: the catalog's record of the developer's own price.
One chat turn of 2,000 input tokens and 500 output tokens costs $0.0012 on GLM 5.3 and $0.0106 on Claude Opus 5.5 at those rates. How the balance and the cached rate work is on Pricing.
06Check the key before LiteLLM
Two curl calls separate a key or base URL problem from a LiteLLM one. The first lists the ids your key can call:
curl https://api.relayswitch.io/v1/models -H "Authorization: Bearer $RELAYSWITCH_API_KEY"The second sends one request the way LiteLLM does. -i prints the headers, including the request id and, on a non-streamed answer, the charge in USD.
curl -i https://api.relayswitch.io/v1/chat/completions \ -H "Authorization: Bearer $RELAYSWITCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Say ok."}]}'If both work, what is left is in the LiteLLM call or config. Send one request through LiteLLM and it shows on the console's Usage page within seconds, with its tokens and its charge.
07Errors and fixes
LLM Provider NOT provided: theopenai/prefix is missing from the model string.NotFoundErrorwith no model code:api_baseis missing/v1or carries an extra path. LiteLLM adds/chat/completionsitself.401: the key is wrong, revoked or cut short, orRELAYSWITCH_API_KEYwas not exported in the shell that started the proxy. Paste it again and run the curl check.402: the balance is too low for the request. Top up in the console; the key works again at once.404with a model code: the id afteropenai/is not in the catalog. Check for a typo or a display name in place of the id.429: the key hit its rate limit. Wait and resend, or create a key with a higher Requests / min in the console.- A parameter error on one model only: set
drop_params: trueas in the config above, or passdrop_params=Trueto thatcompletion()call.
Questions
- Does LiteLLM work with an OpenAI-compatible API key?
- Yes. Prefix the model id with openai/ and pass api_base and api_key. LiteLLM then sends the request to https://api.relayswitch.io/v1/chat/completions with your RelaySwitch key.
- What api_base does LiteLLM need for a custom model?
- https://api.relayswitch.io/v1, with the /v1 at the end and nothing after it. LiteLLM appends the endpoint path itself.
- Can I use Claude through LiteLLM with this key?
- Yes. The Claude ids on RelaySwitch answer the OpenAI format, so openai/claude-sonnet-5-5 works with no Anthropic key and no anthropic/ prefix.
- How do I keep the key out of the LiteLLM proxy config file?
- Write api_key: os.environ/RELAYSWITCH_API_KEY in config.yaml and export RELAYSWITCH_API_KEY before starting the proxy. LiteLLM reads the variable at start.
- How do I pay for the key?
- Top up a balance in the console from $10 by Card or in USDT, USDC, BTC, ETH, SOL. Each request draws from it at the live per-token price. No subscription, no KYC.
- Why does LiteLLM show a different cost from the console?
- LiteLLM multiplies tokens by the developer list prices in its own model map. The console Usage page shows the RelaySwitch charge, which is what the balance pays.