Skip to content

fix(genkit): use gemini-3.8-flash in the init sample - #11638

Open
pcbeingused33 wants to merge 1 commit into
firebase:mainfrom
pcbeingused33:fix/genkit-init-gemini-model
Open

pcbeingused33 wants to merge 1 commit into
firebase:mainfrom
pcbeingused33:fix/genkit-init-gemini-model

Conversation

@pcbeingused33

Copy link
Copy Markdown

Description

firebase init genkit generates src/genkit-sample.ts with vertexAI.model("gemini-2.5-flash") or googleAI.model("gemini-2.5-flash"), depending on the provider picked. gemini-2.5-flash was 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-genai with Vertex/Google AI, and the legacy @genkit-ai/vertexai / @genkit-ai/googleai) to gemini-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, which gemini-3.8-flash accepts, and no repo code depends on the model's pricing or context limits. A CHANGELOG entry is included.

Scenarios Tested

  • New parameterized test in src/init/features/genkit/index.spec.ts: runs doSetup for 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 no gemini-2.5 model. All 4 cases fail on main and pass with this change.
  • npx mocha src/init/features/genkit/index.spec.ts: 10 passing.
  • eslint and prettier --check on 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.

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.

@gemini-code-assist gemini-code-assist Bot 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.

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")',

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 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
  1. 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")');

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

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

This branch has not been deployed

No deployments
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.

1 participant