litellm - ✅(Solved) Fix ## Bug: Usage AI Chat fails when selected LiteLLM model name is a proxy alias / model group [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24513Fetched 2026-04-08 01:23:13
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Timeline (top)
commented ×2mentioned ×2subscribed ×2cross-referenced ×1

The Usage dashboard's Ask AI feature fails if the selected model is a LiteLLM model name / model group such as mylitellmmodel.

In my setup, mylitellmmodel is a valid LiteLLM proxy model name that routes to GPT-4.1. It works for normal proxy requests, but the Usage AI chat feature fails with:

litellm.BadRequestError: GetLLMProvider Exception - list index out of range

original model: mylitellmmodel

Error Message

litellm.BadRequestError: GetLLMProvider Exception - list index out of range

original model: mylitellmmodel

Root Cause

The fallback model path is fine, but it is bypassed because the UI is explicitly sending model: "mylitellmmodel".

PR fix notes

PR #24759: Fix Usage AI chat for proxy model aliases and model groups

Description (problem / solution / changelog)

Summary

  • route Usage AI chat completions through the proxy router when it is available
  • preserve direct litellm.acompletion() as a fallback when no router is initialized
  • pass user_api_key_team_id metadata so team-scoped public model names resolve correctly
  • keep the /usage/ai/chat request contract unchanged

Changes

  • added a shared internal completion helper for Usage AI chat that prefers llm_router.acompletion()
  • updated the Usage AI endpoint to pass team_id into the chat flow
  • used the router-backed helper for both the initial tool-calling completion and the final streamed response
  • added backend regression tests for:
    • proxy alias / model-group routing through the router
    • metadata propagation for team-aware routing
    • fallback to direct LiteLLM calls when the router is missing
  • added a focused UI regression test to verify the selected model value is submitted unchanged

Why

The Usage dashboard dropdown shows valid LiteLLM proxy model names / model groups, but the backend was passing that value directly into litellm.acompletion(). That bypassed router resolution and caused failures for proxy aliases like mylitellmmodel.

With this change, Usage AI chat now resolves models the same way normal proxy traffic does.

Testing

  • added backend unit coverage in tests/test_litellm/proxy/management_endpoints/usage_endpoints/test_ai_usage_chat.py
  • added UI coverage in ui/litellm-dashboard/src/components/UsagePage/components/UsageAIChatPanel.test.tsx
  • local syntax check passed via python3 -m py_compile

Notes

  • full pytest/Vitest execution was not completed in this environment because the local test dependencies were not fully installed

Changed files

  • litellm/proxy/management_endpoints/usage_endpoints/ai_usage_chat.py (modified, +52/-4)
  • litellm/proxy/management_endpoints/usage_endpoints/endpoints.py (modified, +1/-0)
  • tests/test_litellm/proxy/management_endpoints/usage_endpoints/test_ai_usage_chat.py (modified, +114/-71)
  • ui/litellm-dashboard/src/components/UsagePage/components/UsageAIChatPanel.test.tsx (modified, +57/-3)

Code Example

litellm.BadRequestError: GetLLMProvider Exception - list index out of range

original model: mylitellmmodel

---

litellm.BadRequestError: GetLLMProvider Exception - list index out of range

original model: mylitellmmodel

---

GetLLMProvider Exception - list index out of range
original model: mylitellmmodel
RAW_BUFFERClick to expand / collapse

Summary

The Usage dashboard's Ask AI feature fails if the selected model is a LiteLLM model name / model group such as mylitellmmodel.

In my setup, mylitellmmodel is a valid LiteLLM proxy model name that routes to GPT-4.1. It works for normal proxy requests, but the Usage AI chat feature fails with:

litellm.BadRequestError: GetLLMProvider Exception - list index out of range

original model: mylitellmmodel

Expected behavior

The Usage AI chat should accept the same model names shown in the LiteLLM UI dropdown, including proxy model aliases / model groups.

If mylitellmmodel is a valid configured LiteLLM model name in the proxy, the Usage AI feature should work with it.

Actual behavior

The Usage AI feature posts the selected model name to /usage/ai/chat, and the backend calls litellm.acompletion(model=<selected_model>) directly.

If the selected model is a proxy alias / model group like mylitellmmodel, LiteLLM tries to interpret it as a raw model/provider string instead of resolving it through the proxy router, and fails.

Error

litellm.BadRequestError: GetLLMProvider Exception - list index out of range

original model: mylitellmmodel

Relevant code

The Usage AI chat endpoint passes the UI-selected model directly into litellm.acompletion():

  • litellm/proxy/management_endpoints/usage_endpoints/endpoints.py
  • litellm/proxy/management_endpoints/usage_endpoints/ai_usage_chat.py

Specifically:

  • stream_usage_ai_chat(..., model=data.model, ...)
  • litellm.acompletion(model=resolved_model, ...)

The fallback model path is fine, but it is bypassed because the UI is explicitly sending model: "mylitellmmodel".

Why this looks like a bug

The UI dropdown shows LiteLLM model names / model groups, but the Usage AI backend appears to expect a direct concrete LiteLLM model string such as:

  • gpt-4o-mini
  • openai/gpt-4o-mini
  • azure/gpt-4.1

This makes the feature incompatible with valid proxy aliases/model groups that work elsewhere in LiteLLM.

Reproduction

  1. Configure a LiteLLM proxy model / model group named mylitellmmodel
  2. Map it to a real upstream model such as GPT-4.1
  3. Open the Usage dashboard
  4. Click Ask AI
  5. Use the model selected from the UI dropdown
  6. Send a message like hello

Result

The request fails with:

GetLLMProvider Exception - list index out of range
original model: mylitellmmodel

Expected fix

One of these should happen:

  • resolve the selected proxy model name / alias through the LiteLLM router before calling litellm.acompletion()
  • or make Usage AI chat use the proxy/router path instead of direct litellm.acompletion()
  • or reject invalid bare provider names, but still support valid configured proxy model names shown in the UI

Notes

If the model field is omitted, the backend falls back to DEFAULT_COMPETITOR_DISCOVERY_MODEL, so the failure is specifically caused by the UI sending the selected alias value directly.

extent analysis

Fix Plan

To resolve the issue, we need to modify the Usage AI chat endpoint to resolve the selected proxy model name through the LiteLLM router before calling litellm.acompletion().

Here are the steps:

  • Modify the stream_usage_ai_chat function in ai_usage_chat.py to resolve the proxy model name.
  • Use the resolved model name to call litellm.acompletion().

Example code:

# ai_usage_chat.py
from litellm.proxy.router import resolve_model

def stream_usage_ai_chat(..., model=data.model, ...):
    # Resolve the proxy model name
    resolved_model = resolve_model(model)
    
    # Call litellm.acompletion() with the resolved model name
    litellm.acompletion(model=resolved_model, ...)

Verification

To verify the fix, follow these steps:

  • Configure a LiteLLM proxy model / model group named mylitellmmodel
  • Map it to a real upstream model such as GPT-4.1
  • Open the Usage dashboard
  • Click Ask AI
  • Use the model selected from the UI dropdown
  • Send a message like hello
  • The request should succeed without throwing a GetLLMProvider Exception.

Extra Tips

  • Make sure to handle cases where the proxy model name is not resolvable.
  • Consider adding logging to track any errors that occur during the resolution process.
  • Review the LiteLLM router documentation to ensure that the resolve_model function is used correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The Usage AI chat should accept the same model names shown in the LiteLLM UI dropdown, including proxy model aliases / model groups.

If mylitellmmodel is a valid configured LiteLLM model name in the proxy, the Usage AI feature should work with it.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING