Hello developer,
Could you please tell me why I’m getting an error? I didn’t ask for any information that violates policies.
I am using the Gemini 2.5 Flash model.
Preformatted text Invalid operation: The response.text
quick accessor requires the response to contain a valid Part
, but none were returned. The candidate’s finish_reason is 2.
In your case, the finish_reason
is 2
, which corresponds to MAX_TOKENS
. This indicates that the model stopped generating content because it reached the maximum token limit specified in your request.
To handle this situation gracefully, you can check the finish_reason
before attempting to access response.text
.
Thank you for your reply. I have already resolved the issue.
May I ask whether the thinking process of 2.5flash is also counted as output tokens?
In the context of API usage or token limits, the model’s response—whether it’s intermediate or final—is typically counted as output tokens.