Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/background/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
isUsingOpenRouterApiModel,
isUsingAimlApiModel,
isUsingDeepSeekApiModel,
isUsingGoogleApiModel,
} from '../config/index.mjs'
import '../_locales/i18n'
import { openUrl } from '../utils/open-url'
Expand Down Expand Up @@ -345,6 +346,7 @@ function isUsingOpenAICompatibleApiSession(session) {
isUsingOllamaApiModel(session) ||
isUsingOpenRouterApiModel(session) ||
isUsingAimlApiModel(session) ||
isUsingGoogleApiModel(session) ||
isUsingGptCompletionApiModel(session)
)
}
Expand Down
43 changes: 43 additions & 0 deletions src/config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ export const aimlApiModelKeys = [
'aiml_deepseek_v4_pro',
'aiml_deepseek_v4_flash',
]
export const googleApiModelKeys = [
'googleGemini3_1Pro',
'googleGemini3_5Flash',
'googleGemini3Flash',
'googleGemini2_5Pro',
'googleGemini2_5Flash',
'googleGemini2_5FlashLite',
]
Comment on lines +182 to +189

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The Google Gemini API does not have models named Gemini 3.1, 3.5, or 2.5. These appear to be hallucinated model names. The actual current Gemini models available via the API are Gemini 1.5 Pro, Gemini 1.5 Flash, Gemini 2.0 Flash, Gemini 2.0 Flash-Lite, and Gemini 2.0 Pro. Using the hallucinated model IDs will result in API errors (e.g., 404 or 400 Bad Request).

export const googleApiModelKeys = [
  'googleGemini1_5Pro',
  'googleGemini1_5Flash',
  'googleGemini2_0Flash',
  'googleGemini2_0FlashLite',
  'googleGemini2_0Pro',
]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These model IDs are current and documented by Google. Gemini 3.1, 3.5, 3 Flash, and 2.5 models are available, while Gemini 2.0 was shut down on June 1, 2026. No change is needed: https://ai.google.dev/gemini-api/docs/models


