mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-01-31 09:43:07 +08:00
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:
@@ -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 ?? "",
|
||||
|
||||
@@ -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[] = [
|
||||
|
||||
Reference in New Issue
Block a user