From d0413ec96b92736eebaf3c987ea2b256a8c31805 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 17 Feb 2025 17:02:06 -0800 Subject: [PATCH] docs(routing.md): add section on weighted deployments --- docs/my-website/docs/routing.md | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/docs/my-website/docs/routing.md b/docs/my-website/docs/routing.md index 308b850e45e..79fefcf754d 100644 --- a/docs/my-website/docs/routing.md +++ b/docs/my-website/docs/routing.md @@ -826,6 +826,65 @@ asyncio.run(router_acompletion()) ## Basic Reliability +### Weighted Deployments + +Set `weight` on a deployment to pick one deployment more often than others. + +This works across **ALL** routing strategies. + + + + +```python +from litellm import Router + +model_list = [ + { + "model_name": "o1", + "litellm_params": { + "model": "o1-preview", + "api_key": os.getenv("OPENAI_API_KEY"), + "weight": 1 + }, + }, + { + "model_name": "o1", + "litellm_params": { + "model": "o1-preview", + "api_key": os.getenv("OPENAI_API_KEY"), + "weight": 2 # 👈 PICK THIS DEPLOYMENT 2x MORE OFTEN THAN o1-preview + }, + }, +] + +router = Router(model_list=model_list, routing_strategy="cost-based-routing") + +response = await router.acompletion( + model="gpt-3.5-turbo", + messages=[{"role": "user", "content": "Hey, how's it going?"}] +) +print(response) +``` + + + +```yaml +model_list: + - model_name: o1 + litellm_params: + model: o1 + api_key: os.environ/OPENAI_API_KEY + weight: 1 + - model_name: o1 + litellm_params: + model: o1-preview + api_key: os.environ/OPENAI_API_KEY + weight: 2 # 👈 PICK THIS DEPLOYMENT 2x MORE OFTEN THAN o1-preview +``` + + + + ### Max Parallel Requests (ASYNC) Used in semaphore for async requests on router. Limit the max concurrent calls made to a deployment. Useful in high-traffic scenarios.