On Gemini models that think, the tokens spent on reasoning count against max_output_tokens before the first word of the answer is written. The failure is quiet: no exception, HTTP 200, and a response whose text is an empty string.
I reproduced it on purpose on 10 November 2026 with one arithmetic question (a train problem with a known answer, 11:49, asked for in one sentence, so a correct reply is about 15 tokens) and a ladder of output limits, recording the token counts the API reports. Everything below is from that run with one free-tier key.
from google import genai
from google.genai import types
client = genai.Client()
def run(model, level, max_tokens=None):
cfg = types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(thinking_level=level),
max_output_tokens=max_tokens,
)
r = client.models.generate_content(model=model, contents=PROMPT, config=cfg)
u = r.usage_metadata
return {
"finish": r.candidates[0].finish_reason,
"text_chars": len(r.text or ""),
"thoughts": u.thoughts_token_count,
"answer_tokens": u.candidates_token_count,
}
run("gemini-3.6-flash", "high", 60) returned MAX_TOKENS, zero characters of text, 57 thought tokens and 0 answer tokens. The usage fields are the diagnosis: thoughts_token_count next to candidates_token_count shows where the budget went.
At a limit of 60, gemini-3-flash-preview spent 56 tokens on thoughts and returned an empty string. gemini-3.5-flash-lite spent 53 on thoughts and returned 3 answer tokens, the words "They will meet". All ended with MAX_TOKENS, but only some gave an empty string to notice; the others gave a fragment that looks like text.
On gemini-3.6-flash at high thinking, thinking took almost the whole allowance every time:
A truncated reply is worse than an empty one for a pipeline, because that cut-off text passes an if text: check.
Without any limit, gemini-3-flash-preview used 21,607 thinking tokens at high and 1,325 at low for the same question. A limit of a few hundred is far too small for a thinking model, and 4,000 was still not enough at high on that model: the answer came back cut off after 160 tokens.
Lowering the level is not free either: gemini-3.5-flash-lite at low used 0 thinking tokens and answered 12:00 PM, where the right answer is 11:49.
candidates[0].finish_reason before you read text; an empty text together with MAX_TOKENS means the budget was spent on thinking.thoughts_token_count and candidates_token_count together.
One question, one free-tier key, one day. Some models hit their daily free quota during the work, which is why the results mix models. Model behaviour and limits change, so run the probe on your own setup.
More detail and the FAQ: https://aiandsoftwarehub.com/blog/gemini-api-returns-empty-text-with-finishreason-max-tokens-thinking-tokens-eat-y