feat: 添加 AI Gateway Provider (#11064)

* feat: 添加 AI Gateway 提供者支持,包括配置、类型定义和本地化文本

* fix(i18n): Auto update translations for PR #11064

* fix/typecheck

* fix(i18n): Auto update translations for PR #11064

* fix(i18n): Auto update translations for PR #11064

* feat: cerebras

* fix: glm

* fix: minimax api host

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
SuYao 2025-11-13 16:09:49 +08:00 committed by GitHub
parent 060fcd2ce6
commit 2b5ac5ab51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 236 additions and 32 deletions

View File

@ -107,6 +107,8 @@
"@agentic/searxng": "^7.3.3", "@agentic/searxng": "^7.3.3",
"@agentic/tavily": "^7.3.3", "@agentic/tavily": "^7.3.3",
"@ai-sdk/amazon-bedrock": "^3.0.53", "@ai-sdk/amazon-bedrock": "^3.0.53",
"@ai-sdk/cerebras": "^1.0.31",
"@ai-sdk/gateway": "^2.0.9",
"@ai-sdk/google-vertex": "^3.0.62", "@ai-sdk/google-vertex": "^3.0.62",
"@ai-sdk/huggingface": "patch:@ai-sdk/huggingface@npm%3A0.0.8#~/.yarn/patches/@ai-sdk-huggingface-npm-0.0.8-d4d0aaac93.patch", "@ai-sdk/huggingface": "patch:@ai-sdk/huggingface@npm%3A0.0.8#~/.yarn/patches/@ai-sdk-huggingface-npm-0.0.8-d4d0aaac93.patch",
"@ai-sdk/mistral": "^2.0.23", "@ai-sdk/mistral": "^2.0.23",

View File

@ -7,16 +7,17 @@
* 2. * 2.
*/ */
import type { GatewayLanguageModelEntry } from '@ai-sdk/gateway'
import { createExecutor } from '@cherrystudio/ai-core' import { createExecutor } from '@cherrystudio/ai-core'
import { loggerService } from '@logger' import { loggerService } from '@logger'
import { getEnableDeveloperMode } from '@renderer/hooks/useSettings' import { getEnableDeveloperMode } from '@renderer/hooks/useSettings'
import { addSpan, endSpan } from '@renderer/services/SpanManagerService' import { addSpan, endSpan } from '@renderer/services/SpanManagerService'
import type { StartSpanParams } from '@renderer/trace/types/ModelSpanEntity' import type { StartSpanParams } from '@renderer/trace/types/ModelSpanEntity'
import type { Assistant, GenerateImageParams, Model, Provider } from '@renderer/types' import { type Assistant, type GenerateImageParams, type Model, type Provider, SystemProviderIds } from '@renderer/types'
import type { AiSdkModel, StreamTextParams } from '@renderer/types/aiCoreTypes' import type { AiSdkModel, StreamTextParams } from '@renderer/types/aiCoreTypes'
import { SUPPORTED_IMAGE_ENDPOINT_LIST } from '@renderer/utils' import { SUPPORTED_IMAGE_ENDPOINT_LIST } from '@renderer/utils'
import { buildClaudeCodeSystemModelMessage } from '@shared/anthropic' import { buildClaudeCodeSystemModelMessage } from '@shared/anthropic'
import { type ImageModel, type LanguageModel, type Provider as AiSdkProvider, wrapLanguageModel } from 'ai' import { gateway, type ImageModel, type LanguageModel, type Provider as AiSdkProvider, wrapLanguageModel } from 'ai'
import AiSdkToChunkAdapter from './chunk/AiSdkToChunkAdapter' import AiSdkToChunkAdapter from './chunk/AiSdkToChunkAdapter'
import LegacyAiProvider from './legacy/index' import LegacyAiProvider from './legacy/index'
@ -439,6 +440,18 @@ export default class ModernAiProvider {
// 代理其他方法到原有实现 // 代理其他方法到原有实现
public async models() { public async models() {
if (this.actualProvider.id === SystemProviderIds['ai-gateway']) {
const formatModel = function (models: GatewayLanguageModelEntry[]): Model[] {
return models.map((m) => ({
id: m.id,
name: m.name,
provider: 'gateway',
group: m.id.split('/')[0],
description: m.description ?? undefined
}))
}
return formatModel((await gateway.getAvailableModels()).models)
}
return this.legacyProvider.models() return this.legacyProvider.models()
} }

View File

@ -71,6 +71,21 @@ export const NEW_PROVIDER_CONFIGS: ProviderConfig[] = [
creatorFunctionName: 'createHuggingFace', creatorFunctionName: 'createHuggingFace',
supportsImageGeneration: true, supportsImageGeneration: true,
aliases: ['hf', 'hugging-face'] aliases: ['hf', 'hugging-face']
},
{
id: 'ai-gateway',
name: 'AI Gateway',
import: () => import('@ai-sdk/gateway'),
creatorFunctionName: 'createGateway',
supportsImageGeneration: true,
aliases: ['gateway']
},
{
id: 'cerebras',
name: 'Cerebras',
import: () => import('@ai-sdk/cerebras'),
creatorFunctionName: 'createCerebras',
supportsImageGeneration: false
} }
] as const ] as const

