OpenRouter
Multi-provider routing with price comparison and automatic fallback.
Overview
OpenRouter is a unified API gateway that aggregates multiple AI model providers into a single interface with features like price comparison, automatic fallback, and provider selection.
Official Website: https://openrouter.ai API Documentation: https://openrouter.ai/docs
Key Features
- Model Marketplace — Access 100+ models from various providers
- Price Comparison — Find the best price for your needs
- Automatic Fallback — Route to alternatives if a provider is down
- One API Key — Unified access to all providers
Usage Example
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.yuhuanstudio.com/v1"
)
response = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)Available Models
Use the Models API to query available models:
curl https://api.yuhuanstudio.com/v1/models?provider=openrouter \
-H "Authorization: Bearer YOUR_API_KEY"Models and pricing are synced automatically. Check the dashboard for current availability and rates.
Official Resources
How is this guide?