-
Notifications
You must be signed in to change notification settings - Fork 192
Description
What you're trying to do
I'm trying to use the gemini-3-pro-image-preview model but running into issues with a required thought_signature in text parts. My application routes between different AI model providers and standardizes on an internal message structure that gets mapped to a provider specific format before the API request is made.
After mapping to Gemini specific structure, previously the below worked when I manage the conversation history myself in a stateless way with gemini-2.5-flash-image-preview:
const resp = await this.client.models.generateContent({
model: modelToUse,
config: generationConfig,
contents: messages
});Value of generationConfig:
{
"systemInstruction": {
"parts": [
{
"text": "some system message..."
}
]
},
"responseModalities": [
"Text",
"Image"
]
}Value of messages:
[
{
"parts": [
{
"text": "some previous user message....",
},
],
"role": "user",
},
{
"parts": [
{
"text": "some previous model response....",
},
],
"role": "model",
},
{
"parts": [
{
"text": "generate an image of a cat",
},
],
"role": "user",
},
]But after trying to use the new model I run into the error mentioned below with requiring thought_signature in my text parts.
What code you've already tried
I've tried to set thoughtSignature to a random base64 string value to see if that can bypass it for the meantime, but received an invalid signature error as expected. Not too sure the best way to proceed in a stateless way if all future interactions with the new model requires a thought signature when trying to send old and new messages again, there's no provider specific information persisted in our internal message format.
Any error messages you're getting
Receiving the below error when generating content:
{
"error": {
"code": 400,
"message": "Text part is missing a thought_signature in content position 1, part position 1.",
"status": "INVALID_ARGUMENT"
}
}Questions
I've read through the documentation here but still wasn't too sure the best way to proceed with my use case. Currently this happens only for this model and not gemini-3-pro-preview when handling basic message history like this, though when adding function calling will most likely run into the issue discussed in forums here and need to add the thought signature too.
-
Is there a way to bypass the requirement for thought signature on text parts, or if unable to bypass requirement, is there a way to set it to a dummy value that doesn't affect model performance?
-
Any way to keep this stateless without needing to persist a thought signature in my internal system structure that will only be used by Gemini? Currently we map provider messages to an internal structure to be returned over REST since we route to multiple model providers, and has no fields pertaining to a specific provider (since all messages can be sent to any of the models)
Please let me know if I happen to be missing something on this, I will look into this further too and provide any updates in case I find a solution or more information