BerriAI/litellm · error · NotFoundError
Model with id={model_id} not found
Error message
Model with id={model_id} not found What it means
Raised by ModelsManagementClient.get() after it fetched the full list from GET {base_url}/v1/model/info and found no entry whose model_info.id equals model_id or whose model_name equals model_name. It wraps a synthetic requests.exceptions.HTTPError carrying the message 'Model with id=... not found' / 'Model with model_name=... not found' and an empty requests.Response — no real HTTP 401/404 happened at this point; the miss is detected by local equality filtering, so casing and whitespace must match exactly.
Source
Thrown at litellm/proxy/client/models.py:204
# Get all models and filter
models: Final = self.info()
assert isinstance(models, list)
# Find the matching model
for model in models:
if (model_id and model.get("model_info", {}).get("id") == model_id) or (
model_name and model.get("model_name") == model_name
):
return model
# If we get here, no model was found
if model_id:
msg = f"Model with id={model_id} not found"
elif model_name:
msg = f"Model with model_name={model_name} not found"
else:
msg = "Unknown error trying to find model"
raise NotFoundError(
requests.exceptions.HTTPError(
msg,
response=requests.Response(), # Empty response since we didn't make a direct request
)
)
def info(self, return_request: bool = False) -> builtins.list[dict[str, Any]] | requests.Request:
"""
Get detailed information about all models from the server.
Args:
return_request (bool): If True, returns the prepared request object instead of executing it
Returns:
Union[List[Dict[str, Any]], requests.Request]: Either a list of model information dictionaries
or a prepared request object if return_request is True
Raises:View on GitHub (pinned to 77b7c6c40c)
Solutions
- List what actually exists — [m.get('model_name') for m in models.info()] — and use an exact string from it
- Normalize input before calling: model_name.strip() and match the proxy's casing
- If the model should exist, check the proxy config/DB and confirm base_url points at the right deployment
- Catch NotFoundError to degrade gracefully when optional models are absent
Example fix
# before
client.models.get(model_name="GPT-4O") # NotFoundError: Model with model_name=GPT-4O not found
# after
from litellm.proxy.client.exceptions import NotFoundError
try:
client.models.get(model_name="gpt-4o")
except NotFoundError:
available = [m.get("model_name") for m in client.models.info()]
raise RuntimeError(f"model not deployed; available: {available}") from None Defensive patterns
Strategy: try-catch
Validate before calling
def find_model(models_client, model_id: str | None = None, model_name: str | None = None):
key, want = ("id", model_id) if model_id else ("name", model_name)
if want is not None:
want = want.strip()
for m in models_client.info():
if model_id and m.get("model_info", {}).get("id") == want:
return m
if model_name and m.get("model_name") == want:
return m
return None # resolve absence yourself instead of catching Try / catch
from litellm.proxy.client.exceptions import NotFoundError
try:
model = models.get(model_name=name.strip())
except NotFoundError as e:
available = sorted(m.get("model_name") for m in models.info())
raise RuntimeError(f"{e} — deployed models: {available}") from None Prevention
- Source names from models.info()/list() output rather than hardcoding, or validate against it first
- Strip whitespace and match the proxy's exact casing — filtering is plain equality
- Catch NotFoundError to branch when optional models are absent instead of crashing
When it happens
Trigger: Requesting a model_name not deployed on this proxy (typos, wrong casing like 'GPT-4o' vs 'gpt-4o', environment-specific names); a stale model_id after config or database changes; input with surrounding whitespace; calling against the wrong base_url whose deployment lacks the model.
Common situations: Shared code across environments where model names differ; hardcoded names drifting from the deployed config; ids cached from a previous deployment; user-supplied names not trimmed.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Exactly one of model_id or model_name must be provided
- {e}
- LiteLLM Managed File object with id={file_id} not found
- 404
- Organization doesn't exist in db. Organization={org_id}. Cre
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/2084dcf1f5269ad9.
Report an issue: GitHub.