fix(ai_usage_chat): route model_group_alias through llm_router

When pass_through_all_models is enabled, _acompletion fell back to
litellm.acompletion for any model not in model_names / has_model_id,
which incorrectly bypasses router-only aliases configured via
model_group_alias. Match route_llm_request's behavior by treating
alias lookups as router-managed too.
This commit is contained in:
Cursor Agent 2026-05-06 14:27:33 +00:00
parent 55191d6f19
commit b146a1e16b
No known key found for this signature in database

View file

@ -443,10 +443,12 @@ async def _acompletion(**kwargs: Any) -> Any:
# does. Otherwise proxies that route some models via the router but
# allow pass-through for everything else would 400 here.
model = kwargs.get("model")
model_group_alias = llm_router.model_group_alias or {}
if (
llm_router.router_general_settings.pass_through_all_models
and model not in llm_router.model_names
and not llm_router.has_model_id(model or "")
and model not in model_group_alias
):
return await litellm.acompletion(**kwargs)
return await llm_router.acompletion(**kwargs)