From c59fbd511e491a71294c3ce8e0ac46357bff7535 Mon Sep 17 00:00:00 2001 From: Kris Braun Date: Mon, 3 Aug 2026 12:33:02 -0400 Subject: [PATCH] Add current-generation Gemini models to AIModel and deprecate the 2.x members Google has withdrawn most of the Gemini 2.x generation. A `hint` naming one of those models made `ai.prompt()` fail outright, and the speed/cost tiers that resolve without a hint pointed at several of them too, so `{ speed: "capable", cost: "high" }` and neighbouring tiers stopped working. Adds `GEMINI_31_PRO`, `GEMINI_35_FLASH`, and `GEMINI_35_FLASH_LITE`, and marks the `GEMINI_25_*` and `GEMINI_20_*` members deprecated. The deprecated members are kept so twists built against an earlier SDK version still compile, and a hint naming a withdrawn model is now served by its current equivalent instead of erroring. `GEMINI_25_FLASH` is deprecated but not remapped: it still works, and silently substituting a model an author deliberately asked for would be worse than letting it run until it is actually withdrawn. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Y9GNwKEBkEAoLYzkTngfGk --- .changeset/gemini-3-model-refresh.md | 16 ++++++++++++++++ twister/src/tools/ai.ts | 21 ++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .changeset/gemini-3-model-refresh.md diff --git a/.changeset/gemini-3-model-refresh.md b/.changeset/gemini-3-model-refresh.md new file mode 100644 index 00000000..f3b2af7d --- /dev/null +++ b/.changeset/gemini-3-model-refresh.md @@ -0,0 +1,16 @@ +--- +"@plotday/twister": minor +--- + +Added: `AIModel.GEMINI_31_PRO`, `AIModel.GEMINI_35_FLASH`, and +`AIModel.GEMINI_35_FLASH_LITE` for the current generation of Gemini models. + +Deprecated: the `GEMINI_25_*` and `GEMINI_20_*` members. Google has withdrawn +most of that generation, so a `hint` naming one of them previously failed the +whole `ai.prompt()` call. The members still exist and still compile, and a hint +naming a withdrawn model is now served by its current equivalent instead of +erroring — but new code should name a 3.x member. + +The speed/cost tiers that `ai.prompt()` resolves without a hint have also moved +onto current models, so `{ speed: "capable", cost: "high" }` and the other tiers +that previously mapped to withdrawn Gemini models work again. diff --git a/twister/src/tools/ai.ts b/twister/src/tools/ai.ts index 5d4acb96..b7c345a9 100644 --- a/twister/src/tools/ai.ts +++ b/twister/src/tools/ai.ts @@ -188,13 +188,13 @@ export type AICapabilities = { * prompt: "Summarize this in one sentence: ..." * }); * - * // Balanced performance - uses GPT-5 Mini or Gemini 2.5 Flash + * // Balanced performance - uses GPT-5 Mini or Gemini 3.5 Flash * const response = await ai.prompt({ * model: { speed: "balanced", cost: "medium" }, * prompt: "Analyze this data..." * }); * - * // Most capable - uses models like GPT-5, Claude Sonnet 4.6, or Gemini 2.5 Pro + * // Most capable - uses models like GPT-5, Claude Sonnet 4.6, or Gemini 3.1 Pro * const response = await ai.prompt({ * model: { speed: "capable", cost: "high" }, * prompt: "Solve this complex reasoning problem..." @@ -256,11 +256,26 @@ export enum AIModel { CLAUDE_SONNET_46 = "anthropic/claude-sonnet-4-6", CLAUDE_HAIKU_45 = "anthropic/claude-haiku-4-5", - // Google models - Gemini 2.x series + // Google models - Gemini 3.x series + GEMINI_31_PRO = "google/gemini-3.1-pro-preview", + GEMINI_35_FLASH = "google/gemini-3.5-flash", + GEMINI_35_FLASH_LITE = "google/gemini-3.5-flash-lite", + + // Google models - Gemini 2.x series (superseded) + // + // Google has withdrawn most of this generation. The members are kept so that + // twists built against an earlier SDK version still compile, and a hint + // naming a withdrawn model is transparently served by its 3.x equivalent + // rather than failing — but new code should name a 3.x member directly. + /** @deprecated Withdrawn by Google. Use {@link AIModel.GEMINI_31_PRO}. */ GEMINI_25_PRO = "google/gemini-2.5-pro", + /** @deprecated Superseded. Use {@link AIModel.GEMINI_35_FLASH}. */ GEMINI_25_FLASH = "google/gemini-2.5-flash", + /** @deprecated Withdrawn by Google. Use {@link AIModel.GEMINI_35_FLASH_LITE}. */ GEMINI_25_FLASH_LITE = "google/gemini-2.5-flash-lite", + /** @deprecated Withdrawn by Google. Use {@link AIModel.GEMINI_35_FLASH}. */ GEMINI_20_FLASH = "google/gemini-2.0-flash", + /** @deprecated Withdrawn by Google. Use {@link AIModel.GEMINI_35_FLASH_LITE}. */ GEMINI_20_FLASH_LITE = "google/gemini-2.0-flash-lite", // Cloudflare Workers AI models - Free/low-cost models running on Cloudflare's network