This guide explains how to set up and use the OpenRouter integration with MultiLLM-Proxy.
OpenRouter is a unified API that gives you access to the latest AI models from Anthropic, Google, Meta, Mistral, OpenAI, and more. With OpenRouter, you can:
- Access 30+ top AI models through a single API
- Pay as you go with credits (no subscriptions)
- Use a single API key for all models
- Get consistent response formats across different providers
- Visit OpenRouter.ai and sign up for an account
- After signing up, navigate to your account settings
- Create a new API key with appropriate permissions
Add your OpenRouter API key to the .env file:
OPENROUTER_API_KEY=your_openrouter_api_key_here
Restart the MultiLLM-Proxy service to apply the changes:
# If running directly
python app.py
# If running with Docker
docker-compose restartThe OpenRouter dashboard provides a user-friendly interface to test different models and track your credit usage.
- Model Selection: Choose from a variety of models including GPT-4, Claude, Gemini, Llama, and more
- Interactive Testing: Test models with your own prompts
- Streaming Support: Enable streaming for real-time responses
- Credit Tracking: Monitor your OpenRouter credit usage
- Response Formatting: Responses are formatted for readability with support for code blocks and lists
- Navigate to the OpenRouter dashboard in MultiLLM-Proxy
- Select a model from the available options
- Enter your prompt in the text area
- Toggle streaming on/off as needed
- Click "Test Model" to see the response
- Use the copy button to copy the response to your clipboard
MultiLLM-Proxy provides OpenAI-compatible endpoints for OpenRouter:
curl -X POST "http://localhost:1400/openrouter/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ADMIN_API_KEY" \
-d '{
"model": "anthropic/claude-3-opus",
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms"
}
],
"stream": false
}'You can use any model supported by OpenRouter. Some popular options include:
openai/gpt-4anthropic/claude-3-opusanthropic/claude-3-sonnetanthropic/claude-3-haikugoogle/gemini-prometa-llama/llama-3-70b-instructmistralai/mistral-7b-instructcohere/command-rperplexity/pplx-7b-online
For a complete list of models, visit the OpenRouter Models page.
If you encounter authentication errors:
- Verify your OpenRouter API key is correctly set in the
.envfile - Check that your OpenRouter account has sufficient credits
- Ensure your API key has the necessary permissions
Some models may be temporarily unavailable due to:
- Provider maintenance
- Rate limiting
- Model deprecation
Check the OpenRouter status page for any known issues.
OpenRouter operates on a credit system:
- Different models have different costs per token
- Monitor your credit usage in the dashboard
- Add more credits to your OpenRouter account when running low