High severity HTTP 400 beginner · Fix: 2-5 min

BadRequestError

litellm.errors.BadRequestError: model not supported

What this error means
LiteLLM throws BadRequestError when the requested model name is invalid or not supported by the API.

Stack trace

traceback
litellm.errors.BadRequestError: model not supported
  File "/app/main.py", line 42, in <module>
    response = client.chat.completions.create(model="unsupported-model", messages=messages)
  File "/usr/local/lib/python3.9/site-packages/litellm/client.py", line 88, in create
    raise BadRequestError("model not supported")
QUICK FIX
Replace the model parameter with a valid, supported model name exactly as documented by LiteLLM.

Why it happens

This error occurs because the model name passed to LiteLLM's API is either misspelled, deprecated, or not available in the current deployment. The API validates the model parameter and rejects unsupported values with a BadRequestError.

Detection

Check the model parameter before making the API call by validating against the list of supported models from LiteLLM's documentation or via an API endpoint if available.

Causes & fixes

1

Using a model name that does not exist or is misspelled

✓ Fix

Verify the exact model name supported by LiteLLM and correct any typos or casing errors in your code.

2

Requesting a model that is deprecated or removed from the LiteLLM service

✓ Fix

Update your code to use a currently supported model version as listed in the latest LiteLLM documentation.

3

Passing an empty or null string as the model parameter

✓ Fix

Ensure the model parameter is a non-empty string matching a valid model name before calling the API.

Code: broken vs fixed

Broken - triggers the error
python
from litellm import LiteLLM
client = LiteLLM()
messages = [{"role": "user", "content": "Hello"}]
response = client.chat.completions.create(model="unsupported-model", messages=messages)  # triggers BadRequestError
Fixed - works correctly
python
import os
from litellm import LiteLLM
client = LiteLLM(api_key=os.environ["LITELLM_API_KEY"])
messages = [{"role": "user", "content": "Hello"}]
response = client.chat.completions.create(model="gpt-4o-mini", messages=messages)  # fixed with supported model
print(response)
Changed the model parameter to a valid supported model name 'gpt-4o-mini' and added API key usage from environment for proper authentication.

Workaround

Catch BadRequestError exceptions and fallback to a default supported model name programmatically to avoid crashes.

Prevention

Always retrieve and cache the list of supported models from LiteLLM's API or documentation and validate model names before making requests.

Python 3.9+ · litellm >=0.1.0 · tested on 0.2.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.