New in 3.11The Multi-LLM-Routing is available starting with version
3.11.0.Overview
The Router for LLM and embeddings is a feature that allows you to distribute and load balance requests across multiple LLMs and embeddings. This feature uses LiteLLM under the hood to implement the routing logic.Configuration
To enable the Router for LLM and embeddings, you need to define therouter key to your model group configuration in your endpoints.yml file.
endpoints.yml
models key in the model group configuration.
There are no limit to the number models that you can add to the model group configuration.
endpoints.yml
routing_strategy key defines the routing strategy that the Router will use to distribute requests.
The following routing strategies are available without any additional configuration:
simple-shuffle: The Router will shuffle the requests and distribute them based on RPM (requests per minute) or weight.least-busy: The Router will distribute requests to the deployment that has least number of ongoing requests.latency-based-routing: The Router will distribute requests to the deployment with the lowest response time.
cost-based-routing: The Router will distribute requests to the deployment with the lowest cost.usage-based-routing: The Router will distribute requests to the deployment with the lowest TPM (Tokens per minute) usage.
Additional configuration parameters for the Router
The Router can be configured with additional parameters likecooldown_time, num_retries and allowed_fails to fine-tune the routing logic.
Refer to the LiteLLM’s routing configuration documentation for more information on the configuration parameters.
endpoints.yml
Configuring the Router for multiple model groups
endpoints.yml
least-busy and simple-shuffle routing strategies respectively.
The router settings for each model group are defined under the router key in the model group configuration and are independent of each other.
Configuring the Router for embeddings
While the examples above demonstrate the configuration for LLMs, the Router can also be configured for embeddings and all the routing settings and strategies mentioned above can be used for embeddings as well.endpoints.yml
Configuring the Router for other providers
The Router can be configured for other providers as well. The configuration for other providers is similar to the Azure provider configuration demonstrated above. Refer to the LLM and embeddings provider documentation for more information on the provider specific configuration.Configuring the Router for self-hosted deployments
The Router can also be configured for self-hosted deployments. The configuration for self-hosted deployments is similar to the Azure provider configuration demonstrated above. Some examples for different providers are shown below:vLLM
endpoints.yml
use_chat_completions_endpoint parameter is used to enable/disable the chat completions endpoint for the model.
This parameter is optional and is set to true by default. For more information, refer to the LLM configuration documentation.
With the Router enabled, the use_chat_completions_endpoint parameter should be set as a router level setting and not at the model level.
LLama.cpp
endpoints.yml
Ollama
endpoints.yml
Connecting via a proxy
endpoints.yml
Connecting via litellm proxy
endpoints.yml
Caching
The Router caches the responses from the deployments to improve the response time and reduce the load on the deployments. The cache settings can be configured through thecache_responses key in the router configuration.
endpoints.yml
Configuration for Redis based routing strategies
To use thecost-based-routing or usage-based-routing routing strategies, you need to define the redis
connection settings under the router key in your endpoints.yml file.
endpoints.yml
redis_host, redis_port, and redis_password keys define the connection settings for the redis server.
The redis connection can also be configured through redis_url key.
endpoints.yml
Configuring the Router for multiple model groups with Redis
endpoints.yml