Gemini 3.5 Multi-turn 400 Error — 'Thought Signature' Solution

Haram

@haram

Recently, many users have been encountering unexpected 400 Bad Request errors while performing multi-turn tool calling after transitioning from Gemini 2.5 to the Gemini 3.0 or 3.5 model series. If you check the error message, you will likely see the phrase missing a thought_signature. Starting with Gemini 3.x, a strict rule is enforced where the 'Thought Signature'—an encrypted representation of the model's reasoning process—must be passed back in the next turn's request. If the developer doesn't manage this state directly, the API server will throw an error immediately.

The easiest way to solve this is by using Google's officially released 'Interactions API.' Unlike the traditional Chat API or standard text completion API, the Interactions API automatically preserves multi-turn history and state on the server side. Because it handles the Thought Signature processing internally based on the previous_interaction_id, developers don't have to deal with the headache. Haha. If you absolutely must manually manage history using the old method, you have to extract this signature value from the previous response object and include it in the request array for the next turn.

One more thing to be careful about is that if you keep the thinking_budget option used in Gemini 2.5 while also using the new thinking_level in your 3.5 configuration, you will get another 400 error due to setting conflicts. From version 3.x, you should remove the old option and use only thinking_level. There have also been reports of minor SDK bugs where Gemini 3.5 Flash sometimes returns empty responses when reasoning features are enabled; as a temporary workaround, you can clear the signature in the history array to resolve it. Definitely keep this in mind during development!