BerriAI/litellm · error · BadRequestError

OllamaException: Invalid Model/Model not loaded

Error message

OllamaException: Invalid Model/Model not loaded - {original_exception}

What it means

Ollama-specific mapping: when the error string contains 'no such file or directory', Ollama means the requested model is not installed/loaded locally; re-raised as litellm BadRequestError with an explanatory message.

Solutions

  1. Pull/load the model in Ollama first: ollama pull <model>.
  2. Check the model name matches an installed Ollama model (ollama list).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1809 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/f5b3e411518a28f8. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1809

    raise cast(Exception, original_exception)


def _map_ollama_exception(
    *,
    model: str,
    original_exception: _ProviderHTTPException,
    custom_llm_provider: str,
    error_str: str,
    exception_type: str,
    exception_provider: str,
    extra_information: str,
) -> None:
    if isinstance(original_exception, dict):
        error_str = original_exception.get("error", "")
    else:
        error_str = str(original_exception)
    if "no such file or directory" in error_str:
        raise BadRequestError(
            message=f"OllamaException: Invalid Model/Model not loaded - {original_exception}",
            model=model,
            llm_provider="ollama",
            response=getattr(original_exception, "response", None),
        )
    elif "Failed to establish a new connection" in error_str:
        raise ServiceUnavailableError(
            message=f"OllamaException: {original_exception}",
            llm_provider="ollama",
            model=model,
            response=getattr(original_exception, "response", None),
        )
    elif "Invalid response object from API" in error_str:
        raise BadRequestError(
            message=f"OllamaException: {original_exception}",
            llm_provider="ollama",
            model=model,
            response=getattr(original_exception, "response", None),

View on GitHub (pinned to 77b7c6c40c)