Skip to content

Thinking level support for Gemini 3 Pro#1444

Merged
VisargD merged 5 commits into
Portkey-AI:mainfrom
maciej-nexos:maciekskin/fix/add_thinking_level
Dec 8, 2025
Merged

Thinking level support for Gemini 3 Pro#1444
VisargD merged 5 commits into
Portkey-AI:mainfrom
maciej-nexos:maciekskin/fix/add_thinking_level

Conversation

@maciej-nexos

Copy link
Copy Markdown
Contributor

Description: (required)
Gemini 3 Pro model supports thinking_level parameter.
This new parameter is mutually exclusive with existing thinking_budget parameter for Gemini 2.5 series models.

Tests Run/Test cases added: (required)

  • n/a

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

@maciej-nexos maciej-nexos force-pushed the maciekskin/fix/add_thinking_level branch from c7d01d3 to 70af8b9 Compare November 21, 2025 07:16
@roh26it

roh26it commented Nov 21, 2025

Copy link
Copy Markdown
Collaborator

Thanks for this, @maciej-nexos

Will review this quickly and merge

@roh26it roh26it requested a review from Copilot November 21, 2025 07:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the thinking_level parameter in Gemini 3 Pro model, which is mutually exclusive with the existing thinking_budget parameter used by Gemini 2.5 series models.

  • Added thinking_level field to the Params interface
  • Updated Google and Google Vertex AI providers to handle thinking_level with mutual exclusivity logic
  • Modified include_thoughts condition to accept either budget_tokens or thinking_level

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/types/requestBody.ts Added optional thinking_level field to the thinking configuration type
src/providers/google/chatComplete.ts Updated transformation logic to prioritize thinking_level over budget_tokens when present
src/providers/google-vertex-ai/transformGenerationConfig.ts Applied same mutual exclusivity logic for Vertex AI provider

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/providers/google/chatComplete.ts Outdated
Comment on lines +87 to +88
thinkingConfig['thinking_budget'] = budget_tokens;
}

Copilot AI Nov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When thinking_level is not provided but budget_tokens is undefined or 0, this will set thinking_budget to a falsy value. This could cause issues if the API expects either a valid budget or no field at all. Consider only setting thinking_budget when budget_tokens has a meaningful value.

Suggested change
thinkingConfig['thinking_budget'] = budget_tokens;
}
if (budget_tokens != null && budget_tokens !== 0) {
thinkingConfig['thinking_budget'] = budget_tokens;
}

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +64
thinkingConfig['thinking_budget'] = budget_tokens;
}

Copilot AI Nov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When thinking_level is not provided but budget_tokens is undefined or 0, this will set thinking_budget to a falsy value. This could cause issues if the API expects either a valid budget or no field at all. Consider only setting thinking_budget when budget_tokens has a meaningful value.

Suggested change
thinkingConfig['thinking_budget'] = budget_tokens;
}
if (budget_tokens != null && budget_tokens !== 0) {
thinkingConfig['thinking_budget'] = budget_tokens;
}

Copilot uses AI. Check for mistakes.
@maciej-nexos maciej-nexos force-pushed the maciekskin/fix/add_thinking_level branch from 70af8b9 to 601838b Compare November 21, 2025 15:38
@narengogi

Copy link
Copy Markdown
Member

I think it would be best to map reasoning_effort to thinking_level

@narengogi narengogi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR to map reasoning_effort to thinkingLevel

@b4s36t4 for review

@narengogi narengogi requested a review from b4s36t4 November 25, 2025 08:58
@davidwhite-spec

Copy link
Copy Markdown

We would really love to see this feature added as users of Portkey.

@maciej-nexos

Copy link
Copy Markdown
Contributor Author

anything blocking this from being merged in?

@narengogi

Copy link
Copy Markdown
Member

merging this @davidwhite-spec and @maciej-nexos

@VisargD VisargD merged commit 1389220 into Portkey-AI:main Dec 8, 2025
1 check passed
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.

7 participants