Skip to main content

Short Answer

When Gemini 3 and later models (gemini-4-argon, gemini-3.8-flash, gemini-3.1-pro-preview, and so on) run multi-turn function calling, there are two kinds of 400 errors related to the thought signature (thoughtSignature), and they need different fixes: If you call through the OpenAI-compatible /v1/chat/completions endpoint, none of this applies to you: the gateway manages signatures, and standard tool_calls / tool messages are all you need.

Telling the Two Errors Apart

Missing signature

The message names the function and its index in the parts array. This is a hard rule enforced by the model provider for the Gemini 3 family: every functionCall part in the current turn must carry its signature. A missing one fails with 400 on every route, and retrying does not help.

Invalid or corrupted signature

The field is present but fails validation. The signature is an encrypted blob that only the route that generated it can verify. If the conversation switches route, model, key, or group midway, earlier signatures may no longer be accepted.

Why This Happens

When tools are enabled, Gemini 3 models attach an encrypted thoughtSignature to the same part as each functionCall, recording the reasoning state at that step. On the next request the model needs it to continue the reasoning chain, so the provider requires it to be sent back unchanged.

Missing: the client rebuilt the part

The most common cause. A custom framework or middleware keeps only the name and args of the functionCall when assembling history and drops the sibling thoughtSignature; or streaming chunks are reassembled without merging the signature in.

Missing: history was compressed or rewritten

The client trimmed or summarized the context, or merged several parts into one, and the signature went with it.

Invalid: route changed mid-conversation

The first turns were served by route A and later turns landed on route B, which does not recognize A’s signatures. The switch can come from you changing group or key, or from automatic failover.

Invalid: model changed mid-conversation

Starting on gemini-3.8-flash and switching to gemini-4-argon within the same conversation. Signatures are not portable across models.
For parallel function calls the model attaches a signature only to the first functionCall part; the others legitimately have none, so do not fabricate one. For sequential calls (several steps within one turn) every step carries a signature and every one must be returned.

Fix 1: Missing Signature, Change How the Client Replays History

1

Put the whole model reply back verbatim

With the official google-genai SDK, simply contents.append(response.candidates[0].content); do not extract only the function_call field. In hand-written REST, the model turn in the second request’s contents must look like this:
thoughtSignature and functionCall are two fields of the same part, not two parts.
2

Check whether a framework or middleware strips the field

With LangChain, a custom agent framework, or an OpenAI-to-Gemini translation layer, print the actual request body of the second turn and confirm thoughtSignature is still there. The position N in the error is parts[N]; look there directly.
3

Do not rely on some models letting it through

Models and routes differ in how strictly they enforce missing signatures: some let it pass, others return 400. If the same code has always worked on gemini-3.8-flash and breaks on gemini-4-argon, the signature was most likely never sent and was merely tolerated before. Returning signatures as the provider requires is stable on every model.

Fix 2: Invalid Signature, Resend or Start Over

1

Resend once as is

When the APIYI gateway receives a signature 400 it automatically retries on another route, so a plain resend often succeeds. No changes needed.
2

Still 400: strip signatures from history turns and resend

Remove the thoughtSignature field from the parts of every role: "model" turn in the history, then resend. You lose the reasoning context of those turns and answer quality may dip slightly, but the conversation can continue. Only strip history turns, never the current one.
3

Or start a new conversation

The simplest and most reliable option. In a new conversation every signature comes from the same route from the first turn on.
4

One model, one key per conversation

When you need to switch model, key, or group, start a new conversation first. Do not switch inside a conversation that already has tool-call history.

No Signature Handling on the OpenAI-Compatible Endpoint

When you call Gemini through /v1/chat/completions, tool_calls messages have no signature field; the gateway saves and restores it during translation. In our tests on gemini-4-argon, two-turn conversations passed for all three shapes: a single call, two parallel calls, and text plus a call. Just return tool_calls and tool messages the standard OpenAI way.
Clients such as Codex that default to /v1/responses need to switch to the chat protocol, since Gemini models do not support that endpoint yet. See Gemini 4 Argon Text Generation.

FAQ

No. Returning signatures is the provider’s requirement for the whole Gemini 3 family; some models’ routes are simply lenient about missing ones. Moving to a strictly validating model exposes the problem, but the root cause is still a client that never sent the signature.
No. A signature is valid only on the route and within the conversation context that produced it. Copying it into another conversation yields Invalid.
In the same part as the functionCall, inside the chunk that carries it. When reassembling the stream, merge this field together with functionCall into the final model reply before putting it back into history.
Not strictly. The provider hard-validates signatures only on functionCall parts; a missing signature on a text turn does not 400, but keeping it helps reasoning continuity, so return the whole reply verbatim anyway.

Gemini Function Calling Guide

Full two-turn example, including how to return signatures

Gemini 4 Argon Text Generation

Multi-turn tool-call notes and client setup

How Do I Fix Claude's Invalid Thinking Signature Error?

The same class of problem on the Claude side

Multi-Turn Conversation Guide

How each provider expects history to be returned