Skip to content

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]

docs: add per-model-group affinity configuration docs

Sameer Kankutea14122c28e52
diff --git a/docs/my-website/docs/proxy/config_settings.md b/docs/my-website/docs/proxy/config_settings.md
index f5b611a85a6..d7d6079c517 100644
--- a/docs/my-website/docs/proxy/config_settings.md
+++ b/docs/my-website/docs/proxy/config_settings.md
@@ -363,6 +363,7 @@ router_settings:
| router_general_settings | RouterGeneralSettings | [SDK-Only] Router general settings - contains optimizations like 'async_only_mode'. [Docs](../routing.md#router-general-settings) |
| optional_pre_call_checks | List[str] | List of pre-call checks to add to the router. Supported: `router_budget_limiting`, `prompt_caching`, `responses_api_deployment_check`, `encrypted_content_affinity`, `deployment_affinity`, `session_affinity`, `forward_client_headers_by_model_group` |
| deployment_affinity_ttl_seconds | int | TTL (seconds) for user-key → deployment affinity mapping when `deployment_affinity` is enabled (configured at Router init / proxy startup). Defaults to `3600` (1 hour). |
+| model_group_affinity_config | Dict[str, List[str]] | Per-model-group affinity flags. Keys are model group names; values are lists of checks to enable (`deployment_affinity`, `responses_api_deployment_check`, `session_affinity`). Groups not listed fall back to the global `optional_pre_call_checks`. [Docs](../response_api.md#per-model-group-affinity-configuration) |
| ignore_invalid_deployments | boolean | If true, ignores invalid deployments. Default for proxy is True - to prevent invalid models from blocking other models from being loaded. |
| search_tools | List[SearchToolTypedDict] | List of search tool configurations for Search API integration. Each tool specifies a search_tool_name and litellm_params with search_provider, api_key, api_base, etc. [Further Docs](../search/index.md) |
| guardrail_list | List[GuardrailTypedDict] | List of guardrail configurations for guardrail load balancing. Enables load balancing across multiple guardrail deployments with the same guardrail_name. [Further Docs](./guardrails/guardrail_load_balancing.md) |
diff --git a/docs/my-website/docs/response_api.md b/docs/my-website/docs/response_api.md
index fb55ae9f9d0..56b8170995c 100644
--- a/docs/my-website/docs/response_api.md
+++ b/docs/my-website/docs/response_api.md
@@ -1364,6 +1364,85 @@ litellm --config config.yaml
| `deployment_affinity` | Simple sticky sessions | All requests from same API key | ❌ Reduces quota by # of users |
+## Per-Model-Group Affinity Configuration
+
+By default, `optional_pre_call_checks` applies globally to all model groups. Use `model_group_affinity_config` when you want different affinity behavior per model group — for example, enabling stickiness only for models spread across providers (Azure + Bedrock) while leaving single-provider groups free to load-balance.
+
+Groups not listed fall back to the global `optional_pre_call_checks` settings.
+
+<Tabs>
+<TabItem value="python-sdk" label="Python SDK">
+
+```python
+router = litellm.Router(
+ model_list=[
+ {
+ "model_name": "gpt-4",
+ "litellm_params": {"model": "azure/gpt-4", "api_key": "...", "api_base": "https://endpoint1.openai.azure.com"},
+ },
+ {
+ "model_name": "gpt-4",
+ "litellm_params": {"model": "bedrock/anthropic.claude-v2", "aws_region_name": "us-east-1"},
+ },
+ {
+ "model_name": "text-embedding-ada-002",
+ "litellm_params": {"model": "azure/text-embedding-ada-002", "api_key": "...", "api_base": "https://endpoint1.openai.azure.com"},
+ },
+ {
+ "model_name": "text-embedding-ada-002",
+ "litellm_params": {"model": "azure/text-embedding-ada-002", "api_key": "...", "api_base": "https://endpoint2.openai.azure.com"},
+ },
+ ],
+ # gpt-4: cross-provider (Azure + Bedrock) — enable deployment affinity
+ # text-embedding-ada-002: same provider — no affinity, let it load balance freely
+ model_group_affinity_config={
+ "gpt-4": ["deployment_affinity", "responses_api_deployment_check"],
+ },
+)
+```
+
+</TabItem>
+<TabItem value="proxy-server" label="Proxy Server">
+
+```yaml title="config.yaml"
+model_list:
+ - model_name: gpt-4
+ litellm_params:
+ model: azure/gpt-4
+ api_key: os.environ/AZURE_API_KEY_1
+ api_base: https://endpoint1.openai.azure.com
+
+ - model_name: gpt-4
+ litellm_params:
+ model: bedrock/anthropic.claude-v2
+ aws_region_name: us-east-1
+
+ - model_name: text-embedding-ada-002
+ litellm_params:
+ model: azure/text-embedding-ada-002
+ api_key: os.environ/AZURE_API_KEY_1
+ api_base: https://endpoint1.openai.azure.com
+
+ - model_name: text-embedding-ada-002
+ litellm_params:
+ model: azure/text-embedding-ada-002
+ api_key: os.environ/AZURE_API_KEY_2
+ api_base: https://endpoint2.openai.azure.com
+
+router_settings:
+ # gpt-4: cross-provider — enable stickiness
+ # text-embedding-ada-002: not listed — load balances freely
+ model_group_affinity_config:
+ "gpt-4":
+ - deployment_affinity
+ - responses_api_deployment_check
+```
+
+</TabItem>
+</Tabs>
+
+**Supported values:** `deployment_affinity`, `responses_api_deployment_check`, `session_affinity`
+
## Calling non-Responses API endpoints (`/responses` to `/chat/completions` Bridge)
LiteLLM allows you to call non-Responses API models via a bridge to LiteLLM's `/chat/completions` endpoint. This is useful for calling Anthropic, Gemini and even non-Responses API OpenAI models.