Skip to content

Commit 2ff97ad

Browse files
committed
refactor: centralize Anthropic protocol value
1 parent 131c1e1 commit 2ff97ad

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

packages/types/src/provider-settings.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,15 @@ export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = [
589589

590590
const CLAUDE_MODEL_ID_FRAGMENT = "claude"
591591
const ANTHROPIC_MODEL_ID_PREFIX = "anthropic/"
592+
const ANTHROPIC_API_PROTOCOL = "anthropic"
592593
const ANTHROPIC_MODEL_GATEWAY_PROVIDERS: ProviderName[] = [
593594
providerIdentifiers.vercelAiGateway,
594595
providerIdentifiers.zooGateway,
595596
]
596597

597598
export const getApiProtocol = (provider: ProviderName | undefined, modelId?: string): "anthropic" | "openai" => {
598599
if (provider && ANTHROPIC_STYLE_PROVIDERS.includes(provider)) {
599-
return "anthropic"
600+
return ANTHROPIC_API_PROTOCOL
600601
}
601602

602603
if (
@@ -605,7 +606,7 @@ export const getApiProtocol = (provider: ProviderName | undefined, modelId?: str
605606
modelId &&
606607
modelId.toLowerCase().includes(CLAUDE_MODEL_ID_FRAGMENT)
607608
) {
608-
return "anthropic"
609+
return ANTHROPIC_API_PROTOCOL
609610
}
610611

611612
// Vercel AI Gateway and Zoo Gateway use the anthropic protocol for anthropic models.
@@ -615,7 +616,7 @@ export const getApiProtocol = (provider: ProviderName | undefined, modelId?: str
615616
modelId &&
616617
modelId.toLowerCase().startsWith(ANTHROPIC_MODEL_ID_PREFIX)
617618
) {
618-
return "anthropic"
619+
return ANTHROPIC_API_PROTOCOL
619620
}
620621

621622
// Opencode Go routes a subset of its models (Qwen, MiniMax) through the
@@ -631,7 +632,7 @@ export const getApiProtocol = (provider: ProviderName | undefined, modelId?: str
631632
modelId &&
632633
isOpencodeGoAnthropicFormatModel(modelId)
633634
) {
634-
return "anthropic"
635+
return ANTHROPIC_API_PROTOCOL
635636
}
636637

637638
return "openai"

0 commit comments

Comments
 (0)