Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Gemini CLI error

Gemini CLI: API Error: Model stream ended with an invalid chunk or missing finish reason

Error message
[API Error: Model stream ended with an invalid chunk or missing finish reason.]

Status: WorkaroundLast verified 1 documented fix4 sources

What it means

The model's streamed response ended without a valid finish reason or content, so the turn stopped mid-task. Current source raises this as InvalidStreamError with types such as NO_FINISH_REASON and MALFORMED_FUNCTION_CALL (for example "Model stream ended without a finish reason.").

Causes

  • The response stream from the model ended without a finish reason or with malformed content (InvalidStreamError in core/geminiChat.ts). No root cause beyond this was stated by maintainers in #7851.

How to fix it

  1. Fix 1.

    Update the CLI. In #7851 a maintainer (SandyTao520) asked the reporter to update to v0.3.4. Invalid-stream handling was later changed in v0.7.0 (#9169 "Retry invalid stream only 1 time") and v0.42.0 (#26218 "handle InvalidStream event gracefully without throwing").

    Terminal
    npm install -g @google/gemini-cli@latest

More Gemini CLI errors

All 19 Gemini CLI errors

FAQ

What does "API Error: Model stream ended with an invalid chunk or missing finish reason" mean in Gemini CLI?

The model's streamed response ended without a valid finish reason or content, so the turn stopped mid-task. Current source raises this as InvalidStreamError with types such as NO_FINISH_REASON and MALFORMED_FUNCTION_CALL (for example "Model stream ended without a finish reason.").

How do I fix "API Error: Model stream ended with an invalid chunk or missing finish reason"?

Update the CLI. In #7851 a maintainer (SandyTao520) asked the reporter to update to v0.3.4. Invalid-stream handling was later changed in v0.7.0 (#9169 "Retry invalid stream only 1 time") and v0.42.0 (#26218 "handle InvalidStream event gracefully without throwing").

Is this Gemini CLI error fixed?

Status: Workaround. No release removes the cause. The documented fixes work around it. Affected versions: Reported on 0.3.3 (#7851)

Sources

Last verified against 4 sources: official docs, maintainer replies and release notes.

Newsletter

Fixes for the tools you use, weekly

One email per week. New coding agent releases, what broke, and how developers are working around it.