# OpenRouter — Unified LLM API with Smart Routing > Single API endpoint for 200+ LLM models with automatic fallbacks, price comparison, and usage tracking. Route to the cheapest or fastest model that fits your needs. 3,000+ stars. ## Install Save in your project root: ## Quick Use ```bash # Works with any OpenAI SDK — just change the base URL export OPENROUTER_API_KEY=sk-or-... ``` ```python from openai import OpenAI client = OpenAI( base_url="https://openrouter.ai/api/v1", api_key="sk-or-..." ) response = client.chat.completions.create( model="anthropic/claude-sonnet-4-20250514", messages=[{"role": "user", "content": "Hello!"}] ) ``` Get your free API key at [openrouter.ai](https://openrouter.ai/keys). --- ## Intro OpenRouter is a unified API gateway for 200+ LLM models from every major provider with 3,000+ GitHub stars. One API key, one endpoint, access to Claude, GPT-4, Gemini, Llama, Mistral, and hundreds more. It offers automatic fallbacks, real-time price comparison, and usage dashboards — letting you route requests to the cheapest or fastest model that meets your requirements. Best for developers who want multi-model access without managing 10 different API keys. Works with: any OpenAI-compatible client, LangChain, LiteLLM, Cursor, Continue. Setup time: under 1 minute. --- ## Key Features ### 200+ Models, One API Key | Provider | Example Models | |----------|---------------| | Anthropic | Claude Opus 4, Sonnet 4, Haiku | | OpenAI | GPT-4o, GPT-4, o1 | | Google | Gemini 2.5 Pro, Flash | | Meta | Llama 3.1 70B, 405B | | Mistral | Mistral Large, Codestral | | Open-source | DeepSeek, Qwen, Phi | ### Smart Routing ```python # Auto-select the cheapest model that passes your requirements response = client.chat.completions.create( model="openrouter/auto", # Smart routing messages=[...], route="lowest-cost" # or "lowest-latency" ) ``` ### Fallback Chains ```python # If primary model is down, auto-fallback response = client.chat.completions.create( model="anthropic/claude-sonnet-4-20250514", extra_body={ "fallbacks": ["openai/gpt-4o", "google/gemini-pro"] }, messages=[...] ) ``` ### Price Comparison Real-time pricing dashboard shows cost per million tokens: | Model | Input $/M | Output $/M | |-------|-----------|------------| | Claude Sonnet | $3.00 | $15.00 | | GPT-4o | $2.50 | $10.00 | | Llama 3.1 70B | $0.60 | $0.60 | | Gemini Flash | $0.075 | $0.30 | ### Usage Dashboard Track spending, requests, and token usage per model, per day, per API key. ### Use with Popular Tools **Cursor:** Settings > Models > OpenAI Base URL: `https://openrouter.ai/api/v1` **Continue:** ```json {"models": [{"provider": "openrouter", "model": "anthropic/claude-sonnet-4-20250514"}]} ``` ### Key Stats - 3,000+ GitHub stars - 200+ LLM models - OpenAI-compatible API - Smart routing and fallbacks - Real-time price comparison ### FAQ **Q: What is OpenRouter?** A: OpenRouter is a unified API gateway for 200+ LLM models with one API key, automatic fallbacks, price comparison, and smart routing. **Q: Is OpenRouter free?** A: Free tier with limited credits. Pay-as-you-go with no markup on many models. **Q: How does pricing compare to direct API access?** A: Most models are at or near provider pricing. Some open-source models are free. --- ## Source & Thanks > Created by [OpenRouter](https://github.com/OpenRouterTeam). Licensed under MIT. > > [openrouter](https://openrouter.ai) — ⭐ 3,000+ Thanks for making multi-model LLM access simple. --- ## 快速使用 ```python from openai import OpenAI client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key="sk-or-...") response = client.chat.completions.create( model="anthropic/claude-sonnet-4-20250514", messages=[{"role": "user", "content": "你好"}] ) ``` --- ## 简介 OpenRouter 是一个统一 API 网关,GitHub 3,000+ stars。一个 API Key 访问 200+ LLM 模型,支持自动降级、实时价格比较和智能路由。适合需要多模型访问而不想管理多个 API 密钥的开发者。 --- ## 来源与感谢 > Created by [OpenRouter](https://github.com/OpenRouterTeam). Licensed under MIT. > > [openrouter](https://openrouter.ai) — ⭐ 3,000+ --- Source: https://tokrepo.com/en/workflows/283d7316-11a4-447b-8151-95b0f5124cbb Author: AI Open Source