Skip to content

feat(py): add Gemini 3.1 preview support to python #5032

Draft
cabljac wants to merge 2 commits intogenkit-ai:mainfrom
invertase:feat/py-gemini-3-1-preview-support
Draft

feat(py): add Gemini 3.1 preview support to python #5032
cabljac wants to merge 2 commits intogenkit-ai:mainfrom
invertase:feat/py-gemini-3-1-preview-support

Conversation

@cabljac
Copy link
Copy Markdown
Contributor

@cabljac cabljac commented Mar 31, 2026

Summary

  • Adds Python support for new Gemini 3.1 preview models:

    • googleai/gemini-3.1-flash-lite-preview
image
  • googleai/gemini-3.1-pro-preview-customtools
image
  • googleai/gemini-3.1-pro-preview
image
  • vertexai/gemini-3.1-flash-lite-preview
image
  • vertexai/gemini-3.1-pro-preview
image
  • Updates Vertex plugin routing so Gemini 3.1 preview models default to global location (while non-3.1-preview models keep configured region).

  • Updates samples/Dev UI flows so all 5 models can be exercised directly:

    • prompts sample now includes explicit GoogleAI Pro preview flows.
    • vertexai-imagen sample includes explicit Vertex Gemini 3.1 preview flows.
  • Adds/updates tests for enum support and Vertex global-routing behavior.

Issue

Checklist:

Construct Google GenAI clients with explicit typed keyword arguments instead of unpacked kwargs maps, and apply Ruff formatting to plugin tests.

Made-with: Cursor
@github-actions github-actions bot added docs Improvements or additions to documentation python Python labels Mar 31, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Gemini 3.1 preview models (Flash Lite, Pro, and Pro with Custom Tools) across the Google AI and Vertex AI plugins. A key architectural change includes a routing mechanism in the Vertex AI plugin to ensure Gemini 3.1 preview models use the 'global' location, while maintaining configured locations for other models. The PR also updates documentation, enums, and samples to reflect these additions. Feedback was provided regarding the newly defined ModelInfo constants, which are currently not registered in the SUPPORTED_MODELS dictionary, potentially causing them to fall back to generic metadata in the UI.

Comment on lines +725 to +762
GEMINI_3_1_FLASH_LITE_PREVIEW = ModelInfo(
label='Google AI - Gemini 3.1 Flash Lite Preview',
supports=Supports(
multiturn=True,
media=True,
tools=True,
tool_choice=True,
system_role=True,
constrained=Constrained.NO_TOOLS,
output=['text', 'json'],
),
)

GEMINI_3_1_PRO_PREVIEW_CUSTOMTOOLS = ModelInfo(
label='Google AI - Gemini 3.1 Pro Preview Custom Tools',
supports=Supports(
multiturn=True,
media=True,
tools=True,
tool_choice=True,
system_role=True,
constrained=Constrained.NO_TOOLS,
output=['text', 'json'],
),
)

GEMINI_3_1_PRO_PREVIEW = ModelInfo(
label='Google AI - Gemini 3.1 Pro Preview',
supports=Supports(
multiturn=True,
media=True,
tools=True,
tool_choice=True,
system_role=True,
constrained=Constrained.NO_TOOLS,
output=['text', 'json'],
),
)
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.

medium

While these ModelInfo constants are correctly defined, they are currently not being used for model lookup because they aren't added to the SUPPORTED_MODELS dictionary. This means that when these models are resolved, they will fall back to a generic ModelInfo with a default label and support flags, rather than using the specific metadata defined here.

Consider populating the SUPPORTED_MODELS dictionary with these constants (and existing ones) to ensure the correct metadata is surfaced in the Genkit UI and used during execution.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@andyma-star can we address this?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We can.

@cabljac cabljac changed the title Feat/py gemini 3 1 preview support feat: python gemini 3.1 preview support Mar 31, 2026
@cabljac cabljac changed the title feat: python gemini 3.1 preview support feat(python): python gemini 3.1 preview support Mar 31, 2026
@cabljac cabljac changed the title feat(python): python gemini 3.1 preview support feat(python): add Gemini 3.1 preview support to python Mar 31, 2026
@huangjeff5 huangjeff5 changed the title feat(python): add Gemini 3.1 preview support to python feat(py): add Gemini 3.1 preview support to python Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants