litellm - 💡(How to fix) Fix [Bug]: Router.get_model_group_info() raises KeyError when dict-style model_group_alias entry omits 'hidden' key [1 pull requests]

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…

Error Message

KeyError: 'hidden' File "litellm/router.py", line 8700, in get_model_group_info if item["hidden"] is True:

Root Cause

get_model_group_info() crashes with KeyError: 'hidden' when a model_group_alias entry is configured as a dict without the 'hidden' key. Since TypedDict is type-hint only, Python does not inject missing keys at runtime. This crashes every single request because get_model_group_info() is called on every router completion via set_response_headers.

Fix Action

Fixed

Code Example

KeyError: 'hidden'
  File "litellm/router.py", line 8700, in get_model_group_info
    if item["hidden"] is True:
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

get_model_group_info() crashes with KeyError: 'hidden' when a model_group_alias entry is configured as a dict without the 'hidden' key. Since TypedDict is type-hint only, Python does not inject missing keys at runtime. This crashes every single request because get_model_group_info() is called on every router completion via set_response_headers.

Expected behavior: missing 'hidden' key should be treated as hidden=False.

I have a fix ready and will submit a PR immediately after filing this issue.

Steps to Reproduce

  1. Install litellm: pip install litellm

  2. Run the following Python script:

from litellm import Router router = Router( model_list=[{"model_name": "gpt-4", "litellm_params": {"model": "openai/gpt-4", "api_key": "sk-fake"}}], model_group_alias={"my-alias": {"model": "gpt-4"}} ) router.get_model_group_info("my-alias")

  1. Observe KeyError: 'hidden' is raised

Relevant log output

KeyError: 'hidden'
  File "litellm/router.py", line 8700, in get_model_group_info
    if item["hidden"] is True:

What part of LiteLLM is this about?

SDK (litellm Python package)

What LiteLLM version are you on ?

v1.86.0

Twitter / LinkedIn details

No response

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Bug]: Router.get_model_group_info() raises KeyError when dict-style model_group_alias entry omits 'hidden' key [1 pull requests]