LiteLLM
Route LiteLLM client calls and proxy models through AnyRouter as a custom OpenAI-compatible provider.
LiteLLM reaches AnyRouter as a custom OpenAI-compatible provider. Prefix the model with openai/, set api_base to https://anyrouter.dev/api/v1, and pass an sk-ar- key from the dashboard. The part after openai/ is the AnyRouter model id.
import litellm
response = litellm.completion(
model="openai/google/gemini-3.5-flash",
api_base="https://anyrouter.dev/api/v1",
api_key="your-anyrouter-api-key",
messages=[{"role": "user", "content": "Explain load balancing."}],
)
print(response.choices[0].message.content)model_list:
- model_name: anyrouter-gpt-4o
litellm_params:
model: openai/openai/gpt-4o
api_base: https://anyrouter.dev/api/v1
api_key: os.environ/ANYROUTER_API_KEYA model reply confirms it works.
Troubleshooting
| Symptom | Fix |
|---|---|
| 401 | api_key (or ANYROUTER_API_KEY) must start with sk-ar-. |
| 404 model not found | After openai/, use a full provider/model id from the catalog. |
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer