BerriAI/litellm · error · ServiceUnavailableError

OllamaException

Error message

OllamaException: {original_exception}

What it means

Ollama-specific catch-all: any Ollama error not matched by specific branches is re-raised as a normalized litellm exception with the original OllamaException text, keeping the local-server error visible to the caller.

Solutions

  1. Ensure the Ollama server is running and reachable at the configured api_base.
  2. Review the original Ollama exception for the specific cause.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1816 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/b1e02662b53942e6. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1816

    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),
        )
    elif "Read timed out" in error_str:
        raise Timeout(
            message=f"OllamaException: {original_exception}",
            llm_provider="ollama",
            model=model,
        )

View on GitHub (pinned to 77b7c6c40c)