Setting Up OpenRouter as a Custom Provider
To use OpenRouter models in PromptLayer:- Get an OpenRouter API Key: Sign up at OpenRouter and obtain your API key from their dashboard
- Navigate to Settings → Custom Providers and Models in your PromptLayer dashboard
- Click Create Custom Provider
- Configure the provider with the following details:
- Name: OpenRouter
- Client: OpenAI (OpenRouter uses OpenAI-compatible endpoints)
- Base URL:
https://openrouter.ai/api/v1 - API Key: Your OpenRouter API key
Creating Custom Models (Recommended)
For easier model selection in the Playground and Prompt Registry, you can save specific OpenRouter models:- In Settings → Custom Providers and Models, find your OpenRouter provider in the list
- Click on the OpenRouter row to expand it
- Click Create Custom Model in the expanded section
- Configure each model:
- Model Name: Enter the OpenRouter model identifier (e.g.,
deepseek/deepseek-chat,anthropic/claude-3.5-sonnet) - Display Name: A friendly name like “DeepSeek Chat” or “Claude 3.5 Sonnet”
- Model Type: Chat
- Model Name: Enter the OpenRouter model identifier (e.g.,
- Repeat for each model you want to use
Available Models
OpenRouter regularly updates their model offerings and provides access to many providers. Example models include:deepseek/deepseek-chat: DeepSeek’s latest chat modelanthropic/claude-3.5-sonnet: Claude 3.5 Sonnet via OpenRouteropenai/gpt-4-turbo: GPT-4 Turbo via OpenRoutergoogle/gemini-pro-1.5: Gemini Pro 1.5 via OpenRoutermeta-llama/llama-3.1-405b: Llama 3.1 405B via OpenRouter
Using OpenRouter in PromptLayer
In the Playground
After setup, you can use OpenRouter models in the PromptLayer Playground:- Open the Playground
- Select your OpenRouter provider from the provider dropdown
- Choose your desired model (or type the model identifier)
- Start querying with your prompts
In the Prompt Registry
OpenRouter models work seamlessly with PromptLayer’s Prompt Registry:- Select OpenRouter models when creating or editing prompt templates
- Use templates with OpenRouter models in evaluations
- Track and analyze OpenRouter API usage alongside other providers
Key Benefits
OpenRouter provides:- Wide Model Selection: Access to models from multiple providers through one API
- Automatic Rate Limiting and Failover: OpenRouter handles rate limiting between providers
- Cost Optimization: Compare pricing across different models and providers
- Model Availability: Access to models that might not be directly available in your region
SDK Usage
Once you’ve set up your OpenRouter custom provider and created a prompt template in the dashboard, you can run it programmatically with the PromptLayer SDK:Using
promptlayer.run() ensures your requests are properly logged to PromptLayer and leverages your prompt templates from the Prompt Registry. This is the recommended approach for production use.
