Skip to content

fix: support gemini-3.1-flash-image-preview image generation in chat#13335

Open
cherry-ai-bot[bot] wants to merge 4 commits intomainfrom
fix/gemini-3-1-flash-image-preview-13332
Open

fix: support gemini-3.1-flash-image-preview image generation in chat#13335
cherry-ai-bot[bot] wants to merge 4 commits intomainfrom
fix/gemini-3-1-flash-image-preview-13332

Conversation

@cherry-ai-bot
Copy link

@cherry-ai-bot cherry-ai-bot bot commented Mar 9, 2026

Summary

  • add Gemini 3.x flash-image pattern support in vision capability detection
  • support OpenRouter google/gemini-3.1-flash-image-preview in image generation model check
  • add default model entries for Gemini and OpenRouter
  • add/update unit tests for vision/image model detection paths

Related

Copy link
Author

@cherry-ai-bot cherry-ai-bot bot left a comment

Choose a reason for hiding this comment

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

Thanks for the update — overall this PR is on the right track and addresses #13332 with clear tests.

I left a few non-blocking suggestions:

  1. clarify or narrow broad gemini-3.x flash-image regex matching scope,
  2. ensure model list/capability metadata remains fully aligned,
  3. consider removing OpenRouter-specific image-model gating and reusing unified capability detection to avoid duplicated logic.

No blocking issues from my side.

'kandinsky(?:-[\\w-]+)?'
]

const GEMINI_FLASH_IMAGE_MODELS = ['gemini-2.5-flash-image(?:-[\\w-]+)?', 'gemini-3(?:\\.\\d+)?-flash-image(?:-[\\w-]+)?']
Copy link
Author

Choose a reason for hiding this comment

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

Suggestion: The new matcher is intentionally broad. If product scope is strictly for now, consider tightening to explicit known IDs (or adding a comment explaining why broad matching is desired) to avoid accidental enablement for future unknown model variants.

@@ -9,7 +11,7 @@ export function buildGeminiGenerateImageParams(): Record<string, any> {

Copy link
Author

Choose a reason for hiding this comment

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

Suggestion: Agree with reviewer concern that OpenRouter-specific model gating may be unnecessary here. If image-generation capability is already determined upstream by unified model capability detection, consider removing this provider-specific matcher and reusing that capability signal to avoid duplicated source-of-truth.

@DeJeune DeJeune requested a review from EurFelux March 10, 2026 10:28
Copy link
Collaborator

@EurFelux EurFelux left a comment

Choose a reason for hiding this comment

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

Overall the PR looks good — clean refactoring with solid test coverage.

One minor suggestion: replace the .slice(1) with a named constant for better maintainability.

const OPENAI_IMAGE_GENERATION_MODELS = [...OPENAI_TOOL_USE_IMAGE_GENERATION_MODELS, 'gpt-image-1']

const MODERN_IMAGE_MODELS = ['gemini-3(?:\\.\\d+)?-pro-image(?:-[\\w-]+)?']
const MODERN_IMAGE_MODELS = [...GEMINI_FLASH_IMAGE_MODELS.slice(1), ...GEMINI_PRO_IMAGE_MODELS]
Copy link
Collaborator

Choose a reason for hiding this comment

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

GEMINI_FLASH_IMAGE_MODELS.slice(1) relies on array index position to exclude gemini-2.5-flash-image — this is fragile and hard to read. If someone later inserts a new entry at the beginning of the array, the semantics silently change.

Suggest extracting a named constant to make the intent explicit:

const GEMINI_3X_FLASH_IMAGE_MODELS = ['gemini-3(?:\\.\\d+)?-flash-image(?:-[\\w-]+)?']

const GEMINI_FLASH_IMAGE_MODELS = [
  'gemini-2.5-flash-image(?:-[\\w-]+)?',
  ...GEMINI_3X_FLASH_IMAGE_MODELS
]

Then use GEMINI_3X_FLASH_IMAGE_MODELS here directly instead of .slice(1).

@EurFelux
Copy link
Collaborator

Manual test 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.

[Feature] 在 Cherry Studio Chat 中适配 gemini-3.1-flash-image-preview 的画图能力

1 participant