I am asking gemini 2.5 flash with the latest genai js sdk to extract information from a png image, I call the generateContent command and pass a config like so
config: {
systemInstruction: `look at the picture and extract the parts`,
temperature: 0,
thinkingConfig: {
thinkingBudget: 4096,
},
maxOutputTokens: 8096
}
I also pass a json schema as well. The problem is the model seems to be ignoring the thinking budget and having ârunaway thoughtsâ if i increase the max tokens it will think until it hits the max tokens.
usageMetadata: {
[0] promptTokenCount: 1886,
[0] totalTokenCount: 9981,
[0] trafficType: âON_DEMANDâ,
[0] promptTokensDetails: [ [Object], [Object] ],
[0] thoughtsTokenCount: 8095
[0] }
EDIT:
I just removed the json schema from the call and it seems to respect the thinking budget now. so it appears that is the problem. Also if i reduce the thinkingbudget to like 1024 then it seems to respect it more often.