litellm - 💡(How to fix) Fix [Bug]: streamGenerateContent returns 500 when model is missing, should return 404 model not found

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

Internal Server Error%

Code Example

curl -i -L -X POST 'https://localhost:4000/v1beta/models/gemini/gemini-3.1-flash-lite-preview:streamGenerateContent' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer token123' \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Explain quantum computing"
          }
        ],
        "role": "user"
      }
    ],
    "generationConfig": {
      "maxOutputTokens": 500
    }
  }'
HTTP/2 500
content-type: text/plain; charset=utf-8
date: Wed, 27 May 2026 17:32:26 GMT
server: uvicorn
content-length: 21

Internal Server Error%

---
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?

If you use a gemini model that its deprecated, you get a 500 instead of a 404 like the rest of the apis :

curl -i -L -X POST 'https://localhost:4000/v1beta/models/gemini/gemini-3.1-flash-lite-preview:streamGenerateContent' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer token123' \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Explain quantum computing"
          }
        ],
        "role": "user"
      }
    ],
    "generationConfig": {
      "maxOutputTokens": 500
    }
  }'
HTTP/2 500
content-type: text/plain; charset=utf-8
date: Wed, 27 May 2026 17:32:26 GMT
server: uvicorn
content-length: 21

Internal Server Error%

The 500 should be actually a 404

Steps to Reproduce

Relevant log output

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.83.14

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]: streamGenerateContent returns 500 when model is missing, should return 404 model not found