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

  1. Verify the exact model id against the provider's models endpoint (or litellm model_list/get_model_info) and correct model=.
  2. For Azure, ensure the model maps to an existing deployment name; for the proxy, check model_list entries match what the key can access.
  3. 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

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


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/4e28009383242f27. Report an issue: GitHub.