From 68a75dc4e3fc5944b9f0ac9a56a41293556cbdca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=C2=B7Dong?= <98630204+GeorgeDong32@users.noreply.github.com> Date: Sun, 4 Jan 2026 18:07:49 +0800 Subject: [PATCH] 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 --- src/renderer/src/config/providers.ts | 1 + src/renderer/src/pages/code/index.ts | 6 ++++++ src/renderer/src/store/index.ts | 2 +- src/renderer/src/store/migrate.ts | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/config/providers.ts b/src/renderer/src/config/providers.ts index 9e2831ee6e..f49794aaa7 100644 --- a/src/renderer/src/config/providers.ts +++ b/src/renderer/src/config/providers.ts @@ -212,6 +212,7 @@ export const SYSTEM_PROVIDERS_CONFIG: Record = type: 'openai', apiKey: '', apiHost: 'https://api.302.ai', + anthropicApiHost: 'https://api.302.ai', models: SYSTEM_MODELS['302ai'], isSystem: true, enabled: false diff --git a/src/renderer/src/pages/code/index.ts b/src/renderer/src/pages/code/index.ts index 78347cd2c7..81f5ddddc3 100644 --- a/src/renderer/src/pages/code/index.ts +++ b/src/renderer/src/pages/code/index.ts @@ -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' + } } } diff --git a/src/renderer/src/store/index.ts b/src/renderer/src/store/index.ts index 3d21d12cc7..4727bdc1e7 100644 --- a/src/renderer/src/store/index.ts +++ b/src/renderer/src/store/index.ts @@ -83,7 +83,7 @@ const persistedReducer = persistReducer( { key: 'cherry-studio', storage, - version: 191, + version: 192, blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs', 'toolPermissions'], migrate }, diff --git a/src/renderer/src/store/migrate.ts b/src/renderer/src/store/migrate.ts index 9375dc3b75..272d9fbaa4 100644 --- a/src/renderer/src/store/migrate.ts +++ b/src/renderer/src/store/migrate.ts @@ -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 + } } }