**feat(registry): expand Gemini model definitions and support Vertex AI**

This commit is contained in:
Luis Pater
2025-11-20 18:16:26 +08:00
parent d50b0f7524
commit 371324c090
2 changed files with 257 additions and 125 deletions

View File

@@ -68,28 +68,13 @@ func GetClaudeModels() []*ModelInfo {
} }
} }
// GeminiModels returns the shared base Gemini model set used by multiple providers. // GetGeminiModels returns the standard Gemini model definitions
func GeminiModels() []*ModelInfo { func GetGeminiModels() []*ModelInfo {
return []*ModelInfo{ return []*ModelInfo{
{
ID: "gemini-2.5-flash",
Object: "model",
Created: time.Now().Unix(),
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash",
Version: "001",
DisplayName: "Gemini 2.5 Flash",
Description: "Stable version of Gemini 2.5 Flash, our mid-size multimodal model that supports up to 1 million tokens, released in June of 2025.",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{ {
ID: "gemini-2.5-pro", ID: "gemini-2.5-pro",
Object: "model", Object: "model",
Created: time.Now().Unix(), Created: 1750118400,
OwnedBy: "google", OwnedBy: "google",
Type: "gemini", Type: "gemini",
Name: "models/gemini-2.5-pro", Name: "models/gemini-2.5-pro",
@@ -101,10 +86,25 @@ func GeminiModels() []*ModelInfo {
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"}, SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true}, Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
}, },
{
ID: "gemini-2.5-flash",
Object: "model",
Created: 1750118400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash",
Version: "001",
DisplayName: "Gemini 2.5 Flash",
Description: "Stable version of Gemini 2.5 Flash, our mid-size multimodal model that supports up to 1 million tokens, released in June of 2025.",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{ {
ID: "gemini-2.5-flash-lite", ID: "gemini-2.5-flash-lite",
Object: "model", Object: "model",
Created: time.Now().Unix(), Created: 1753142400,
OwnedBy: "google", OwnedBy: "google",
Type: "gemini", Type: "gemini",
Name: "models/gemini-2.5-flash-lite", Name: "models/gemini-2.5-flash-lite",
@@ -119,7 +119,7 @@ func GeminiModels() []*ModelInfo {
{ {
ID: "gemini-3-pro-preview", ID: "gemini-3-pro-preview",
Object: "model", Object: "model",
Created: time.Now().Unix(), Created: 1737158400,
OwnedBy: "google", OwnedBy: "google",
Type: "gemini", Type: "gemini",
Name: "models/gemini-3-pro-preview", Name: "models/gemini-3-pro-preview",
@@ -134,31 +134,12 @@ func GeminiModels() []*ModelInfo {
} }
} }
// GetGeminiModels returns the standard Gemini model definitions func GetGeminiVertexModels() []*ModelInfo {
func GetGeminiModels() []*ModelInfo { return GeminiModels() }
// GetGeminiCLIModels returns the standard Gemini model definitions
func GetGeminiCLIModels() []*ModelInfo {
return []*ModelInfo{ return []*ModelInfo{
{
ID: "gemini-2.5-flash",
Object: "model",
Created: time.Now().Unix(),
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash",
Version: "001",
DisplayName: "Gemini 2.5 Flash",
Description: "Stable version of Gemini 2.5 Flash, our mid-size multimodal model that supports up to 1 million tokens, released in June of 2025.",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{ {
ID: "gemini-2.5-pro", ID: "gemini-2.5-pro",
Object: "model", Object: "model",
Created: time.Now().Unix(), Created: 1750118400,
OwnedBy: "google", OwnedBy: "google",
Type: "gemini", Type: "gemini",
Name: "models/gemini-2.5-pro", Name: "models/gemini-2.5-pro",
@@ -170,10 +151,25 @@ func GetGeminiCLIModels() []*ModelInfo {
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"}, SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true}, Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
}, },
{
ID: "gemini-2.5-flash",
Object: "model",
Created: 1750118400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash",
Version: "001",
DisplayName: "Gemini 2.5 Flash",
Description: "Stable version of Gemini 2.5 Flash, our mid-size multimodal model that supports up to 1 million tokens, released in June of 2025.",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{ {
ID: "gemini-2.5-flash-lite", ID: "gemini-2.5-flash-lite",
Object: "model", Object: "model",
Created: time.Now().Unix(), Created: 1753142400,
OwnedBy: "google", OwnedBy: "google",
Type: "gemini", Type: "gemini",
Name: "models/gemini-2.5-flash-lite", Name: "models/gemini-2.5-flash-lite",
@@ -188,7 +184,87 @@ func GetGeminiCLIModels() []*ModelInfo {
{ {
ID: "gemini-3-pro-preview", ID: "gemini-3-pro-preview",
Object: "model", Object: "model",
Created: time.Now().Unix(), Created: 1737158400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-3-pro-preview",
Version: "3.0",
DisplayName: "Gemini 3 Pro Preview",
Description: "Gemini 3 Pro Preview",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
},
{
ID: "gemini-3-pro-image-preview",
Object: "model",
Created: 1737158400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-3-pro-image-preview",
Version: "3.0",
DisplayName: "Gemini 3 Pro Image Preview",
Description: "Gemini 3 Pro Image Preview",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
},
}
}
// GetGeminiCLIModels returns the standard Gemini model definitions
func GetGeminiCLIModels() []*ModelInfo {
return []*ModelInfo{
{
ID: "gemini-2.5-pro",
Object: "model",
Created: 1750118400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-pro",
Version: "2.5",
DisplayName: "Gemini 2.5 Pro",
Description: "Stable release (June 17th, 2025) of Gemini 2.5 Pro",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
},
{
ID: "gemini-2.5-flash",
Object: "model",
Created: 1750118400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash",
Version: "001",
DisplayName: "Gemini 2.5 Flash",
Description: "Stable version of Gemini 2.5 Flash, our mid-size multimodal model that supports up to 1 million tokens, released in June of 2025.",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{
ID: "gemini-2.5-flash-lite",
Object: "model",
Created: 1753142400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash-lite",
Version: "2.5",
DisplayName: "Gemini 2.5 Flash Lite",
Description: "Our smallest and most cost effective model, built for at scale usage.",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{
ID: "gemini-3-pro-preview",
Object: "model",
Created: 1737158400,
OwnedBy: "google", OwnedBy: "google",
Type: "gemini", Type: "gemini",
Name: "models/gemini-3-pro-preview", Name: "models/gemini-3-pro-preview",
@@ -205,87 +281,143 @@ func GetGeminiCLIModels() []*ModelInfo {
// GetAIStudioModels returns the Gemini model definitions for AI Studio integrations // GetAIStudioModels returns the Gemini model definitions for AI Studio integrations
func GetAIStudioModels() []*ModelInfo { func GetAIStudioModels() []*ModelInfo {
base := GeminiModels() return []*ModelInfo{
{
return append(base, ID: "gemini-2.5-pro",
[]*ModelInfo{ Object: "model",
{ Created: 1750118400,
ID: "gemini-pro-latest", OwnedBy: "google",
Object: "model", Type: "gemini",
Created: time.Now().Unix(), Name: "models/gemini-2.5-pro",
OwnedBy: "google", Version: "2.5",
Type: "gemini", DisplayName: "Gemini 2.5 Pro",
Name: "models/gemini-pro-latest", Description: "Stable release (June 17th, 2025) of Gemini 2.5 Pro",
Version: "2.5", InputTokenLimit: 1048576,
DisplayName: "Gemini Pro Latest", OutputTokenLimit: 65536,
Description: "Latest release of Gemini Pro", SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
InputTokenLimit: 1048576, Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
OutputTokenLimit: 65536, },
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"}, {
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true}, ID: "gemini-2.5-flash",
}, Object: "model",
{ Created: 1750118400,
ID: "gemini-flash-latest", OwnedBy: "google",
Object: "model", Type: "gemini",
Created: time.Now().Unix(), Name: "models/gemini-2.5-flash",
OwnedBy: "google", Version: "001",
Type: "gemini", DisplayName: "Gemini 2.5 Flash",
Name: "models/gemini-flash-latest", Description: "Stable version of Gemini 2.5 Flash, our mid-size multimodal model that supports up to 1 million tokens, released in June of 2025.",
Version: "2.5", InputTokenLimit: 1048576,
DisplayName: "Gemini Flash Latest", OutputTokenLimit: 65536,
Description: "Latest release of Gemini Flash", SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
InputTokenLimit: 1048576, Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
OutputTokenLimit: 65536, },
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"}, {
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, ID: "gemini-2.5-flash-lite",
}, Object: "model",
{ Created: 1753142400,
ID: "gemini-flash-lite-latest", OwnedBy: "google",
Object: "model", Type: "gemini",
Created: time.Now().Unix(), Name: "models/gemini-2.5-flash-lite",
OwnedBy: "google", Version: "2.5",
Type: "gemini", DisplayName: "Gemini 2.5 Flash Lite",
Name: "models/gemini-flash-lite-latest", Description: "Our smallest and most cost effective model, built for at scale usage.",
Version: "2.5", InputTokenLimit: 1048576,
DisplayName: "Gemini Flash-Lite Latest", OutputTokenLimit: 65536,
Description: "Latest release of Gemini Flash-Lite", SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
InputTokenLimit: 1048576, Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
OutputTokenLimit: 65536, },
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"}, {
Thinking: &ThinkingSupport{Min: 512, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, ID: "gemini-3-pro-preview",
}, Object: "model",
{ Created: 1737158400,
ID: "gemini-2.5-flash-image-preview", OwnedBy: "google",
Object: "model", Type: "gemini",
Created: time.Now().Unix(), Name: "models/gemini-3-pro-preview",
OwnedBy: "google", Version: "3.0",
Type: "gemini", DisplayName: "Gemini 3 Pro Preview",
Name: "models/gemini-2.5-flash-image-preview", Description: "Gemini 3 Pro Preview",
Version: "2.5", InputTokenLimit: 1048576,
DisplayName: "Gemini 2.5 Flash Image Preview", OutputTokenLimit: 65536,
Description: "State-of-the-art image generation and editing model.", SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
InputTokenLimit: 1048576, Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
OutputTokenLimit: 8192, },
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"}, {
// image models don't support thinkingConfig; leave Thinking nil ID: "gemini-pro-latest",
}, Object: "model",
{ Created: 1750118400,
ID: "gemini-2.5-flash-image", OwnedBy: "google",
Object: "model", Type: "gemini",
Created: time.Now().Unix(), Name: "models/gemini-pro-latest",
OwnedBy: "google", Version: "2.5",
Type: "gemini", DisplayName: "Gemini Pro Latest",
Name: "models/gemini-2.5-flash-image", Description: "Latest release of Gemini Pro",
Version: "2.5", InputTokenLimit: 1048576,
DisplayName: "Gemini 2.5 Flash Image", OutputTokenLimit: 65536,
Description: "State-of-the-art image generation and editing model.", SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
InputTokenLimit: 1048576, Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
OutputTokenLimit: 8192, },
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"}, {
// image models don't support thinkingConfig; leave Thinking nil ID: "gemini-flash-latest",
}, Object: "model",
}..., Created: 1750118400,
) OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-flash-latest",
Version: "2.5",
DisplayName: "Gemini Flash Latest",
Description: "Latest release of Gemini Flash",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{
ID: "gemini-flash-lite-latest",
Object: "model",
Created: 1753142400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-flash-lite-latest",
Version: "2.5",
DisplayName: "Gemini Flash-Lite Latest",
Description: "Latest release of Gemini Flash-Lite",
InputTokenLimit: 1048576,
OutputTokenLimit: 65536,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
Thinking: &ThinkingSupport{Min: 512, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
},
{
ID: "gemini-2.5-flash-image-preview",
Object: "model",
Created: 1756166400,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash-image-preview",
Version: "2.5",
DisplayName: "Gemini 2.5 Flash Image Preview",
Description: "State-of-the-art image generation and editing model.",
InputTokenLimit: 1048576,
OutputTokenLimit: 8192,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
// image models don't support thinkingConfig; leave Thinking nil
},
{
ID: "gemini-2.5-flash-image",
Object: "model",
Created: 1759363200,
OwnedBy: "google",
Type: "gemini",
Name: "models/gemini-2.5-flash-image",
Version: "2.5",
DisplayName: "Gemini 2.5 Flash Image",
Description: "State-of-the-art image generation and editing model.",
InputTokenLimit: 1048576,
OutputTokenLimit: 8192,
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
// image models don't support thinkingConfig; leave Thinking nil
},
}
} }
// GetOpenAIModels returns the standard OpenAI model definitions // GetOpenAIModels returns the standard OpenAI model definitions

View File

@@ -629,7 +629,7 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) {
models = registry.GetGeminiModels() models = registry.GetGeminiModels()
case "vertex": case "vertex":
// Vertex AI Gemini supports the same model identifiers as Gemini. // Vertex AI Gemini supports the same model identifiers as Gemini.
models = registry.GetGeminiModels() models = registry.GetGeminiVertexModels()
case "gemini-cli": case "gemini-cli":
models = registry.GetGeminiCLIModels() models = registry.GetGeminiCLIModels()
case "aistudio": case "aistudio":