feat(claude): add apiFormat support for provider presets

Allow preset providers to specify API format (anthropic or openai_chat),
enabling third-party proxy services that use OpenAI Chat Completions format.
This commit is contained in:
Jason
2026-01-30 15:22:39 +08:00
parent 065d5db843
commit 162800e18e
2 changed files with 13 additions and 0 deletions

View File

@@ -1139,6 +1139,14 @@ export function ProviderForm({
preset.templateValues,
);
// Sync preset's apiFormat to local state (for Claude providers)
if (preset.apiFormat) {
setLocalApiFormat(preset.apiFormat);
} else {
// Reset to default if preset doesn't specify apiFormat
setLocalApiFormat("anthropic");
}
form.reset({
name: preset.name,
websiteUrl: preset.websiteUrl ?? "",

View File

@@ -43,6 +43,11 @@ export interface ProviderPreset {
// 图标配置
icon?: string; // 图标名称
iconColor?: string; // 图标颜色
// Claude API 格式(仅 Claude 供应商使用)
// - "anthropic" (默认): Anthropic Messages API 格式,直接透传
// - "openai_chat": OpenAI Chat Completions 格式,需要格式转换
apiFormat?: "anthropic" | "openai_chat";
}
export const providerPresets: ProviderPreset[] = [