Skip to content

Gemini image model does not accept history with tool calls or thinking #3149

@DouweM

Description

@DouweM

Initial Checks

Description

When gemini-2.5-flash-image-preview with https://ai.pydantic.dev/builtin-tools/#image-generation-tool (see example code there) is passed message history from another model with tool calls or thinking, the API returns an error:

Tool calls:

Function calling is not enabled for models/gemini-2.5-flash-image-preview

Thinking signatures:

Request contains an invalid argument.

Thinking signatures we can simply omit (while leaving the thinking summaries in), but tool calls are a bit more tricky, as the tool call results may be relevant to image generation, and may not be repeated in text messages.

Example Code

Python, Pydantic AI & LLM client version

Latest

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions