Skip to content

fix(gemini): skip thinking config for image models - #17027

Merged
3 commits merged into
BerriAI:mainfrom
Chesars:fix/gemini-3-image-thinking-level-issue-17013
Nov 25, 2025
Merged

fix(gemini): skip thinking config for image models#17027
3 commits merged into
BerriAI:mainfrom
Chesars:fix/gemini-3-image-thinking-level-issue-17013

Conversation

@Chesars

@Chesars Chesars commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

Title

Fix: Exclude Gemini 3 image models from automatic thinking_level parameter

Relevant issues

Fixes #17013

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard
    requirement
    - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

Summary

LiteLLM automatically adds thinkingConfig: {thinkingLevel: "low"} to ALL Gemini 3+ models by default. However, Gemini 3 image models (e.g., gemini-3-pro-image-preview) do not support the thinking_level parameter, causing API requests to fail with: BadRequestError: "Thinking level is not supported for this model

Solution

Added check to exclude models containing "image" from automatic thinkingConfig injection (line 911 in vertex_and_google_ai_studio_gemini.py).

Code Changes

  • File: litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py
    • Added if "image" not in model.lower() check before adding automatic thinking config
  • Tests: tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py - Added 3 unit tests (all passing ✅)
  • Docs: docs/my-website/docs/providers/gemini.md - Added warning about image models not supporting thinking_level

Docs

According to https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/3-pro-image, gemini-3-pro-image-preview only supports: temperature, topP, topK, candidateCount - NOT thinking_level.

…eter (BerriAI#17013)

- gemini-3-pro-image-preview does not support thinking_level parameter
- Added check to skip adding thinkingConfig for models containing "image"
- Fixes BadRequestError: "Thinking level is not supported for this model"
- Only affects automatic default behavior, user can still pass reasoning_effort explicitly

Fixes BerriAI#17013
@vercel

vercel Bot commented Nov 24, 2025

Copy link
Copy Markdown

@Chesars is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@marty-sullivan

Copy link
Copy Markdown
Contributor

+1 also seeing this bug

@ghost
ghost merged commit 650b189 into BerriAI:main Nov 25, 2025
2 of 6 checks passed
@Chesars
Chesars deleted the fix/gemini-3-image-thinking-level-issue-17013 branch November 25, 2025 11:45
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
* fix(gemini): exclude image models from automatic thinking_level parameter (BerriAI#17013)

- gemini-3-pro-image-preview does not support thinking_level parameter
- Added check to skip adding thinkingConfig for models containing "image"
- Fixes BadRequestError: "Thinking level is not supported for this model"
- Only affects automatic default behavior, user can still pass reasoning_effort explicitly

Fixes BerriAI#17013

* test: add tests for gemini-3 image models thinking_level exclusion

* update docs
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Thinking level error in litellm proxy + gemini 3 pro image

2 participants