BerriAI/litellm · error · NotFoundError
{exception_provider} - {message}
Error message
{exception_provider} - {message} What it means
Normalized NotFoundError from the exception-mapping chain: the provider error string contains both 'invalid_request_error' and 'model_not_found', so litellm maps it to NotFoundError with the message '<Provider>Exception - <original message>'. It means the requested model does not exist for that API key/account/deployment.
Source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:306
if ExceptionCheckers.is_error_str_rate_limit(
error_str, status_code=getattr(original_exception, "status_code", None)
):
raise RateLimitError(
message=f"RateLimitError: {exception_provider} - {message}",
model=model,
llm_provider=custom_llm_provider,
response=getattr(original_exception, "response", None),
)
elif ExceptionCheckers.is_error_str_context_window_exceeded(error_str):
raise ContextWindowExceededError(
message=f"ContextWindowExceededError: {exception_provider} - {message}",
llm_provider=custom_llm_provider,
model=model,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif "invalid_request_error" in error_str and "model_not_found" in error_str:
raise NotFoundError(
message=f"{exception_provider} - {message}",
llm_provider=custom_llm_provider,
model=model,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif "A timeout occurred" in error_str:
raise Timeout(
message=f"{exception_provider} - {message}",
model=model,
llm_provider=custom_llm_provider,
litellm_debug_info=extra_information,
)
elif (
("invalid_request_error" in error_str and "content_policy_violation" in error_str)
or ("Invalid prompt" in error_str and "violating our usage policy" in error_str)
or ("request was rejected as a result of the safety system" in error_str.lower())
):View on GitHub (pinned to 6c2dcb801b)
Solutions
- Verify the exact model id against the provider's models endpoint (or litellm model_list/get_model_info) and correct model=.
- For Azure, ensure the model maps to an existing deployment name; for the proxy, check model_list entries match what the key can access.
- Remove stale hard-coded names; source them from a validated catalog or env var to avoid drift when providers rename models.
Example fix
# before litellm.completion(model="gpt-4o-mini-pro", messages=m) # typo -> NotFoundError # after litellm.completion(model="gpt-4o-mini", messages=m) # discover valid ids: litellm.model_list; openai client.models.list()
Defensive patterns
Strategy: type-guard
Validate before calling
import litellm
def model_exists(model: str) -> bool:
return model in {m["model_name"] for m in litellm.model_list} or model in litellm.model_cost.keys() Type guard
from litellm import NotFoundError
def is_model_not_found(exc: BaseException) -> bool:
return isinstance(exc, NotFoundError) and "model" in str(exc).lower() Try / catch
from litellm import NotFoundError
try:
resp = litellm.completion(model=m, messages=msgs)
except NotFoundError as e:
m = FALLBACK_MODEL # only if you intended a fallback; else surface 404 to caller
resp = litellm.completion(model=m, messages=msgs) Prevention
- Source model ids from litellm.model_list or the provider's models endpoint.
- Validate model names in config at startup and prune unknown entries.
- After provider model renames/deprecations, run a config audit before deploying.
When it happens
Trigger: Calling a model name the key has no access to ('gpt-4o' on an org without access), typos in model names ('gpt-4o-mini ' with whitespace, 'gpt4o'), using a custom/in-house model name on a base URL where it isn't deployed, or referencing a fine-tune/deployment that was deleted.
Common situations: Model deprecated/renamed by the provider and old names kept in config; proxy deployments listing models the backing key can't see; typos or casing mistakes in model=; pointing at Azure with an OpenAI public model name (missing deployment mapping).
Related errors
- ContextWindowExceededError: {exception_provider} - {message}
- ContentPolicyViolationError: {exception_provider} - {message
- File not found. blocked_user_list={blocked_user_list}
- model_name not set for LlamaGuard
- File not found. file_path={file_path}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/4e28009383242f27.
Report an issue: GitHub.