feat(code-tools): add 302.AI as Claude Code provider (#12254)

* feat(code-tools): add 302.AI as Claude Code provider

* feat(agent): add 302.AI anthropicApiHost to enable Agent support

302.AI now supports Claude Code (Agent) functionality by configuring
the anthropicApiHost endpoint. Users can use 302.AI's Claude models
(claude-sonnet-4-20250514, claude-opus-4-20250514) with Agent.

* feat(migrate): add migration 192 to set 302ai API host
This commit is contained in:
George·Dong 2026-01-04 18:07:49 +08:00 committed by GitHub
parent 4c67e5b43a
commit 68a75dc4e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 1 deletions

View File

@ -212,6 +212,7 @@ export const SYSTEM_PROVIDERS_CONFIG: Record<SystemProviderId, SystemProvider> =
type: 'openai',
apiKey: '',
apiHost: 'https://api.302.ai',
anthropicApiHost: 'https://api.302.ai',
models: SYSTEM_MODELS['302ai'],
isSystem: true,
enabled: false

View File

@ -43,6 +43,7 @@ export const CLAUDE_SUPPORTED_PROVIDERS = [
'dmxapi',
'new-api',
'cherryin',
'302ai',
...CLAUDE_OFFICIAL_SUPPORTED_PROVIDERS
]
export const OPENAI_CODEX_SUPPORTED_PROVIDERS = ['openai', 'openrouter', 'aihubmix', 'new-api', 'cherryin']
@ -96,6 +97,11 @@ export const getCodeToolsApiBaseUrl = (model: Model, type: EndpointType) => {
anthropic: {
api_base_url: 'https://api.minimaxi.com/anthropic'
}
},
'302ai': {
anthropic: {
api_base_url: 'https://api.302.ai'
}
}
}

View File

@ -83,7 +83,7 @@ const persistedReducer = persistReducer(
{
key: 'cherry-studio',
storage,
version: 191,
version: 192,
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs', 'toolPermissions'],
migrate
},

View File

@ -3144,6 +3144,20 @@ const migrateConfig = {
logger.error('migrate 191 error', error as Error)
return state
}
},
'192': (state: RootState) => {
try {
state.llm.providers.forEach((provider) => {
if (provider.id === '302ai') {
provider.anthropicApiHost = 'https://api.302.ai'
}
})
logger.info('migrate 192 success')
return state
} catch (error) {
logger.error('migrate 192 error', error as Error)
return state
}
}
}