The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Router order parameter documentation (#18045)
Krish Dholakiae31d8a1cf600
diff --git a/docs/my-website/docs/proxy/load_balancing.md b/docs/my-website/docs/proxy/load_balancing.mdindex 54c917bbbca..4cff7e5d041 100644--- a/docs/my-website/docs/proxy/load_balancing.md+++ b/docs/my-website/docs/proxy/load_balancing.md@@ -29,6 +29,10 @@ LiteLLM automatically distributes requests across multiple deployments of the sa| **latency-based-routing** | Routes to fastest responding deployment | Latency-critical applications || **cost-based-routing** | Routes to deployment with lowest cost | Cost-sensitive applications |+:::tip Deployment Priority+Use the `order` parameter to prioritize specific deployments. [See Deployment Ordering](#deployment-ordering-priority) for details.+:::+## Quick Start - Load Balancing#### Step 1 - Set deployments on config@@ -243,6 +247,27 @@ class RouterModelGroupAliasItem(TypedDict):hidden: bool # if 'True', don't return on `/v1/models`, `/v1/model/info`, `/v1/model_group/info````+## Deployment Ordering (Priority)++Set `order` in `litellm_params` to prioritize deployments. Lower values = higher priority. When multiple deployments share the same `order`, the routing strategy picks among them.++```yaml+model_list:+ - model_name: gpt-4+ litellm_params:+ model: azure/gpt-4-primary+ api_key: os.environ/AZURE_API_KEY+ order: 1 # 👈 Highest priority - always tried first++ - model_name: gpt-4+ litellm_params:+ model: azure/gpt-4-fallback+ api_key: os.environ/AZURE_API_KEY_2+ order: 2 # 👈 Used when order=1 is unavailable+```++If `order=1` deployment is unavailable (e.g., rate-limited), the router falls back to `order=2` deployments.+### When You'll See Load Balancing in Action**Immediate Effects:**diff --git a/docs/my-website/docs/routing.md b/docs/my-website/docs/routing.mdindex 971427806ed..2539f70d5bc 100644--- a/docs/my-website/docs/routing.md+++ b/docs/my-website/docs/routing.md@@ -832,6 +832,59 @@ asyncio.run(router_acompletion())## Basic Reliability+### Deployment Ordering (Priority)++Set `order` in `litellm_params` to prioritize deployments. Lower values = higher priority. When multiple deployments share the same `order`, the routing strategy picks among them.++<Tabs>+<TabItem value="sdk" label="SDK">++```python+from litellm import Router++model_list = [+ {+ "model_name": "gpt-4",+ "litellm_params": {+ "model": "azure/gpt-4-primary",+ "api_key": os.getenv("AZURE_API_KEY"),+ "order": 1, # 👈 Highest priority+ },+ },+ {+ "model_name": "gpt-4",+ "litellm_params": {+ "model": "azure/gpt-4-fallback",+ "api_key": os.getenv("AZURE_API_KEY_2"),+ "order": 2, # 👈 Used when order=1 is unavailable+ },+ },+]++router = Router(model_list=model_list)+```++</TabItem>+<TabItem value="proxy" label="PROXY">++```yaml+model_list:+ - model_name: gpt-4+ litellm_params:+ model: azure/gpt-4-primary+ api_key: os.environ/AZURE_API_KEY+ order: 1 # 👈 Highest priority++ - model_name: gpt-4+ litellm_params:+ model: azure/gpt-4-fallback+ api_key: os.environ/AZURE_API_KEY_2+ order: 2 # 👈 Used when order=1 is unavailable+```++</TabItem>+</Tabs>+### Weighted DeploymentsSet `weight` on a deployment to pick one deployment more often than others.