View File

@ -151,11 +151,12 @@ export function buildProviderOptions(
...providerSpecificOptions, ...providerSpecificOptions,
...getCustomParameters(assistant) ...getCustomParameters(assistant)
} }
// vertex需要映射到google或anthropic
const rawProviderKey = const rawProviderKey =
{ {
'google-vertex': 'google', 'google-vertex': 'google',
'google-vertex-anthropic': 'anthropic' 'google-vertex-anthropic': 'anthropic',
'ai-gateway': 'gateway'
}[rawProviderId] || rawProviderId }[rawProviderId] || rawProviderId
// 返回 AI Core SDK 要求的格式:{ 'providerId': providerOptions } // 返回 AI Core SDK 要求的格式:{ 'providerId': providerOptions }

View File

@ -109,6 +109,11 @@ export function getReasoningEffort(assistant: Assistant, model: Model): Reasonin
// use thinking, doubao, zhipu, etc. // use thinking, doubao, zhipu, etc.
if (isSupportedThinkingTokenDoubaoModel(model) || isSupportedThinkingTokenZhipuModel(model)) { if (isSupportedThinkingTokenDoubaoModel(model) || isSupportedThinkingTokenZhipuModel(model)) {
if (provider.id === SystemProviderIds.cerebras) {
return {
disable_reasoning: true
}
}
return { thinking: { type: 'disabled' } } return { thinking: { type: 'disabled' } }
} }
@ -306,6 +311,9 @@ export function getReasoningEffort(assistant: Assistant, model: Model): Reasonin
return {} return {}
} }
if (isSupportedThinkingTokenZhipuModel(model)) { if (isSupportedThinkingTokenZhipuModel(model)) {
if (provider.id === SystemProviderIds.cerebras) {
return {}
}
return { thinking: { type: 'enabled' } } return { thinking: { type: 'enabled' } }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -0,0 +1 @@
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Vercel</title><path d="M12 0l12 20.785H0L12 0z"></path></svg>

After

Width:  |  Height:  |  Size: 225 B

View File

@ -1840,5 +1840,26 @@ export const SYSTEM_MODELS: Record<SystemProviderId | 'defaultModel', Model[]> =
group: 'LongCat' group: 'LongCat'
} }
], ],
huggingface: [] huggingface: [],
'ai-gateway': [],
cerebras: [
{
id: 'gpt-oss-120b',
name: 'GPT oss 120B',
provider: 'cerebras',
group: 'openai'
},
{
id: 'zai-glm-4.6',
name: 'GLM 4.6',
provider: 'cerebras',
group: 'zai'
},
{
id: 'qwen-3-235b-a22b-instruct-2507',
name: 'Qwen 3 235B A22B Instruct',
provider: 'cerebras',
group: 'qwen'
}
]
} }

View File

