BerriAI/litellm · error · ValueError

Failed to decode JSON from chunk: {chunk}

Error message

Failed to decode JSON from chunk: {chunk}

What it means

Error "Failed to decode JSON from chunk: {chunk}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/anthropic/completion/transformation.py:289

            if _chunk_text is not None and isinstance(_chunk_text, str):
                text = _chunk_text
            finish_reason = chunk.get("stop_reason") or ""
            if finish_reason is not None:
                is_finished = True
            returned_chunk: Final = GenericStreamingChunk(
                text=text,
                tool_use=tool_use,
                is_finished=is_finished,
                finish_reason=finish_reason,
                usage=usage,
                index=index,
                provider_specific_fields=provider_specific_fields,
            )

            return returned_chunk

        except json.JSONDecodeError:
            raise ValueError(f"Failed to decode JSON from chunk: {chunk}")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. The stream chunk was not valid JSON; check for proxy interference or provider issues.

When it happens

Trigger: Thrown at litellm/llms/anthropic/completion/transformation.py:289 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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