Hi, this issue is still present. I’m using the following code with the new Google GenAI Python SDK:
gen_config = types.GenerateContentConfig(
system_instruction=instruction,
top_p=0.9,
top_k=60,
temperature=0.7,
safety_settings=disabled_safety,
response_mime_type="application/json",
response_schema=groups_schema,
)
groups_fragment_response = await gemini_client.generate_content(
contents=json_str,
genconfig=gen_config,
gemini_model_type=self.gemini_model_type
)
I’ve tried disabling JSON mode and manually setting the max output tokens to 1,000,000, but I still get this error from time to time:
candidates=[Candidate(content=Content(parts=None, role='model'), citation_metadata=None, finish_message=None, token_count=None, finish_reason=<FinishReason.MAX_TOKENS: 'MAX_TOKENS'>, avg_logprobs=None, grounding_metadata=None, index=0, logprobs_result=None, safety_ratings=None)] create_time=None response_id=None model_version='models/gemini-2.5-flash-preview-05-20' prompt_feedback=None usage_metadata=GenerateContentResponseUsageMetadata(cache_tokens_details=None, cached_content_token_count=None, candidates_token_count=None, candidates_tokens_details=None, prompt_token_count=194494, prompt_tokens_details=[ModalityTokenCount(modality=<MediaModality.TEXT: 'TEXT'>, token_count=194494)], thoughts_token_count=65535, tool_use_prompt_token_count=None, tool_use_prompt_tokens_details=None, total_token_count=260029, traffic_type=None) automatic_function_calling_history=[] parsed=None