Repository navigation
fix(genkit): use gemini-3.8-flash in the init sample - #11638
pcbeingused33 wants to merge 1 commit into
Conversation
gemini-2.5-flash was retired on Vertex AI on 2026-10-20 and is no longer offered to new Gemini API keys, so the sample flow generated by `firebase init genkit` failed on its first request.
There was a problem hiding this comment.
Code Review
This pull request updates the Genkit initialization templates to use gemini-3.8-flash instead of the retired gemini-2.5-flash model for both Vertex AI and Google AI providers, and adds corresponding unit tests. The review feedback recommends extracting the repeated model name string into a top-level constant to align with the repository style guide, and referencing this constant in the tests to prevent hardcoding.
| // If you want to use Vertex Express Mode, you can specify apiKey instead. | ||
| vertexAI({location: "global"})`, | ||
| model: 'vertexAI.model("gemini-2.5-flash")', | ||
| model: 'vertexAI.model("gemini-3.8-flash")', |
There was a problem hiding this comment.
The model name "gemini-3.8-flash" is repeated multiple times across the pluginToInfo configuration. According to the repository style guide (under Code Quality & Utilities), repeated strings and static IDs should be extracted as top-level constants (UPPER_SNAKE_CASE) instead of being inlined.\n\nConsider defining a top-level constant at the top of the file:\ntypescript\nexport const DEFAULT_GEMINI_MODEL = "gemini-3.8-flash";\n\nAnd then referencing it in the configuration using template literals:\ntypescript\nmodel: `vertexAI.model("${DEFAULT_GEMINI_MODEL}")`\n
References
- Define static IDs, default timeouts, millisecond offsets, and repeated strings as top-level constants (UPPER_SNAKE_CASE) instead of inlining magic values inside functions. (link)
| .find((call) => String(call.args[0]).endsWith("genkit-sample.ts")); | ||
| expect(sampleWrite).to.not.be.undefined; | ||
| const sample = String(sampleWrite?.args[1]); | ||
| expect(sample).to.include('.model("gemini-3.8-flash")'); |
There was a problem hiding this comment.
If DEFAULT_GEMINI_MODEL is extracted as a top-level constant in src/init/features/genkit/index.ts and exported, we should reference it here in the test to avoid hardcoding the model name again. This ensures that if the default model is updated in the future, the tests will automatically stay in sync and won't require manual updates.\n\nExample:\ntypescript\nexpect(sample).to.include(`.model("${genkit.DEFAULT_GEMINI_MODEL}")`);\n
Description
firebase init genkitgeneratessrc/genkit-sample.tswithvertexAI.model("gemini-2.5-flash")orgoogleAI.model("gemini-2.5-flash"), depending on the provider picked.gemini-2.5-flashwas retired on Vertex AI on 2026-10-20 (Vertex AI model versions), and on the Gemini API it is no longer available to new API keys and is listed on the deprecations page with a 2026-12-01 date. So a freshly scaffolded project's sample flow fails (Vertex) or gets silently rerouted (Gemini API) on its first request.This changes the default model for all four plugin variants (unified
@genkit-ai/google-genaiwith Vertex/Google AI, and the legacy@genkit-ai/vertexai/@genkit-ai/googleai) togemini-3.8-flash, which is Vertex AI's listed replacement and the current stable Flash model on the Gemini API. The two stale "Here, we import Gemini 2.0 Flash" comments are updated to match.No other parameters needed changing: the templates only pass
temperature: 1, whichgemini-3.8-flashaccepts, and no repo code depends on the model's pricing or context limits. A CHANGELOG entry is included.Scenarios Tested
src/init/features/genkit/index.spec.ts: runsdoSetupfor both providers on both template versions (1.0.0 and 1.18.0) and checks that the generated sample uses.model("gemini-3.8-flash")and nogemini-2.5model. All 4 cases fail onmainand pass with this change.npx mocha src/init/features/genkit/index.spec.ts: 10 passing.eslintandprettier --checkon the touched files: clean (only 2 existing warnings in untouched lines).Sample Commands
firebase init genkit(no change to commands or flags).This PR was prepared with the help of an AI coding assistant.