OpenRouter
Multi-provider routing gateway with broad model selection.
Overview
OpenRouter is a unified API gateway and marketplace that aggregates models from many upstream providers behind a single OpenAI-compatible interface.
Official Website: https://openrouter.ai API Documentation: https://openrouter.ai/docs
Key features
- Model marketplace — Broad selection of models from many providers
- OpenAI-compatible — Standard
/chat/completionsinterface - Provider routing — Automatic fallback and provider selection upstream
- Unified access — One endpoint across all upstream providers
Using OpenRouter with Yunxin
Address OpenRouter models using the provider/model convention by prefixing with openrouter/. Because OpenRouter model ids are themselves namespaced (for example, anthropic/claude-3.5-sonnet), Yunxin passes the nested suffix upstream — so the full model id becomes openrouter/anthropic/claude-3.5-sonnet. Requests use the same Yunxin base URL (https://api.yuhuanstudio.com/v1) and your Yunxin sk- API key.
Usage example
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["YUNXIN_API_KEY"],
base_url="https://api.yuhuanstudio.com/v1"
)
response = client.chat.completions.create(
model="openrouter/anthropic/claude-3.5-sonnet",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)Available models
Query the live catalog with the Models API:
curl "https://api.yuhuanstudio.com/v1/models?provider=openrouter" \
-H "Authorization: Bearer $YUNXIN_API_KEY"Capabilities and pricing are tracked per model. Use GET /v1/models?provider=openrouter and each model's capabilities array as the authoritative source rather than relying on a hardcoded list.
Official resources
How is this guide?