export const AlwaysCustomGroups = [
'ollamaApiModelKeys',
Expand Down Expand Up @@ -253,6 +261,10 @@ export const ModelGroups = {
value: aimlApiModelKeys,
desc: 'AI/ML (API)',
},
googleApiModelKeys: {
value: googleApiModelKeys,
desc: 'Google (API)',
},
customApiModelKeys: {
value: customApiModelKeys,
desc: 'Custom Model',
Expand Down Expand Up @@ -605,6 +617,30 @@ export const Models = {
value: 'deepseek/deepseek-v4-flash',
desc: 'AIML (DeepSeek V4 Flash)',
},
googleGemini3_1Pro: {
value: 'gemini-3.1-pro-preview',
desc: 'Google (Gemini 3.1 Pro Preview)',
},
googleGemini3_5Flash: {
value: 'gemini-3.5-flash',
desc: 'Google (Gemini 3.5 Flash)',
},
googleGemini3Flash: {
value: 'gemini-3-flash-preview',
desc: 'Google (Gemini 3 Flash Preview)',
},
googleGemini2_5Pro: {
value: 'gemini-2.5-pro',
desc: 'Google (Gemini 2.5 Pro)',
},
googleGemini2_5Flash: {
value: 'gemini-2.5-flash',
desc: 'Google (Gemini 2.5 Flash)',
},
googleGemini2_5FlashLite: {
value: 'gemini-2.5-flash-lite',
desc: 'Google (Gemini 2.5 Flash-Lite)',
},
Comment on lines +620 to +643

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Replace the hallucinated Gemini model IDs and descriptions with the actual existing Gemini models supported by the Google API.

Suggested change
googleGemini3_1Pro: {
value: 'gemini-3.1-pro-preview',
desc: 'Google (Gemini 3.1 Pro Preview)',
},
googleGemini3_5Flash: {
value: 'gemini-3.5-flash',
desc: 'Google (Gemini 3.5 Flash)',
},
googleGemini3Flash: {
value: 'gemini-3-flash-preview',
desc: 'Google (Gemini 3 Flash Preview)',
},
googleGemini2_5Pro: {
value: 'gemini-2.5-pro',
desc: 'Google (Gemini 2.5 Pro)',
},
googleGemini2_5Flash: {
value: 'gemini-2.5-flash',
desc: 'Google (Gemini 2.5 Flash)',
},
googleGemini2_5FlashLite: {
value: 'gemini-2.5-flash-lite',
desc: 'Google (Gemini 2.5 Flash-Lite)',
},
googleGemini1_5Pro: {
value: 'gemini-1.5-pro',
desc: 'Google (Gemini 1.5 Pro)',
},
googleGemini1_5Flash: {
value: 'gemini-1.5-flash',
desc: 'Google (Gemini 1.5 Flash)',
},
googleGemini2_0Flash: {
value: 'gemini-2.0-flash',
desc: 'Google (Gemini 2.0 Flash)',
},
googleGemini2_0FlashLite: {
value: 'gemini-2.0-flash-lite-preview',
desc: 'Google (Gemini 2.0 Flash-Lite Preview)',
},
googleGemini2_0Pro: {
value: 'gemini-2.0-pro-exp',
desc: 'Google (Gemini 2.0 Pro Experimental)',
},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These definitions match the current official model IDs. Replacing them with Gemini 1.5 or 2.0 models would introduce outdated or unavailable entries: https://ai.google.dev/gemini-api/docs/deprecations

}

for (const modelName in Models) {
Expand Down Expand Up @@ -673,6 +709,7 @@ export const defaultConfig = {

openRouterApiKey: '',
aimlApiKey: '',
googleApiKey: '',

// advanced

Expand Down Expand Up @@ -711,6 +748,8 @@ export const defaultConfig = {
'claudeOpus48Api',
'claudeSonnet5Api',
'claudeHaiku45Api',
'googleGemini3_1Pro',
'googleGemini3_5Flash',
Comment on lines +751 to +752

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Update the default active API modes to use the corrected Gemini 1.5 Pro and Gemini 1.5 Flash model keys.

Suggested change
'googleGemini3_1Pro',
'googleGemini3_5Flash',
'googleGemini1_5Pro',
'googleGemini1_5Flash',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current defaults intentionally use available Gemini 3.x models. The suggested Gemini 1.5 replacements are outdated, so no change is needed.

'openRouter_auto',
'openRouter_free',
],
Expand Down Expand Up @@ -868,6 +907,10 @@ export function isUsingAimlApiModel(configOrSession) {
return isInApiModeGroup(aimlApiModelKeys, configOrSession)
}

export function isUsingGoogleApiModel(configOrSession) {
return isInApiModeGroup(googleApiModelKeys, configOrSession)
}

export function isUsingChatGLMApiModel(configOrSession) {
return isInApiModeGroup(chatglmApiModelKeys, configOrSession)
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/openai-provider-mappings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const LEGACY_API_KEY_FIELD_BY_PROVIDER_ID = {
aiml: 'aimlApiKey',
chatglm: 'chatglmApiKey',
ollama: 'ollamaApiKey',
google: 'googleApiKey',
'legacy-custom-default': 'customApiKey',
}

Expand All @@ -26,5 +27,6 @@ export const OPENAI_COMPATIBLE_GROUP_TO_PROVIDER_ID = {
aimlApiModelKeys: 'aiml',
chatglmApiModelKeys: 'chatglm',
ollamaApiModelKeys: 'ollama',
googleApiModelKeys: 'google',
customApiModelKeys: 'legacy-custom-default',
}
9 changes: 9 additions & 0 deletions src/services/apis/provider-registry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ const BUILTIN_PROVIDER_TEMPLATE = [
builtin: true,
enabled: true,
},
{
id: 'google',
name: 'Google',
baseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai',
Comment thread
PeterDaveHello marked this conversation as resolved.
chatCompletionsPath: '/chat/completions',
builtin: true,
enabled: true,
},
Comment thread
PeterDaveHello marked this conversation as resolved.
{
id: 'legacy-custom-default',
name: 'Custom Model (Legacy)',
Expand Down Expand Up @@ -111,6 +119,7 @@ function resolveProviderIdFromLegacyModelName(modelName) {
return 'ollama'
}
if (preset.startsWith('chatglm') || preset === 'chatglmApiModelKeys') return 'chatglm'
if (preset.startsWith('googleGemini') || preset === 'googleApiModelKeys') return 'google'
if (preset === 'customApiModelKeys') return 'legacy-custom-default'

return null
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/services/apis/provider-registry.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getProviderById,
resolveEndpointTypeForSession,
resolveOpenAICompatibleRequest,
resolveProviderIdForSession,
} from '../../../../src/services/apis/provider-registry.mjs'

test('resolveEndpointTypeForSession prefers apiMode when present', () => {
Expand Down Expand Up @@ -40,6 +41,15 @@ test('resolveEndpointTypeForSession falls back to legacy modelName when apiMode
assert.equal(resolveEndpointTypeForSession(session), 'completion')
})

test('resolveProviderIdForSession resolves legacy Google preset keys', () => {
assert.equal(resolveProviderIdForSession({ modelName: 'googleGemini2_5Flash' }), 'google')
assert.equal(resolveProviderIdForSession({ modelName: 'googleApiModelKeys-custom' }), 'google')
})

test('resolveProviderIdForSession does not treat raw Gemini model IDs as legacy presets', () => {
assert.equal(resolveProviderIdForSession({ modelName: 'gemini-2.5-flash' }), null)
})
Comment on lines +44 to +51

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update the test cases to use the corrected Gemini model names for consistency and clarity.

Suggested change
test('resolveProviderIdForSession resolves legacy Google preset keys', () => {
assert.equal(resolveProviderIdForSession({ modelName: 'googleGemini2_5Flash' }), 'google')
assert.equal(resolveProviderIdForSession({ modelName: 'googleApiModelKeys-custom' }), 'google')
})
test('resolveProviderIdForSession does not treat raw Gemini model IDs as legacy presets', () => {
assert.equal(resolveProviderIdForSession({ modelName: 'gemini-2.5-flash' }), null)
})
test('resolveProviderIdForSession resolves legacy Google preset keys', () => {
assert.equal(resolveProviderIdForSession({ modelName: 'googleGemini1_5Flash' }), 'google')
assert.equal(resolveProviderIdForSession({ modelName: 'googleApiModelKeys-custom' }), 'google')
})
test('resolveProviderIdForSession does not treat raw Gemini model IDs as legacy presets', () => {
assert.equal(resolveProviderIdForSession({ modelName: 'gemini-1.5-flash' }), null)
})

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test values match the configured current model keys and IDs. Changing them to Gemini 1.5 would make the tests inconsistent with the supported model configuration.


test('resolveOpenAICompatibleRequest resolves custom provider from normalized session provider id', () => {
const config = {
customOpenAIProviders: [
Expand Down