litellm - 💡(How to fix) Fix [Bug]: Complexity router fails with content array format (multi-modal messages) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

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#23247Fetched 2026-04-08 00:37:57
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
1
Timeline (top)
labeled ×3commented ×2mentioned ×1subscribed ×1

Error Message

400 litellm.BadRequestError: Unmapped LLM provider for this endpoint. You passed model=complexity_router, custom_llm_provider=auto_router. Check supported provider and route: https://docs.litellm.ai/docs/providers. Received Model Group=smart-router Available Model Group Fallbacks=None

Code Example

model_list:
    - model_name: anthropic-claude-haiku-4-5
      litellm_params:
        model: anthropic/claude-haiku-4-5
        api_key: os.environ/ANTHROPIC_API_KEY

    - model_name: anthropic-claude-sonnet-4-6
      litellm_params:
        model: anthropic/claude-sonnet-4-6
        api_key: os.environ/ANTHROPIC_API_KEY

    - model_name: smart-router
      litellm_params:
        model: auto_router/complexity_router
        complexity_router_config:
          tiers:
            SIMPLE: anthropic-claude-haiku-4-5
            MEDIUM: anthropic-claude-haiku-4-5
            COMPLEX: anthropic-claude-sonnet-4-6
            REASONING: anthropic-claude-sonnet-4-6
        complexity_router_default_model: anthropic-claude-sonnet-4-6

---

{
    "model": "smart-router",
    "messages": [{"role": "user", "content": "hello"}],
    "stream": true
  }

---

{
    "model": "smart-router",
    "messages": [{"role": "user", "content": [{"type": "text", "text": "hello"}]}],
    "stream": true
  }

---

400 litellm.BadRequestError: Unmapped LLM provider for this endpoint. You passed model=complexity_router,
 custom_llm_provider=auto_router. Check supported provider and route: https://docs.litellm.ai/docs/providers.
 Received Model Group=smart-router
 Available Model Group Fallbacks=None
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?

The auto_router/complexity_router fails with LiteLLMUnknownProvider when messages use the OpenAI content array format ([{"type": "text", "text": "..."}]) instead of plain strings.

Steps to Reproduce

Config:

  model_list:
    - model_name: anthropic-claude-haiku-4-5
      litellm_params:
        model: anthropic/claude-haiku-4-5
        api_key: os.environ/ANTHROPIC_API_KEY

    - model_name: anthropic-claude-sonnet-4-6
      litellm_params:
        model: anthropic/claude-sonnet-4-6
        api_key: os.environ/ANTHROPIC_API_KEY

    - model_name: smart-router
      litellm_params:
        model: auto_router/complexity_router
        complexity_router_config:
          tiers:
            SIMPLE: anthropic-claude-haiku-4-5
            MEDIUM: anthropic-claude-haiku-4-5
            COMPLEX: anthropic-claude-sonnet-4-6
            REASONING: anthropic-claude-sonnet-4-6
        complexity_router_default_model: anthropic-claude-sonnet-4-6

Works (string content):

{
    "model": "smart-router",
    "messages": [{"role": "user", "content": "hello"}],
    "stream": true
  }

Fails (content array format):

  {
    "model": "smart-router",
    "messages": [{"role": "user", "content": [{"type": "text", "text": "hello"}]}],
    "stream": true
  }

Error: litellm.BadRequestError: Unmapped LLM provider for this endpoint. You passed model=complexity_router, custom_llm_provider=auto_router. Check supported provider and route: https://docs.litellm.ai/docs/providers. Received Model Group=smart-router Available Model Group Fallbacks=None

Expected behavior:

The complexity router should handle both content formats — plain strings and content block arrays — since both are valid per the OpenAI API spec. Many clients (including OpenClaw) use the array format by default.

Traceback:

The error originates in litellm/main.py:completion() which raises LiteLLMUnknownProvider for auto_router. This suggests the complexity router's content analysis fails to parse the array format, causing it to skip tier routing and fall through to the generic completion handler.

LiteLLM version: ghcr.io/berriai/litellm:main-stable (as of 2026-03-10)

Relevant log output

400 litellm.BadRequestError: Unmapped LLM provider for this endpoint. You passed model=complexity_router,
 custom_llm_provider=auto_router. Check supported provider and route: https://docs.litellm.ai/docs/providers.
 Received Model Group=smart-router
 Available Model Group Fallbacks=None

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.81.14

Twitter / LinkedIn details

@theleoborges / https://www.linkedin.com/in/theleoborges/

extent analysis

Fix Plan

To fix the issue, we need to modify the complexity router to handle both plain strings and content block arrays. We can achieve this by adding a content parsing step before routing.

  • Update the complexity_router to parse the content format:
def parse_content(message):
    if isinstance(message["content"], str):
        return message["content"]
    elif isinstance(message["content"], list) and message["content"][0]["type"] == "text":
        return message["content"][0]["text"]
    else:
        raise ValueError("Unsupported content format")

def complexity_router(messages):
    for message in messages:
        content = parse_content(message)
        # Proceed with routing based on the parsed content
        # ...
  • Ensure the parse_content function is called before routing in the complexity_router:
def completion(messages):
    parsed_messages = []
    for message in messages:
        parsed_message = message.copy()
        parsed_message["content"] = parse_content(message)
        parsed_messages.append(parsed_message)
    # Proceed with routing using the parsed messages
    # ...

Verification

To verify the fix, test the complexity router with both plain strings and content block arrays:

# Test with plain string
messages = [{"role": "user", "content": "hello"}]
# Test with content array format
messages = [{"role": "user", "content": [{"type": "text", "text": "hello"}]}]

If the fix is successful, the complexity router should handle both formats correctly and route the messages accordingly.

Extra Tips

  • Ensure the parse_content function is robust and handles various content formats that may be encountered.
  • Consider adding logging or monitoring to track any issues with content parsing or routing.
  • Review the OpenAI API spec to ensure compliance with the expected content formats.

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