BerriAI/litellm · error · Exception

Ollama Error

Error message

Ollama Error - {chunk}

What it means

Error "Ollama Error - {chunk}" thrown in BerriAI/litellm.

Solutions

  1. Read the Ollama error chunk in the message; common fixes are pulling the model (ollama pull <model>) and checking the Ollama server is running.

When it happens

Trigger: Thrown at litellm/llms/ollama/completion/transformation.py:458 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/95dd29b48d546f52. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/ollama/completion/transformation.py:458

            streaming_response=streaming_response,
            sync_stream=sync_stream,
            json_mode=json_mode,
        )


class OllamaTextCompletionResponseIterator(BaseModelResponseIterator):
    def __init__(self, streaming_response, sync_stream: bool, json_mode: bool | None = False):
        super().__init__(streaming_response, sync_stream, json_mode)
        self.started_reasoning_content: bool = False
        self.finished_reasoning_content: bool = False

    def _handle_string_chunk(self, str_line: str) -> GenericStreamingChunk | ModelResponseStream:
        return self.chunk_parser(json.loads(str_line))

    def chunk_parser(self, chunk: dict) -> GenericStreamingChunk | ModelResponseStream:
        try:
            if "error" in chunk:
                raise Exception(f"Ollama Error - {chunk}")

            text = ""
            is_finished = False
            finish_reason = None
            if chunk["done"] is True:
                text = ""
                is_finished = True
                finish_reason = "stop"
                prompt_eval_count: Final[int | None] = chunk.get("prompt_eval_count", None)
                eval_count: Final[int | None] = chunk.get("eval_count", None)

                usage: ChatCompletionUsageBlock | None = None
                if prompt_eval_count is not None and eval_count is not None:
                    usage = ChatCompletionUsageBlock(
                        prompt_tokens=prompt_eval_count,
                        completion_tokens=eval_count,
                        total_tokens=prompt_eval_count + eval_count,
                    )

View on GitHub (pinned to 77b7c6c40c)