Migrate off deprecated gemini-2.5-flash and recalibrate AI pricing#90
Merged
Conversation
Google stopped serving gemini-2.5-flash to new API keys/projects starting July 9 2026 ahead of its official Oct 16 2026 shutdown date — confirmed by the exact 404 this app hit on POST /api/agents/:id/chat. The same hardcoded model string was also used by the CCTP "suggest articles" endpoint (server.ts), sharing the same GEMINI_API_KEY and billing pipeline — almost certainly broken too, just not yet reported. Both switched to gemini-3-flash-preview, Google's recommended near-term migration target and the newest model the installed @google/genai SDK version's own types already list. Note: gemini-3-flash-preview costs more than the old 2.5-flash ($0.50/$3.00 per M input/output tokens vs ~$0.30/$2.50) — the app's AI-credit pricing (AI_PRICE_INPUT_PER_M / AI_PRICE_OUTPUT_PER_M env vars, currently €0.40/€1.65 per M, calibrated to the old model) was deliberately left untouched since that's a pricing decision, not a bug fix — worth revisiting to stay profitable at the new cost.
Preserves the existing markup rather than letting it silently drift after the gemini-2.5-flash -> gemini-3-flash-preview migration: - input: €0.40 (was ~1.333x Google's $0.30) -> €0.67 (~1.333x of $0.50) - output: €1.65 (was ~0.66x Google's $2.50) -> €1.98 (~0.66x of $3.00) Only changes the process.env fallback defaults — if AI_PRICE_INPUT_PER_M / AI_PRICE_OUTPUT_PER_M are set explicitly in the actual deployment environment, those still take precedence and need updating there too.
Output was priced at a ~0.66x markup on Google's cost (i.e. below cost, subsidized by the input side's ~1.333x markup) — both now use the same ~1.333x factor: €4.00/M output (was €1.98), applied to gemini-3-flash-preview's $3.00/M Google cost. Input unchanged (€0.67).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gemini-2.5-flashto new API keys/projects starting July 9 2026 (ahead of its official Oct 16 2026 shutdown) — confirmed by the exact 404 this app hit onPOST /api/agents/:id/chat. Migrated both call sites (agent chat, and the CCTP "suggest articles" endpoint, which shares the same API key/billing pipeline and was almost certainly broken too) togemini-3-flash-preview.AI_PRICE_INPUT_PER_M/AI_PRICE_OUTPUT_PER_M) for the new model's actual Google cost ($0.50/$3.00 per M tokens vs the old $0.30/$2.50), preserving the input-side markup (~1.333x) on both input and output — output was previously priced below cost (~0.66x markup, subsidized by input), now unsubsidized at the same ~1.333x factor: €0.67/M input, €4.00/M output (was €0.40/€1.65).Test plan
npm run lint(tsc --noEmit) passesAI_PRICE_INPUT_PER_M/AI_PRICE_OUTPUT_PER_Menv vars (if set explicitly, overriding these code defaults) are updated to matchGenerated by Claude Code