Incomplete text output - Token limit 200

Hi everyone,

I’ve been using the Gemini API for text summarization across different projects, but I’ve run into a strange issue with one of them.

The Use Case: I am processing call transcriptions to identify customer issues. The expected output is a concise summary like: “The root cause is…”

The Problem: Even though I have set max_output_tokens = 200 (which should be more than enough for a short phrase), the API response is getting cut off mid-word. For example, instead of finishing the sentence, the output abruptly ends like this:

“The root cause is inconsis”

Details:

  • Model: gemini-2.5-flash

Since Gemini 2.5 Flash has a large output limit, I don’t understand why it’s running out of tokens so early or why the generation is stopping abruptly.

Has anyone faced a similar truncation issue with Flash? Could this be related to the thinking budget?

Thanks in advance for the help!

Hi, max_output_tokens acts as a combined budget for both the thinking tokens and the final visible output tokens. If you set this too low the model might run out of tokens because of thinking tokens being used and truncate the final answer.

You could try experimenting with a combination of thinking_budget and max_output_tokens on 2.5 Flash for your use case to ensure responses are not truncated. Note that the newer models like 3 Flash and later don’t have the thinking_budget parameter and have a thinking_level parameter instead.