litellm - 💡(How to fix) Fix [Bug]: response API wrong model name resolution [1 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#26773Fetched 2026-04-30 06:20:09
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Error Message

{ "error": { "message": "litellm.BadRequestError: OpenrouterException - {"error":{"message":"openrouter/openai/gpt-4o is not a valid model ID","code":400},"user_id":"user_33T2s3poJxTY0aRaCzsDNON2Xb1"}. Received Model Group=mymodel\nAvailable Model Group Fallbacks=None", "type": null, "param": null, "code": "400" } }

Code Example

model_list:
  - model_name: openrouter/*
    litellm_params:
      model: openrouter/*
      api_base: https://openrouter.ai/api/v1
      api_key: os.environ/OPEN_ROUTER_API_KEY

  - model_name: mymodel
    litellm_params:
      model: openrouter/openai/gpt-4o
      api_key: os.environ/OPEN_ROUTER_API_KEY

# I also tested this configuration and observed the same behavior:
#router_settings:
#  model_group_alias:
#    "mymodel": "openrouter/openai/gpt-4o"

---

curl -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer sk-123' \
  -q -L -X POST 'https://llm.example.com/chat/completions' \
  -d '{
    "model": "mymodel",
    "messages": [
      {
        "role": "system",
        "content": "You are an LLM named MyModel"
      },
      {
        "role": "user",
        "content": "what is your name?"
      }
    ]
  }' | jq

---

{
  "id": "gen-1777462401-PcgnzN9w859JYuFh3g7h",
  "created": 1777462401,
  "model": "mymodel",
  "object": "chat.completion",
  "system_fingerprint": "fp_c9e874ca3a",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "I am MyModel, your language model assistant. How can I help you today?",
        "role": "assistant",
        "provider_specific_fields": {
          "reasoning": null,
          "refusal": null
        }
      },
      "provider_specific_fields": {
        "native_finish_reason": "stop"
      }
    }
  ],
  "usage": {
    "completion_tokens": 18,
    "prompt_tokens": 25,
    "total_tokens": 43,
    "completion_tokens_details": {
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "image_tokens": 0
    },
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0,
      "video_tokens": 0,
      "cache_write_tokens": 0
    },
    "cost": 0.0002425,
    "is_byok": false,
    "cost_details": {
      "upstream_inference_cost": 0.0002425,
      "upstream_inference_prompt_cost": 6.25e-05,
      "upstream_inference_completions_cost": 0.00018
    }
  },
  "provider": "OpenAI"
}

---

curl -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer sk-123' \
  -q -L -X POST 'https://llm.example.com/chat/completions' \
  -d '{
    "model": "mymodel",
    "input": [
      {
        "role": "system",
        "content": [
          {
            "type": "input_text",
            "text": "You are an LLM named MyModel"
          }
        ]
      },
      {
        "role": "user",
        "content": "what is your name?"
      }
    ],
    "store": false,
    "temperature": 0.5
  }' | jq

---

{
  "error": {
    "message": "litellm.BadRequestError: OpenrouterException - {\"error\":{\"message\":\"openrouter/openai/gpt-4o is not a valid model ID\",\"code\":400},\"user_id\":\"user_33T2s3poJxTY0aRaCzsDNON2Xb1\"}. Received Model Group=mymodel\nAvailable Model Group Fallbacks=None",
    "type": null,
    "param": null,
    "code": "400"
  }
}

---

openrouter/openai/gpt-4o is not a valid model ID

---

openrouter/openai/gpt-4o is not a valid model ID

---

litellm-1  | 11:33:21 - LiteLLM:DEBUG: utils.py:481 - Final returned optional params: {'stream': False, 'max_retries': 0, 'extra_body': {}}
litellm-1  | 11:33:21 - LiteLLM:DEBUG: litellm_logging.py:538 - self.optional_params: {'stream': False, 'max_retries': 0}
litellm-1  | 11:33:21 - LiteLLM:DEBUG: utils.py:5507 - checking potential_model_names in litellm.model_cost: {'split_model': 'openai/gpt-4o', 'combined_model_name': 'openrouter/openai/gpt-4o', 'stripped_model_name': 'openai/gpt-4o', 'combined_stripped_model_name': 'openrouter/openai/gpt-4o', 'custom_llm_provider': 'openrouter'}
litellm-1  | 11:33:21 - LiteLLM:DEBUG: litellm_logging.py:1131 -
litellm-1  |
litellm-1  | POST Request Sent from LiteLLM:
litellm-1  | curl -X POST \
litellm-1  | https://openrouter.ai/api/v1/chat/completions \
litellm-1  | -H 'HTTP-Referer: https://litellm.ai' -H 'X-Title: liteLLM' -H 'Authorization: Be****57' -H 'Content-Type: application/json' \
litellm-1  | -d '{'model': 'openai/gpt-4o', 'messages': [{'role': 'system', 'content': 'You are an LLM named MyModel'}, {'role': 'user', 'content': 'what is your name?'}], 'stream': False, 'usage': {'include': True}}'
litellm-1  |
litellm-1  |
litellm-1  | 11:33:21 - LiteLLM:DEBUG: litellm_logging.py:1204 - RAW RESPONSE:

---

litellm-1  | 11:33:40 - LiteLLM:DEBUG: llm_http_handler.py:2238 - Creating HTTP client for responses API with shared_session: 140659107816384
litellm-1  | 11:33:40 - LiteLLM:DEBUG: litellm_logging.py:1131 -
litellm-1  |
litellm-1  | POST Request Sent from LiteLLM:
litellm-1  | curl -X POST \
litellm-1  | https://openrouter.ai/api/v1/responses \
litellm-1  | -H 'Authorization: Be****34' \
litellm-1  | -d '{'model': 'openrouter/openai/gpt-4o', 'input': [{'role': 'system', 'content': [{'type': 'input_text', 'text': 'You are an LLM named MyModel'}]}, {'content': 'what is your name?', 'role': 'user'}], 'store': False, 'temperature': 0.5}'
litellm-1  |
litellm-1  |
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?

Hi, thank you for your great app.

The Responses API (/v1/responses) does not use the correct model name when using an alias.

I have the following configuration:

model_list:
  - model_name: openrouter/*
    litellm_params:
      model: openrouter/*
      api_base: https://openrouter.ai/api/v1
      api_key: os.environ/OPEN_ROUTER_API_KEY

  - model_name: mymodel
    litellm_params:
      model: openrouter/openai/gpt-4o
      api_key: os.environ/OPEN_ROUTER_API_KEY

# I also tested this configuration and observed the same behavior:
#router_settings:
#  model_group_alias:
#    "mymodel": "openrouter/openai/gpt-4o"

Assume the following two curl requests.

Using /chat/completions:

curl -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer sk-123' \
  -q -L -X POST 'https://llm.example.com/chat/completions' \
  -d '{
    "model": "mymodel",
    "messages": [
      {
        "role": "system",
        "content": "You are an LLM named MyModel"
      },
      {
        "role": "user",
        "content": "what is your name?"
      }
    ]
  }' | jq

It return this response:

{
  "id": "gen-1777462401-PcgnzN9w859JYuFh3g7h",
  "created": 1777462401,
  "model": "mymodel",
  "object": "chat.completion",
  "system_fingerprint": "fp_c9e874ca3a",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "I am MyModel, your language model assistant. How can I help you today?",
        "role": "assistant",
        "provider_specific_fields": {
          "reasoning": null,
          "refusal": null
        }
      },
      "provider_specific_fields": {
        "native_finish_reason": "stop"
      }
    }
  ],
  "usage": {
    "completion_tokens": 18,
    "prompt_tokens": 25,
    "total_tokens": 43,
    "completion_tokens_details": {
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "image_tokens": 0
    },
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0,
      "video_tokens": 0,
      "cache_write_tokens": 0
    },
    "cost": 0.0002425,
    "is_byok": false,
    "cost_details": {
      "upstream_inference_cost": 0.0002425,
      "upstream_inference_prompt_cost": 6.25e-05,
      "upstream_inference_completions_cost": 0.00018
    }
  },
  "provider": "OpenAI"
}

Using /v1/responses

curl -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer sk-123' \
  -q -L -X POST 'https://llm.example.com/chat/completions' \
  -d '{
    "model": "mymodel",
    "input": [
      {
        "role": "system",
        "content": [
          {
            "type": "input_text",
            "text": "You are an LLM named MyModel"
          }
        ]
      },
      {
        "role": "user",
        "content": "what is your name?"
      }
    ],
    "store": false,
    "temperature": 0.5
  }' | jq

It return this error:

{
  "error": {
    "message": "litellm.BadRequestError: OpenrouterException - {\"error\":{\"message\":\"openrouter/openai/gpt-4o is not a valid model ID\",\"code\":400},\"user_id\":\"user_33T2s3poJxTY0aRaCzsDNON2Xb1\"}. Received Model Group=mymodel\nAvailable Model Group Fallbacks=None",
    "type": null,
    "param": null,
    "code": "400"
  }
}

As shown above, unlike /chat/completions, the /v1/responses endpoint does not correctly resolve the mymodel alias to the OpenRouter model. Instead, it sends openrouter/openai/gpt-4o as the model ID to OpenRouter, which causes OpenRouter to reject the request with:

openrouter/openai/gpt-4o is not a valid model ID

Steps to Reproduce

  1. Set and alias to a model using ether model_list.model_name or router_settings.model_group_alias
  2. Use that model in /chat/completions API
  3. Use that model in /v1/responses API

Expected behavior:

/v1/responses should resolve and route aliases in the same way as /chat/completions.

Actual behavior:

/v1/responses appears to pass the internal LiteLLM/OpenRouter-prefixed model name directly to OpenRouter, causing the request to fail.

Relevant log output

The logs shows that, unlike /chat/completions, the /v1/responses endpoint does not correctly resolve the mymodel alias to the OpenRouter model. Instead, it sends openrouter/openai/gpt-4o as the model ID to OpenRouter, which causes OpenRouter to reject the request with:

openrouter/openai/gpt-4o is not a valid model ID

/chat/completions

litellm-1  | 11:33:21 - LiteLLM:DEBUG: utils.py:481 - Final returned optional params: {'stream': False, 'max_retries': 0, 'extra_body': {}}
litellm-1  | 11:33:21 - LiteLLM:DEBUG: litellm_logging.py:538 - self.optional_params: {'stream': False, 'max_retries': 0}
litellm-1  | 11:33:21 - LiteLLM:DEBUG: utils.py:5507 - checking potential_model_names in litellm.model_cost: {'split_model': 'openai/gpt-4o', 'combined_model_name': 'openrouter/openai/gpt-4o', 'stripped_model_name': 'openai/gpt-4o', 'combined_stripped_model_name': 'openrouter/openai/gpt-4o', 'custom_llm_provider': 'openrouter'}
litellm-1  | 11:33:21 - LiteLLM:DEBUG: litellm_logging.py:1131 -
litellm-1  |
litellm-1  | POST Request Sent from LiteLLM:
litellm-1  | curl -X POST \
litellm-1  | https://openrouter.ai/api/v1/chat/completions \
litellm-1  | -H 'HTTP-Referer: https://litellm.ai' -H 'X-Title: liteLLM' -H 'Authorization: Be****57' -H 'Content-Type: application/json' \
litellm-1  | -d '{'model': 'openai/gpt-4o', 'messages': [{'role': 'system', 'content': 'You are an LLM named MyModel'}, {'role': 'user', 'content': 'what is your name?'}], 'stream': False, 'usage': {'include': True}}'
litellm-1  |
litellm-1  |
litellm-1  | 11:33:21 - LiteLLM:DEBUG: litellm_logging.py:1204 - RAW RESPONSE:

/v1/responses

litellm-1  | 11:33:40 - LiteLLM:DEBUG: llm_http_handler.py:2238 - Creating HTTP client for responses API with shared_session: 140659107816384
litellm-1  | 11:33:40 - LiteLLM:DEBUG: litellm_logging.py:1131 -
litellm-1  |
litellm-1  | POST Request Sent from LiteLLM:
litellm-1  | curl -X POST \
litellm-1  | https://openrouter.ai/api/v1/responses \
litellm-1  | -H 'Authorization: Be****34' \
litellm-1  | -d '{'model': 'openrouter/openai/gpt-4o', 'input': [{'role': 'system', 'content': [{'type': 'input_text', 'text': 'You are an LLM named MyModel'}]}, {'content': 'what is your name?', 'role': 'user'}], 'store': False, 'temperature': 0.5}'
litellm-1  |
litellm-1  |

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.3

Twitter / LinkedIn details

No response

extent analysis

TL;DR

The /v1/responses endpoint does not correctly resolve the model alias, causing the request to fail with an invalid model ID error.

Guidance

  • The issue seems to be related to how the model alias is being resolved in the /v1/responses endpoint.
  • Compare the request payloads for /chat/completions and /v1/responses to identify any differences in how the model is specified.
  • Verify that the model_list configuration is being applied correctly to the /v1/responses endpoint.
  • Check if there are any endpoint-specific settings or overrides that might be causing the discrepancy.

Example

No code example is provided as the issue seems to be related to configuration or endpoint-specific behavior.

Notes

The issue might be specific to the v1.82.3 version of LiteLLM, and it's recommended to check the documentation or release notes for any known issues or updates related to model alias resolution.

Recommendation

Apply a workaround by ensuring that the model alias is correctly resolved in the /v1/responses endpoint, potentially by updating the configuration or modifying the request payload to match the expected format.

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]: response API wrong model name resolution [1 participants]