feat(tokenflux): add Anthropic host support using OpenRouter package (#12188)

* feat(tokenflux): add Anthropic host support using OpenRouter package

- Add anthropicApiHost to TokenFlux provider config
- Map TokenFlux to OpenRouter in STATIC_PROVIDER_MAPPING for full compatibility

* feat(tokenflux): update API URLs and add migration

- Update apiHost to https://api.tokenflux.ai/openai/v1
- Update anthropicApiHost to https://api.tokenflux.ai/anthropic
- Add migration 191 to update existing TokenFlux users

* fix(tokenflux): add to Anthropic compatible providers list

Enable Anthropic API host configuration in TokenFlux provider settings UI
This commit is contained in:
LiuVaayne 2025-12-29 18:24:57 +08:00 committed by GitHub
parent cccf9bb7be
commit efbe64e5da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 4 deletions

View File

@ -31,7 +31,8 @@ const STATIC_PROVIDER_MAPPING: Record<string, ProviderId> = {
'azure-openai': 'azure', // Azure OpenAI -> azure
'openai-response': 'openai', // OpenAI Responses -> openai
grok: 'xai', // Grok -> xai
copilot: 'github-copilot-openai-compatible'
copilot: 'github-copilot-openai-compatible',
tokenflux: 'openrouter' // TokenFlux -> openrouter (fully compatible)
}
/**

View File

@ -200,7 +200,8 @@ export const SYSTEM_PROVIDERS_CONFIG: Record<SystemProviderId, SystemProvider> =
name: 'TokenFlux',
type: 'openai',
apiKey: '',
apiHost: 'https://tokenflux.ai',
apiHost: 'https://api.tokenflux.ai/openai/v1',
anthropicApiHost: 'https://api.tokenflux.ai/anthropic',
models: SYSTEM_MODELS.tokenflux,
isSystem: true,
enabled: false

View File

@ -82,7 +82,8 @@ const ANTHROPIC_COMPATIBLE_PROVIDER_IDS = [
SystemProviderIds.qiniu,
SystemProviderIds.dmxapi,
SystemProviderIds.mimo,
SystemProviderIds.openrouter
SystemProviderIds.openrouter,
SystemProviderIds.tokenflux
] as const
type AnthropicCompatibleProviderId = (typeof ANTHROPIC_COMPATIBLE_PROVIDER_IDS)[number]

View File

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

View File

@ -3129,6 +3129,21 @@ const migrateConfig = {
logger.error('migrate 190 error', error as Error)
return state
}
},
'191': (state: RootState) => {
try {
state.llm.providers.forEach((provider) => {
if (provider.id === 'tokenflux') {
provider.apiHost = 'https://api.tokenflux.ai/openai/v1'
provider.anthropicApiHost = 'https://api.tokenflux.ai/anthropic'
}
})
logger.info('migrate 191 success')
return state
} catch (error) {
logger.error('migrate 191 error', error as Error)
return state
}
}
}