@ -12,6 +12,7 @@ import BaiduCloudProviderLogo from '@renderer/assets/images/providers/baidu-clou
import BailianProviderLogo from '@renderer/assets/images/providers/bailian.png' import BailianProviderLogo from '@renderer/assets/images/providers/bailian.png'
import BurnCloudProviderLogo from '@renderer/assets/images/providers/burncloud.png' import BurnCloudProviderLogo from '@renderer/assets/images/providers/burncloud.png'
import CephalonProviderLogo from '@renderer/assets/images/providers/cephalon.jpeg' import CephalonProviderLogo from '@renderer/assets/images/providers/cephalon.jpeg'
import CerebrasProviderLogo from '@renderer/assets/images/providers/cerebras.webp'
import CherryInProviderLogo from '@renderer/assets/images/providers/cherryin.png' import CherryInProviderLogo from '@renderer/assets/images/providers/cherryin.png'
import DeepSeekProviderLogo from '@renderer/assets/images/providers/deepseek.png' import DeepSeekProviderLogo from '@renderer/assets/images/providers/deepseek.png'
import DmxapiProviderLogo from '@renderer/assets/images/providers/DMXAPI.png' import DmxapiProviderLogo from '@renderer/assets/images/providers/DMXAPI.png'
@ -51,6 +52,7 @@ import StepProviderLogo from '@renderer/assets/images/providers/step.png'
import TencentCloudProviderLogo from '@renderer/assets/images/providers/tencent-cloud-ti.png' import TencentCloudProviderLogo from '@renderer/assets/images/providers/tencent-cloud-ti.png'
import TogetherProviderLogo from '@renderer/assets/images/providers/together.png' import TogetherProviderLogo from '@renderer/assets/images/providers/together.png'
import TokenFluxProviderLogo from '@renderer/assets/images/providers/tokenflux.png' import TokenFluxProviderLogo from '@renderer/assets/images/providers/tokenflux.png'
import AIGatewayProviderLogo from '@renderer/assets/images/providers/vercel.svg'
import VertexAIProviderLogo from '@renderer/assets/images/providers/vertexai.svg' import VertexAIProviderLogo from '@renderer/assets/images/providers/vertexai.svg'
import BytedanceProviderLogo from '@renderer/assets/images/providers/volcengine.png' import BytedanceProviderLogo from '@renderer/assets/images/providers/volcengine.png'
import VoyageAIProviderLogo from '@renderer/assets/images/providers/voyageai.png' import VoyageAIProviderLogo from '@renderer/assets/images/providers/voyageai.png'
@ -470,7 +472,7 @@ export const SYSTEM_PROVIDERS_CONFIG: Record<SystemProviderId, SystemProvider> =
name: 'MiniMax', name: 'MiniMax',
type: 'openai', type: 'openai',
apiKey: '', apiKey: '',
apiHost: 'https://api.minimax.chat/v1/', apiHost: 'https://api.minimax.com/v1/',
models: SYSTEM_MODELS.minimax, models: SYSTEM_MODELS.minimax,
isSystem: true, isSystem: true,
enabled: false enabled: false
@ -675,6 +677,26 @@ export const SYSTEM_PROVIDERS_CONFIG: Record<SystemProviderId, SystemProvider> =
models: [], models: [],
isSystem: true, isSystem: true,
enabled: false enabled: false
},
'ai-gateway': {
id: 'ai-gateway',
name: 'AI Gateway',
type: 'ai-gateway',
apiKey: '',
apiHost: 'https://ai-gateway.vercel.sh/v1',
models: [],
isSystem: true,
enabled: false
},
cerebras: {
id: 'cerebras',
name: 'Cerebras AI',
type: 'openai',
apiKey: '',
apiHost: 'https://api.cerebras.ai/v1',
models: SYSTEM_MODELS.cerebras,
isSystem: true,
enabled: false
} }
} as const } as const
@ -741,7 +763,9 @@ export const PROVIDER_LOGO_MAP: AtLeast<SystemProviderId, string> = {
aionly: AiOnlyProviderLogo, aionly: AiOnlyProviderLogo,
longcat: LongCatProviderLogo, longcat: LongCatProviderLogo,
huggingface: HuggingfaceProviderLogo, huggingface: HuggingfaceProviderLogo,
sophnet: SophnetProviderLogo sophnet: SophnetProviderLogo,
'ai-gateway': AIGatewayProviderLogo,
cerebras: CerebrasProviderLogo
} as const } as const
export function getProviderLogo(providerId: string) { export function getProviderLogo(providerId: string) {
@ -1048,7 +1072,7 @@ export const PROVIDER_URLS: Record<SystemProviderId, ProviderUrls> = {
}, },
minimax: { minimax: {
api: { api: {
url: 'https://api.minimax.chat/v1/' url: 'https://api.minimax.com/v1/'
}, },
websites: { websites: {
official: 'https://platform.minimaxi.com/', official: 'https://platform.minimaxi.com/',
@ -1390,6 +1414,28 @@ export const PROVIDER_URLS: Record<SystemProviderId, ProviderUrls> = {
docs: 'https://huggingface.co/docs', docs: 'https://huggingface.co/docs',
models: 'https://huggingface.co/models' models: 'https://huggingface.co/models'
} }
},
'ai-gateway': {
api: {
url: 'https://ai-gateway.vercel.sh/v1/ai'
},
websites: {
official: 'https://vercel.com/ai-gateway',
apiKey: 'https://vercel.com/',
docs: 'https://vercel.com/docs/ai-gateway',
models: 'https://vercel.com/ai-gateway/models'
}
},
cerebras: {
api: {
url: 'https://api.cerebras.ai/v1'
},
websites: {
official: 'https://www.cerebras.ai',
apiKey: 'https://cloud.cerebras.ai',
docs: 'https://inference-docs.cerebras.ai/introduction',
models: 'https://inference-docs.cerebras.ai/models/overview'
}
} }
} }
@ -1452,7 +1498,7 @@ export const isSupportEnableThinkingProvider = (provider: Provider) => {
) )
} }
const NOT_SUPPORT_SERVICE_TIER_PROVIDERS = ['github', 'copilot'] as const satisfies SystemProviderId[] const NOT_SUPPORT_SERVICE_TIER_PROVIDERS = ['github', 'copilot', 'cerebras'] as const satisfies SystemProviderId[]
/** /**
* service_tier Only for OpenAI API. * service_tier Only for OpenAI API.
@ -1519,6 +1565,10 @@ export function isGeminiProvider(provider: Provider): boolean {
return provider.type === 'gemini' return provider.type === 'gemini'
} }
export function isAIGatewayProvider(provider: Provider): boolean {
return provider.type === 'ai-gateway'
}
const NOT_SUPPORT_API_VERSION_PROVIDERS = ['github', 'copilot', 'perplexity'] as const satisfies SystemProviderId[] const NOT_SUPPORT_API_VERSION_PROVIDERS = ['github', 'copilot', 'perplexity'] as const satisfies SystemProviderId[]
export const isSupportAPIVersionProvider = (provider: Provider) => { export const isSupportAPIVersionProvider = (provider: Provider) => {

View File

@ -86,7 +86,9 @@ const providerKeyMap = {
aionly: 'provider.aionly', aionly: 'provider.aionly',
longcat: 'provider.longcat', longcat: 'provider.longcat',
huggingface: 'provider.huggingface', huggingface: 'provider.huggingface',
sophnet: 'provider.sophnet' sophnet: 'provider.sophnet',
'ai-gateway': 'provider.ai-gateway',
cerebras: 'provider.cerebras'
} as const } as const
/** /**

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "AI Gateway",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "AiOnly", "aionly": "AiOnly",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Baidu Cloud", "baidu-cloud": "Baidu Cloud",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilot", "copilot": "GitHub Copilot",
"dashscope": "Alibaba Cloud", "dashscope": "Alibaba Cloud",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "AI Gateway",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "唯一AI (AiOnly)", "aionly": "唯一AI (AiOnly)",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "百度云千帆", "baidu-cloud": "百度云千帆",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilot", "copilot": "GitHub Copilot",
"dashscope": "阿里云百炼", "dashscope": "阿里云百炼",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "AI 閘道器",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "唯一AI (AiOnly)", "aionly": "唯一AI (AiOnly)",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "百度雲千帆", "baidu-cloud": "百度雲千帆",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilot", "copilot": "GitHub Copilot",
"dashscope": "阿里雲百鍊", "dashscope": "阿里雲百鍊",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "KI-Gateway",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "Einzige KI (AiOnly)", "aionly": "Einzige KI (AiOnly)",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Baidu Cloud Qianfan", "baidu-cloud": "Baidu Cloud Qianfan",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilot", "copilot": "GitHub Copilot",
"dashscope": "Alibaba Cloud Bailian", "dashscope": "Alibaba Cloud Bailian",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "Πύλη Τεχνητής Νοημοσύνης",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "AiOnly", "aionly": "AiOnly",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Baidu Cloud Qianfan", "baidu-cloud": "Baidu Cloud Qianfan",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilot", "copilot": "GitHub Copilot",
"dashscope": "AliCloud Bailian", "dashscope": "AliCloud Bailian",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "Puerta de enlace de IA",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "AiOnly", "aionly": "AiOnly",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Baidu Nube Qiánfān", "baidu-cloud": "Baidu Nube Qiánfān",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copiloto", "copilot": "GitHub Copiloto",
"dashscope": "Álibaba Nube BaiLiàn", "dashscope": "Álibaba Nube BaiLiàn",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "Passerelle IA",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "AiOnly", "aionly": "AiOnly",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Baidu Cloud Qianfan", "baidu-cloud": "Baidu Cloud Qianfan",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilote", "copilot": "GitHub Copilote",
"dashscope": "AliCloud BaiLian", "dashscope": "AliCloud BaiLian",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "AIゲートウェイ",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "AiOnly", "aionly": "AiOnly",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Baidu Cloud", "baidu-cloud": "Baidu Cloud",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilot", "copilot": "GitHub Copilot",
"dashscope": "Alibaba Cloud", "dashscope": "Alibaba Cloud",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "Gateway de IA",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "AiOnly", "aionly": "AiOnly",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Nuvem Baidu", "baidu-cloud": "Nuvem Baidu",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copiloto", "copilot": "GitHub Copiloto",
"dashscope": "Área de Atuação AliCloud", "dashscope": "Área de Atuação AliCloud",

View File

@ -2484,6 +2484,7 @@
}, },
"provider": { "provider": {
"302ai": "302.AI", "302ai": "302.AI",
"ai-gateway": "AI-шлюз",
"aihubmix": "AiHubMix", "aihubmix": "AiHubMix",
"aionly": "AiOnly", "aionly": "AiOnly",
"alayanew": "Alaya NeW", "alayanew": "Alaya NeW",
@ -2494,6 +2495,7 @@
"baidu-cloud": "Baidu Cloud", "baidu-cloud": "Baidu Cloud",
"burncloud": "BurnCloud", "burncloud": "BurnCloud",
"cephalon": "Cephalon", "cephalon": "Cephalon",
"cerebras": "Cerebras AI",
"cherryin": "CherryIN", "cherryin": "CherryIN",
"copilot": "GitHub Copilot", "copilot": "GitHub Copilot",
"dashscope": "Alibaba Cloud", "dashscope": "Alibaba Cloud",

View File

@ -5,6 +5,7 @@ import { ApiKeyListPopup } from '@renderer/components/Popups/ApiKeyListPopup'
import Selector from '@renderer/components/Selector' import Selector from '@renderer/components/Selector'
import { isEmbeddingModel, isRerankModel } from '@renderer/config/models' import { isEmbeddingModel, isRerankModel } from '@renderer/config/models'
import { import {
isAIGatewayProvider,
isAnthropicProvider, isAnthropicProvider,
isAzureOpenAIProvider, isAzureOpenAIProvider,
isGeminiProvider, isGeminiProvider,
@ -305,6 +306,9 @@ const ProviderSetting: FC<Props> = ({ providerId }) => {
if (isVertexProvider(provider)) { if (isVertexProvider(provider)) {
return formatVertexApiHost(provider) + '/publishers/google' return formatVertexApiHost(provider) + '/publishers/google'
} }
if (isAIGatewayProvider(provider)) {
return formatApiHost(apiHost) + '/language-model'
}
return formatApiHost(apiHost) return formatApiHost(apiHost)
} }
@ -520,24 +524,17 @@ const ProviderSetting: FC<Props> = ({ providerId }) => {
<SettingHelpText>{t('settings.provider.vertex_ai.api_host_help')}</SettingHelpText> <SettingHelpText>{t('settings.provider.vertex_ai.api_host_help')}</SettingHelpText>
</SettingHelpTextRow> </SettingHelpTextRow>
)} )}
{(isOpenAICompatibleProvider(provider) || <SettingHelpTextRow style={{ justifyContent: 'space-between' }}>
isAzureOpenAIProvider(provider) || <SettingHelpText
isAnthropicProvider(provider) || style={{
isGeminiProvider(provider) || marginLeft: 6,
isVertexProvider(provider) || marginRight: '1em',
isOpenAIProvider(provider)) && ( whiteSpace: 'break-spaces',
<SettingHelpTextRow style={{ justifyContent: 'space-between' }}> wordBreak: 'break-all'
<SettingHelpText }}>
style={{ {t('settings.provider.api_host_preview', { url: hostPreview() })}
marginLeft: 6, </SettingHelpText>
marginRight: '1em', </SettingHelpTextRow>
whiteSpace: 'break-spaces',
wordBreak: 'break-all'
}}>
{t('settings.provider.api_host_preview', { url: hostPreview() })}
</SettingHelpText>
</SettingHelpTextRow>
)}
</> </>
)} )}

View File

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

View File

@ -2802,6 +2802,23 @@ const migrateConfig = {
logger.error('migrate 173 error', error as Error) logger.error('migrate 173 error', error as Error)
return state return state
} }
},
'174': (state: RootState) => {
try {
addProvider(state, SystemProviderIds.longcat)
addProvider(state, SystemProviderIds['ai-gateway'])
addProvider(state, 'cerebras')
state.llm.providers.forEach((provider) => {
if (provider.id === SystemProviderIds.minimax) {
provider.anthropicApiHost = 'https://api.minimaxi.com/anthropic'
}
})
return state
} catch (error) {
logger.error('migrate 174 error', error as Error)
return state
}
} }
} }

View File

@ -11,7 +11,8 @@ export const ProviderTypeSchema = z.enum([
'mistral', 'mistral',
'aws-bedrock', 'aws-bedrock',
'vertex-anthropic', 'vertex-anthropic',
'new-api' 'new-api',
'ai-gateway'
]) ])
export type ProviderType = z.infer<typeof ProviderTypeSchema> export type ProviderType = z.infer<typeof ProviderTypeSchema>
@ -176,7 +177,9 @@ export const SystemProviderIds = {
poe: 'poe', poe: 'poe',
aionly: 'aionly', aionly: 'aionly',
longcat: 'longcat', longcat: 'longcat',
huggingface: 'huggingface' huggingface: 'huggingface',
'ai-gateway': 'ai-gateway',
cerebras: 'cerebras'
} as const } as const
export type SystemProviderId = keyof typeof SystemProviderIds export type SystemProviderId = keyof typeof SystemProviderIds

View File

@ -97,6 +97,7 @@ export type ReasoningEffortOptionalParams = {
} }
} }
} }
disable_reasoning?: boolean
// Add any other potential reasoning-related keys here if they exist // Add any other potential reasoning-related keys here if they exist
} }

View File

@ -127,6 +127,19 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@ai-sdk/cerebras@npm:^1.0.31":
version: 1.0.31
resolution: "@ai-sdk/cerebras@npm:1.0.31"
dependencies:
"@ai-sdk/openai-compatible": "npm:1.0.27"
"@ai-sdk/provider": "npm:2.0.0"
"@ai-sdk/provider-utils": "npm:3.0.17"
peerDependencies:
zod: ^3.25.76 || ^4.1.8
checksum: 10c0/0723f0041b767acfb7a9d903d51d5c95af83c31c89b83f242cb5c02a076d8b98f6567334eb32dcdbc8565b55ded2aa5195ca68612bbe7b13e68253cf4ef412d6
languageName: node
linkType: hard
"@ai-sdk/deepseek@npm:^1.0.27": "@ai-sdk/deepseek@npm:^1.0.27":
version: 1.0.27 version: 1.0.27
resolution: "@ai-sdk/deepseek@npm:1.0.27" resolution: "@ai-sdk/deepseek@npm:1.0.27"
@ -153,6 +166,19 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@ai-sdk/gateway@npm:^2.0.9":
version: 2.0.9
resolution: "@ai-sdk/gateway@npm:2.0.9"
dependencies:
"@ai-sdk/provider": "npm:2.0.0"
"@ai-sdk/provider-utils": "npm:3.0.17"
"@vercel/oidc": "npm:3.0.3"
peerDependencies:
zod: ^3.25.76 || ^4.1.8
checksum: 10c0/840f94795b96c0fa6e73897ea8dba95fc78af1f8482f3b7d8439b6233b4f4de6979a8b67206f4bbf32649baf2acfb1153a46792dfa20259ca9f5fd214fb25fa5
languageName: node
linkType: hard
"@ai-sdk/google-vertex@npm:^3.0.62": "@ai-sdk/google-vertex@npm:^3.0.62":
version: 3.0.62 version: 3.0.62
resolution: "@ai-sdk/google-vertex@npm:3.0.62" resolution: "@ai-sdk/google-vertex@npm:3.0.62"
@ -242,6 +268,18 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@ai-sdk/openai-compatible@npm:1.0.27":
version: 1.0.27
resolution: "@ai-sdk/openai-compatible@npm:1.0.27"
dependencies:
"@ai-sdk/provider": "npm:2.0.0"
"@ai-sdk/provider-utils": "npm:3.0.17"
peerDependencies:
zod: ^3.25.76 || ^4.1.8
checksum: 10c0/9f656e4f2ea4d714dc05be588baafd962b2e0360e9195fef373e745efeb20172698ea87e1033c0c5e1f1aa6e0db76a32629427bc8433eb42bd1a0ee00e04af0c
languageName: node
linkType: hard
"@ai-sdk/openai-compatible@npm:^1.0.19": "@ai-sdk/openai-compatible@npm:^1.0.19":
version: 1.0.19 version: 1.0.19
resolution: "@ai-sdk/openai-compatible@npm:1.0.19" resolution: "@ai-sdk/openai-compatible@npm:1.0.19"
@ -316,7 +354,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@ai-sdk/provider-utils@npm:3.0.17, @ai-sdk/provider-utils@npm:^3.0.10, @ai-sdk/provider-utils@npm:^3.0.12": "@ai-sdk/provider-utils@npm:3.0.17, @ai-sdk/provider-utils@npm:^3.0.10":
version: 3.0.17 version: 3.0.17
resolution: "@ai-sdk/provider-utils@npm:3.0.17" resolution: "@ai-sdk/provider-utils@npm:3.0.17"
dependencies: dependencies:
@ -329,6 +367,19 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@ai-sdk/provider-utils@npm:^3.0.12":
version: 3.0.12
resolution: "@ai-sdk/provider-utils@npm:3.0.12"
dependencies:
"@ai-sdk/provider": "npm:2.0.0"
"@standard-schema/spec": "npm:^1.0.0"
eventsource-parser: "npm:^3.0.5"
peerDependencies:
zod: ^3.25.76 || ^4.1.8
checksum: 10c0/83886bf188cad0cc655b680b710a10413989eaba9ec59dd24a58b985c02a8a1d50ad0f96dd5259385c07592ec3c37a7769fdf4a1ef569a73c9edbdb2cd585915
languageName: node
linkType: hard
"@ai-sdk/provider@npm:2.0.0, @ai-sdk/provider@npm:^2.0.0": "@ai-sdk/provider@npm:2.0.0, @ai-sdk/provider@npm:^2.0.0":
version: 2.0.0 version: 2.0.0
resolution: "@ai-sdk/provider@npm:2.0.0" resolution: "@ai-sdk/provider@npm:2.0.0"
@ -9879,6 +9930,8 @@ __metadata:
"@agentic/searxng": "npm:^7.3.3" "@agentic/searxng": "npm:^7.3.3"
"@agentic/tavily": "npm:^7.3.3" "@agentic/tavily": "npm:^7.3.3"
"@ai-sdk/amazon-bedrock": "npm:^3.0.53" "@ai-sdk/amazon-bedrock": "npm:^3.0.53"
"@ai-sdk/cerebras": "npm:^1.0.31"
"@ai-sdk/gateway": "npm:^2.0.9"
"@ai-sdk/google-vertex": "npm:^3.0.62" "@ai-sdk/google-vertex": "npm:^3.0.62"
"@ai-sdk/huggingface": "patch:@ai-sdk/huggingface@npm%3A0.0.8#~/.yarn/patches/@ai-sdk-huggingface-npm-0.0.8-d4d0aaac93.patch" "@ai-sdk/huggingface": "patch:@ai-sdk/huggingface@npm%3A0.0.8#~/.yarn/patches/@ai-sdk-huggingface-npm-0.0.8-d4d0aaac93.patch"
"@ai-sdk/mistral": "npm:^2.0.23" "@ai-sdk/mistral": "npm:^2.0.23"