litellm - 💡(How to fix) Fix [Bug]: OpenRouter model selected from Admin UI list fails Test Connect with 'is not a valid model ID' [1 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#24795Fetched 2026-04-08 01:53:53
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
4
Author
Timeline (top)
subscribed ×5commented ×1labeled ×1

Error Message

OpenrouterException - {"error":{"message":"openrouter/google/gemini-2.5-flash is not a valid model ID","code":400},"user_id":"..."}

Root Cause

This does not appear to be a manual input error, because the model was selected from the OpenRouter model list in the UI.

Code Example

OpenrouterException - {"error":{"message":"openrouter/google/gemini-2.5-flash is not a valid model ID","code":400},"user_id":"..."}

---

OpenrouterException - {"error":{"message":"openrouter/google/gemini-2.5-flash is not a valid model ID","code":400}}

---

curl -X POST \
  https://openrouter.ai/api/v1/chat/completions \
  -H 'HTTP-Referer: https://litellm.ai' \
  -H 'X-Title: LiteLLM' \
  -H 'Authorization: Bearer <redacted>' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "openrouter/google/gemini-2.5-flash",
    "messages": [
      {
        "role": "user",
        "content": "hello"
      }
    ]
  }'
RAW_BUFFERClick to expand / collapse

What happened?

In LiteLLM Admin UI, when adding a model with provider OpenRouter, I selected openrouter/google/gemini-2.5-flash directly from the provider model list/dropdown.

When I click Test Connect, the request fails with:

OpenrouterException - {"error":{"message":"openrouter/google/gemini-2.5-flash is not a valid model ID","code":400},"user_id":"..."}

This does not appear to be a manual input error, because the model was selected from the OpenRouter model list in the UI.

Why this seems incorrect

As of March 30, 2026, google/gemini-2.5-flash still exists on OpenRouter: https://openrouter.ai/google/gemini-2.5-flash

So either:

  1. LiteLLM Admin UI is surfacing a stale or invalid OpenRouter model ID.
  2. The Test Connect flow is sending a model name format that OpenRouter rejects.
  3. There is a mismatch between what the dropdown returns and what the backend/OpenRouter expects.

Reproduction

  1. Open LiteLLM Admin UI.
  2. Go to Models + Endpoints -> Add Model.
  3. Choose provider: OpenRouter.
  4. Select model from the provider model list: openrouter/google/gemini-2.5-flash.
  5. Click Test Connect.

Actual result

Connection test fails with:

OpenrouterException - {"error":{"message":"openrouter/google/gemini-2.5-flash is not a valid model ID","code":400}}

Expected result

If the model is selectable from the OpenRouter list, Test Connect should succeed, or the UI should not offer that model.

API request shown by the UI

curl -X POST \
  https://openrouter.ai/api/v1/chat/completions \
  -H 'HTTP-Referer: https://litellm.ai' \
  -H 'X-Title: LiteLLM' \
  -H 'Authorization: Bearer <redacted>' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "openrouter/google/gemini-2.5-flash",
    "messages": [
      {
        "role": "user",
        "content": "hello"
      }
    ]
  }'

Environment

  • LiteLLM version: v1.82.3
  • Provider: OpenRouter
  • Flow: Admin UI -> Add Model -> select from list -> Test Connect

Notes

This looks related to earlier OpenRouter model ID issues, but this specific bug is about a model selected directly from the Admin UI list still failing validation.

extent analysis

Fix Plan

To resolve the issue, we need to ensure that the model ID sent in the API request matches the expected format by OpenRouter.

  1. Update the model ID format: Modify the code that constructs the API request to remove the openrouter/ prefix from the model ID.
  2. Verify the model ID: Before sending the request, validate that the model ID is in the correct format.

Example code changes:

# Before
model_id = "openrouter/google/gemini-2.5-flash"
data = {
    "model": model_id,
    "messages": [
        {
            "role": "user",
            "content": "hello"
        }
    ]
}

# After
model_id = "openrouter/google/gemini-2.5-flash"
# Remove the 'openrouter/' prefix
model_id = model_id.replace("openrouter/", "")
data = {
    "model": model_id,
    "messages": [
        {
            "role": "user",
            "content": "hello"
        }
    ]
}

Alternatively, you can also use string slicing to remove the prefix:

model_id = model_id[10:]  # Remove the first 10 characters ('openrouter/')

Verification

To verify that the fix worked, repeat the steps to reproduce the issue and check that the Test Connect flow succeeds. You can also inspect the API request to ensure that the model ID is sent in the correct format.

Extra Tips

  • Make sure to update the documentation and testing to reflect the correct model ID format.
  • Consider adding input validation to prevent similar issues in the future.
  • If you're using a library or framework to construct the API request, check the documentation to see if there are any built-in functions to handle model ID formatting.

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]: OpenRouter model selected from Admin UI list fails Test Connect with 'is not a valid model ID' [1 comments, 2 participants]