fix(router): capture xai-oauth alias normalization in add_deployment path

This commit is contained in:
Devin AI 2026-07-10 23:35:48 +00:00
parent d3a2cb2b75
commit db18e33fec
2 changed files with 30 additions and 2 deletions

View file

@ -8061,11 +8061,12 @@ class Router:
if _deployment_model_id and self.has_model_id(_deployment_model_id):
return None
# add to model list
_deployment = deployment.to_json(exclude_none=True)
# initialize client
self._add_deployment(deployment=deployment)
# add to model list
_deployment = deployment.to_json(exclude_none=True)
_model_info_dict: dict = deployment.model_info.model_dump(exclude_none=True)
for field in CustomPricingLiteLLMParams.model_fields.keys():
field_value = deployment.litellm_params.get(field)

View file

@ -1138,6 +1138,33 @@ def test_apply_xai_oauth_alias_helper():
assert router._apply_xai_oauth_alias(untouched) is untouched
def test_add_deployment_normalizes_xai_oauth_alias():
"""add_deployment (used for runtime/DB deployments) must normalize the alias too."""
from litellm.types.router import Deployment
router = litellm.Router(
model_list=[
{"model_name": "grok-4.5", "litellm_params": {"model": "xai/grok-4.5"}}
]
)
router.add_deployment(
Deployment(
model_name="grok-4.5",
litellm_params={"model": "xai-oauth/grok-4.5"},
)
)
added = [
m
for m in router.get_model_list()
if m["litellm_params"].get("use_xai_oauth")
]
assert len(added) == 1
assert added[0]["litellm_params"]["model"] == "xai/grok-4.5"
assert added[0]["litellm_params"].get("custom_llm_provider") is None
@pytest.mark.asyncio
async def test_router_ageneric_api_call_with_fallbacks_helper():
"""