litellm - 💡(How to fix) Fix [Bug]: Not able to add openrouter model as endpoint [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#26199Fetched 2026-04-22 07:45:45
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Error Message

Error: OpenrouterException - {"error":{"message":"openrouter/openrouter/free is not a valid model ID","code":400},"user_id":"user_3CPzNQdGnhemSE8rJv8M8IGGLPu"}

litellm.BadRequestError: OpenrouterException - {"error":{"message":"openrouter/openrouter/free is not a valid model ID","code":400},"user_id":"user_3CPzNQdGnhemSE8rJv8M8IGGLPu"} stack trace: Traceback (most recent call last): File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 175, in _make_common_async_call response = await async_httpx_client.post( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<10 lines>... ) ^ File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/logging_utils.py", line 297, in async_wrapper result = await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 513, in post raise e File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 469, in post response.raise_for_status() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status raise HTTPStatusError(message, request=request, response=self) httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://ope

Code Example

Error:
OpenrouterException - {"error":{"message":"openrouter/openrouter/free is not a valid model ID","code":400},"user_id":"user_3CPzNQdGnhemSE8rJv8M8IGGLPu"}

litellm.BadRequestError: OpenrouterException - {"error":{"message":"openrouter/openrouter/free is not a valid model ID","code":400},"user_id":"user_3CPzNQdGnhemSE8rJv8M8IGGLPu"}
stack trace: Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 175, in _make_common_async_call
    response = await async_httpx_client.post(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<10 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/logging_utils.py", line 297, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 513, in post
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 469, in post
    response.raise_for_status()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://ope

---

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrouter/free",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

{"id":"gen-1776809776-CyJqcXfnx9XSL51KnD9a","object":"chat.completion","created":1776809776,"model":"openai/gpt-oss-20b:free","provider":"OpenInference","system_fingerprint":null,"choices":[{"index":0,"logprobs":null,"finish_reason":"stop","native_finish_reason":"stop","message":{"role":"assistant","content":"Hello! How can I help you today?","refusal":null,"reasoning":"Just greet.","reasoning_details":[{"type":"reasoning.text","text":"Just greet.","format":"unknown","index":0}]}}],"usage":{"prompt_tokens":69,"completion_tokens":22,"total_tokens":91,"cost":0,"is_byok":false,"prompt_tokens_details":{"cached_tokens":64,"cache_write_tokens":0,"audio_tokens":0,"video_tokens":0},"cost_details":{"upstream_inference_cost":0,"upstream_inference_prompt_cost":0,"upstream_inference_completions_cost":0},"completion_tokens_details":{"reasoning_tokens":3,"image_tokens":0,"audio_tokens":0}}}
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?

I have deployed litellm proxy using docker-compose file. I am able to configure local models which are available locally via UI.

Now when i try to configure "Add Model" with Provider: Openrouter LiteLLM Model Name: "openrouter/openrouter/free"
API-Key:"OPENROUTER_API_KEY"

Now If I click test connection it just fails

Steps to Reproduce

Added in description

Relevant log output

Error:
OpenrouterException - {"error":{"message":"openrouter/openrouter/free is not a valid model ID","code":400},"user_id":"user_3CPzNQdGnhemSE8rJv8M8IGGLPu"}

litellm.BadRequestError: OpenrouterException - {"error":{"message":"openrouter/openrouter/free is not a valid model ID","code":400},"user_id":"user_3CPzNQdGnhemSE8rJv8M8IGGLPu"}
stack trace: Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/llm_http_handler.py", line 175, in _make_common_async_call
    response = await async_httpx_client.post(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<10 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/logging_utils.py", line 297, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 513, in post
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 469, in post
    response.raise_for_status()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://ope

If run the below CURL command with the same OPENROUTER_API_KEY it just works fine

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrouter/free",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

{"id":"gen-1776809776-CyJqcXfnx9XSL51KnD9a","object":"chat.completion","created":1776809776,"model":"openai/gpt-oss-20b:free","provider":"OpenInference","system_fingerprint":null,"choices":[{"index":0,"logprobs":null,"finish_reason":"stop","native_finish_reason":"stop","message":{"role":"assistant","content":"Hello! How can I help you today?","refusal":null,"reasoning":"Just greet.","reasoning_details":[{"type":"reasoning.text","text":"Just greet.","format":"unknown","index":0}]}}],"usage":{"prompt_tokens":69,"completion_tokens":22,"total_tokens":91,"cost":0,"is_byok":false,"prompt_tokens_details":{"cached_tokens":64,"cache_write_tokens":0,"audio_tokens":0,"video_tokens":0},"cost_details":{"upstream_inference_cost":0,"upstream_inference_prompt_cost":0,"upstream_inference_completions_cost":0},"completion_tokens_details":{"reasoning_tokens":3,"image_tokens":0,"audio_tokens":0}}}

What part of LiteLLM is this about?

UI Dashboard

What LiteLLM version are you on ?

v1.82.3

Twitter / LinkedIn details

No response

extent analysis

TL;DR

The issue is likely due to an invalid model ID being passed to the OpenRouter API, which can be resolved by verifying the correct model ID and updating the configuration accordingly.

Guidance

  • Verify that the model ID "openrouter/openrouter/free" is correct and supported by the OpenRouter API.
  • Check the OpenRouter API documentation to ensure that the model ID format is correct and that the model is available for use.
  • Compare the model ID used in the CURL command ("model": "openrouter/free") with the one used in the LiteLLM configuration (LiteLLM Model Name: "openrouter/openrouter/free"), and update the configuration to match the working CURL command.
  • Test the connection again after updating the configuration to ensure that the issue is resolved.

Example

No code snippet is provided as the issue seems to be related to configuration rather than code.

Notes

The issue may be specific to the OpenRouter API and the LiteLLM version being used (v1.82.3). It's possible that the model ID format has changed or that there are specific requirements for using the OpenRouter API with LiteLLM.

Recommendation

Apply workaround: Update the LiteLLM configuration to use the correct model ID, as verified through the OpenRouter API documentation and the working CURL command. This should resolve the issue and allow the connection to be established successfully.

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]: Not able to add openrouter model as endpoint [1 participants]