Skip to content

fix(gemini): repoint providers off models retired for new API keys#3283

Open
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/fix-gemini-retired-models
Open

fix(gemini): repoint providers off models retired for new API keys#3283
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/fix-gemini-retired-models

Conversation

@posthog

@posthog posthog Bot commented Jul 16, 2026

Copy link
Copy Markdown

Fixes the Gemini provider being completely broken for users with freshly created Google API keys.

Why

New keys default to gemini-2.5-flash-lite, which Google now 404s with NOT_FOUND ("no longer available to new users"), so memory generation silently fails for the affected cohort. The providers also hard-coded several other retired IDs (gemini-2.5-flash, gemini-2.5-pro, gemini-2.0-flash, gemini-2.0-flash-lite) and called them against the non-beta v1 endpoint.

What changed

  • Endpoint v1v1beta in both GeminiProvider.ts and GeminiObservationProvider.ts — the current 3.x models and the -latest aliases are only served under v1beta.
  • Model list repointed to currently-available IDs: gemini-flash-latest, gemini-flash-lite-latest, gemini-3.5-flash, gemini-3.1-flash-lite, gemini-3-flash-preview. Default is now gemini-flash-latest, a Google-maintained alias that tracks the current GA Flash model, so it won't go stale on new keys the next time Google rotates models.
  • Dropped the bogus gemini-3-flash ID (only gemini-3-flash-preview exists) that the earlier code carried.
  • Updated all four sync points that track the model list independently (worker provider type/allow-list, SettingsDefaultsManager + ui/viewer/constants/settings.ts, SettingsRoutes validator, ContextSettingsModal dropdown), plus tests, docs, and the built plugin/ bundles.

A retired model already saved in settings.json now falls back to the working default with a warning, auto-healing users stuck on the old broken default.

Note vs. the issue's suggestion: gemini-3.5-flash / gemini-3.1-flash-lite are real, GA model IDs (verified against Google's model docs), so they're included; gemini-3-flash (no -preview) is not a real ID and was removed.

Closes #3278


Created with PostHog Code from an inbox report.

New Gemini API keys can't use claude-mem: the providers pinned model IDs Google
no longer serves to newly created keys (gemini-2.5-flash-lite default, plus
gemini-2.5-flash / 2.5-pro / 2.0-flash / 2.0-flash-lite) and called them against
the non-beta v1 endpoint, so every generation 404s with NOT_FOUND
("no longer available to new users").

- Switch both Gemini paths from the v1 to the v1beta generateContent endpoint;
  current 3.x models and the -latest aliases are only served under v1beta.
- Replace the retired model list with currently-available IDs
  (gemini-flash-latest, gemini-flash-lite-latest, gemini-3.5-flash,
  gemini-3.1-flash-lite, gemini-3-flash-preview) and default to
  gemini-flash-latest, a Google-maintained alias that tracks the current GA
  Flash model so it never goes stale on new keys.
- Drop the bogus gemini-3-flash ID (only gemini-3-flash-preview exists).
- Update all four sync points (worker provider type/allow-list, settings
  defaults, settings validator, UI dropdown) plus the server-side
  GeminiObservationProvider, tests, and docs. A retired configured model now
  falls back to the working default, auto-healing users stuck on the old
  default persisted in settings.json.

Generated-By: PostHog Code
Task-Id: 2abacff4-9901-4aa2-9f55-b9ec4375d9d8
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates Gemini support to use current model IDs and the beta API path. The main changes are:

  • Swaps Gemini API calls from v1 to v1beta.
  • Replaces retired Gemini model IDs with gemini-flash-latest, gemini-flash-lite-latest, gemini-3.5-flash, gemini-3.1-flash-lite, and gemini-3-flash-preview.
  • Changes Gemini defaults in worker settings, server generation, viewer constants, and built plugin bundles.
  • Updates settings validation and the model dropdown to match the new allow-list.
  • Refreshes Gemini docs and tests for the new endpoint and default model.

Confidence Score: 5/5

Safe to merge with minimal risk.

The changes are narrowly scoped to Gemini endpoint constants, model allow-lists, UI options, generated bundles, docs, and matching tests. No blocking correctness or security issues were found.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The targeted Gemini tests rerun completed with exit code 0, reporting 11 tests passed.
  • The Gemini v1beta harness ran and finished with exit code 0, printing the v1beta request URL and the retired-model fallback warning.
  • TypeScript checks completed successfully for both root and viewer analyses, each with exit code 0.
  • Noted the attempted capture of the targeted tests log and that Bun tests passed, but the shell wrapper exited with code 2 due to /bin/sh not supporting ${PIPESTATUS[0]}; the corrected rerun artifact is the authoritative proof.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/services/worker/GeminiProvider.ts Moves worker Gemini calls to v1beta, replaces retired model IDs, and falls back invalid saved models to the new default.
src/server/generation/providers/GeminiObservationProvider.ts Moves server-side Gemini generation to v1beta and defaults to gemini-flash-latest.
src/services/worker/http/routes/SettingsRoutes.ts Updates settings validation to accept only the refreshed Gemini model list.
src/ui/viewer/components/ContextSettingsModal.tsx Updates the Gemini model selector default and options.
src/shared/SettingsDefaultsManager.ts Updates persisted settings defaults to use gemini-flash-latest.
tests/gemini_provider.test.ts Updates Gemini provider tests for the new endpoint and model default.
plugin/scripts/worker-service.cjs Built worker bundle reflects the v1beta endpoint, new allowed model list, and fallback default.
docs/public/usage/gemini-provider.mdx Refreshes Gemini provider configuration docs, supported model table, and retirement note.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant SettingsUI as Settings UI / settings.json
participant Validator as SettingsRoutes validator
participant Worker as GeminiProvider
participant Gemini as Google Gemini v1beta

User->>SettingsUI: Select Gemini model or keep default
SettingsUI->>Validator: POST /api/settings with CLAUDE_MEM_GEMINI_MODEL
Validator-->>SettingsUI: Accept refreshed model allow-list
Worker->>SettingsUI: Load settings/defaults
alt Saved model is valid
    Worker->>Worker: Use configured model
else Saved retired/unknown model
    Worker->>Worker: Warn and fall back to gemini-flash-latest
end
Worker->>Gemini: "POST /v1beta/models/{model}:generateContent"
Gemini-->>Worker: Generated observations or provider error
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant SettingsUI as Settings UI / settings.json
participant Validator as SettingsRoutes validator
participant Worker as GeminiProvider
participant Gemini as Google Gemini v1beta

User->>SettingsUI: Select Gemini model or keep default
SettingsUI->>Validator: POST /api/settings with CLAUDE_MEM_GEMINI_MODEL
Validator-->>SettingsUI: Accept refreshed model allow-list
Worker->>SettingsUI: Load settings/defaults
alt Saved model is valid
    Worker->>Worker: Use configured model
else Saved retired/unknown model
    Worker->>Worker: Warn and fall back to gemini-flash-latest
end
Worker->>Gemini: "POST /v1beta/models/{model}:generateContent"
Gemini-->>Worker: Generated observations or provider error
Loading

Reviews (1): Last reviewed commit: "fix(gemini): repoint providers off model..." | Re-trigger Greptile

@thedotmack
thedotmack marked this pull request as ready for review July 20, 2026 06:11
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.

Gemini Providers are no longer valid for new users

2 participants