Skip to content

chore(go/samples): use gemini-flash-latest as the model#5329

Open
apascal07 wants to merge 1 commit into
mainfrom
ap/go-samples-flash-latest
Open

chore(go/samples): use gemini-flash-latest as the model#5329
apascal07 wants to merge 1 commit into
mainfrom
ap/go-samples-flash-latest

Conversation

@apascal07
Copy link
Copy Markdown
Collaborator

No description provided.

Updates Go samples to use gemini-flash-latest. Specialized models are kept
where the sample demonstrates them on purpose: image generation
(gemini-2.5-flash-image, gemini-3.1-flash-image-preview), TTS
(gemini-2.5-flash-preview-tts), Fallback middleware demos
(gemini-3.1-flash-preview, gemini-3.1-pro-preview), the gemini-3.1 preview
flows in imagen-gemini, and the SimplePrompt "Override the default model"
demo in samples/prompts/main.go.
@apascal07 apascal07 requested a review from huangjeff5 May 14, 2026 19:39
@apascal07 apascal07 enabled auto-merge (squash) May 14, 2026 19:39
@apascal07 apascal07 requested a review from a team May 14, 2026 19:41
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 updates model references across numerous Go samples to use gemini-flash-latest. Review feedback highlights that this alias is not currently supported by the googlegenai plugin, which will cause runtime failures. Additionally, the alias is inappropriate for Vertex AI samples, where gemini-1.5-flash should be used instead. Finally, one instance requires the addition of the googleai/ provider prefix for consistency.

// Define a flow to demonstrate code execution
genkit.DefineFlow(g, "codeExecutionFlow", func(ctx context.Context, _ any) (string, error) {
m := googlegenai.GoogleAIModel(g, "gemini-2.5-flash")
m := googlegenai.GoogleAIModel(g, "gemini-flash-latest")
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.

high

The model gemini-flash-latest is not currently registered in the googlegenai plugin's supported models list (see go/plugins/googlegenai/models.go). As a result, googlegenai.GoogleAIModel will return nil, causing the flow to fail at the check on line 39. Please ensure the model name is correct (e.g., gemini-1.5-flash-latest) or update the plugin to support this alias. Additionally, ensure that any error returned from this check is wrapped with contextual information (like the model name) to improve diagnosability.

References
  1. Wrap generic errors with contextual information (such as resource names or IDs) when the underlying function's error message lacks specific context, particularly when multiple instances of the same operation are performed in a single scope.

Comment thread go/samples/menu/main.go
g := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.VertexAI{}))

model := googlegenai.VertexAIModel(g, "gemini-2.5-flash")
model := googlegenai.VertexAIModel(g, "gemini-flash-latest")
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.

high

Vertex AI does not support the gemini-flash-latest alias; this naming convention is specific to the Google AI (AI Studio) API. For Vertex AI, you should use gemini-1.5-flash or a specific versioned model like gemini-1.5-flash-002.

Suggested change
model := googlegenai.VertexAIModel(g, "gemini-flash-latest")
model := googlegenai.VertexAIModel(g, "gemini-1.5-flash")

Comment on lines 84 to +87
Location: vectorsearchPlugin.Location,
}, vectorsearchPlugin))

model := googlegenai.VertexAIModel(g, "gemini-2.5-flash")
model := googlegenai.VertexAIModel(g, "gemini-flash-latest")
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.

high

Vertex AI does not support the gemini-flash-latest alias. Please use a valid Vertex AI model name such as gemini-1.5-flash.

Suggested change
Location: vectorsearchPlugin.Location,
}, vectorsearchPlugin))
model := googlegenai.VertexAIModel(g, "gemini-2.5-flash")
model := googlegenai.VertexAIModel(g, "gemini-flash-latest")
Location: vectorsearchPlugin.Location,
}, vectorsearchPlugin))
model := googlegenai.VertexAIModel(g, "gemini-1.5-flash")

Comment on lines 84 to +87
Location: vectorsearchPlugin.Location,
}, vectorsearchPlugin))

model := googlegenai.VertexAIModel(g, "gemini-2.5-flash")
model := googlegenai.VertexAIModel(g, "gemini-flash-latest")
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.

high

Vertex AI does not support the gemini-flash-latest alias. Please use a valid Vertex AI model name such as gemini-1.5-flash.

Suggested change
Location: vectorsearchPlugin.Location,
}, vectorsearchPlugin))
model := googlegenai.VertexAIModel(g, "gemini-2.5-flash")
model := googlegenai.VertexAIModel(g, "gemini-flash-latest")
Location: vectorsearchPlugin.Location,
}, vectorsearchPlugin))
model := googlegenai.VertexAIModel(g, "gemini-1.5-flash")


return genkit.GenerateText(ctx, g,
ai.WithModel(googlegenai.ModelRef("gemini-2.5-flash", &genai.GenerateContentConfig{
ai.WithModel(googlegenai.ModelRef("gemini-flash-latest", &genai.GenerateContentConfig{
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

The model reference is missing the googleai/ provider prefix. For consistency with other samples in this pull request and to ensure the model is correctly resolved by Genkit, it should be googleai/gemini-flash-latest.

Suggested change
ai.WithModel(googlegenai.ModelRef("gemini-flash-latest", &genai.GenerateContentConfig{
ai.WithModel(googlegenai.ModelRef("googleai/gemini-flash-latest", &genai.GenerateContentConfig{

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants