feat: update Gemini and Vertex AI models from preview to GA version

- Remove outdated preview models (gemini-2.5-pro-preview-03-25, gemini-2.5-pro-preview-05-06, gemini-2.5-pro-preview-06-05) from gemini.ts and vertex.ts
- Add backward compatibility logic in Gemini and Vertex providers to automatically map legacy preview models to gemini-2.5-pro GA version
- Update OpenRouter provider to handle legacy preview model mapping
- Update OpenRouter tests to reflect removal of preview model references

Fixes #5444
This commit is contained in:
Roo Code 2025-07-18 17:33:41 +00:00
parent a6e16e80d9
commit 3dacc9fddd
6 changed files with 33 additions and 103 deletions

View file

@ -68,80 +68,6 @@ export const geminiModels = {
inputPrice: 0,
outputPrice: 0,
},
"gemini-2.5-pro-preview-03-25": {
maxTokens: 65_535,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
cacheWritesPrice: 4.5,
tiers: [
{
contextWindow: 200_000,
inputPrice: 1.25,
outputPrice: 10,
cacheReadsPrice: 0.31,
},
{
contextWindow: Infinity,
inputPrice: 2.5,
outputPrice: 15,
cacheReadsPrice: 0.625,
},
],
},
"gemini-2.5-pro-preview-05-06": {
maxTokens: 65_535,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
cacheWritesPrice: 4.5,
tiers: [
{
contextWindow: 200_000,
inputPrice: 1.25,
outputPrice: 10,
cacheReadsPrice: 0.31,
},
{
contextWindow: Infinity,
inputPrice: 2.5,
outputPrice: 15,
cacheReadsPrice: 0.625,
},
],
},
"gemini-2.5-pro-preview-06-05": {
maxTokens: 65_535,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
cacheWritesPrice: 4.5,
maxThinkingTokens: 32_768,
supportsReasoningBudget: true,
tiers: [
{
contextWindow: 200_000,
inputPrice: 1.25,
outputPrice: 10,
cacheReadsPrice: 0.31,
},
{
contextWindow: Infinity,
inputPrice: 2.5,
outputPrice: 15,
cacheReadsPrice: 0.625,
},
],
},
"gemini-2.5-pro": {
maxTokens: 64_000,
contextWindow: 1_048_576,

View file

@ -56,32 +56,6 @@ export const vertexModels = {
inputPrice: 0.15,
outputPrice: 0.6,
},
"gemini-2.5-pro-preview-03-25": {
maxTokens: 65_535,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 2.5,
outputPrice: 15,
},
"gemini-2.5-pro-preview-05-06": {
maxTokens: 65_535,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 2.5,
outputPrice: 15,
},
"gemini-2.5-pro-preview-06-05": {
maxTokens: 65_535,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 2.5,
outputPrice: 15,
maxThinkingTokens: 32_768,
supportsReasoningBudget: true,
},
"gemini-2.5-pro": {
maxTokens: 64_000,
contextWindow: 1_048_576,

View file

@ -29,7 +29,6 @@ describe("OpenRouter API", () => {
// Define models that are intentionally excluded
const excludedModels = new Set([
"google/gemini-2.5-pro-preview", // Excluded due to lag issue (#4487)
"google/gemini-2.5-flash", // OpenRouter doesn't report this as supporting prompt caching
"google/gemini-2.5-flash-lite-preview-06-17", // OpenRouter doesn't report this as supporting prompt caching
])
@ -215,7 +214,7 @@ describe("OpenRouter API", () => {
describe("getOpenRouterModelEndpoints", () => {
it("fetches model endpoints and validates schema", async () => {
const { nockDone } = await nockBack("openrouter-model-endpoints.json")
const endpoints = await getOpenRouterModelEndpoints("google/gemini-2.5-pro-preview")
const endpoints = await getOpenRouterModelEndpoints("google/gemini-2.5-pro")
expect(endpoints).toEqual({
Google: {

View file

@ -129,9 +129,26 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
}
}
/**
* Check if the model ID is a legacy preview model that should be mapped to the GA version
*/
protected isLegacyPreviewModel(modelId: string): boolean {
return [
"gemini-2.5-pro-preview-03-25",
"gemini-2.5-pro-preview-05-06",
"gemini-2.5-pro-preview-06-05"
].includes(modelId)
}
override getModel() {
const modelId = this.options.apiModelId
let id = modelId && modelId in geminiModels ? (modelId as GeminiModelId) : geminiDefaultModelId
// Handle backward compatibility for legacy preview models
if (modelId && this.isLegacyPreviewModel(modelId)) {
id = "gemini-2.5-pro" as GeminiModelId
}
const info: ModelInfo = geminiModels[id]
const params = getModelParams({ format: "gemini", modelId: id, model: info, settings: this.options })

View file

@ -69,6 +69,13 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
this.client = new OpenAI({ baseURL, apiKey, defaultHeaders: DEFAULT_HEADERS })
}
/**
* Check if the model ID is a legacy Gemini preview model that should be mapped to the GA version
*/
private isLegacyGeminiPreviewModel(modelId: string): boolean {
return modelId === "google/gemini-2.5-pro-preview"
}
override async *createMessage(
systemPrompt: string,
messages: Anthropic.Messages.MessageParam[],
@ -83,7 +90,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
// i We should generalize this using the logic in `getModelParams`, but
// this is easier for now.
if (
(modelId === "google/gemini-2.5-pro-preview" || modelId === "google/gemini-2.5-pro") &&
(this.isLegacyGeminiPreviewModel(modelId) || modelId === "google/gemini-2.5-pro") &&
typeof reasoning === "undefined"
) {
reasoning = { exclude: true }

View file

@ -15,6 +15,13 @@ export class VertexHandler extends GeminiHandler implements SingleCompletionHand
override getModel() {
const modelId = this.options.apiModelId
let id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId
// Handle backward compatibility for legacy preview models
// Use the same logic as GeminiHandler
if (modelId && this.isLegacyPreviewModel(modelId)) {
id = "gemini-2.5-pro" as VertexModelId
}
const info: ModelInfo = vertexModels[id]
const params = getModelParams({ format: "gemini", modelId: id, model: info, settings: this.options })