Skip to content

Commit fcd904d

Browse files
committed
test: address protocol routing review feedback
1 parent 7b084ea commit fcd904d

3 files changed

Lines changed: 17 additions & 19 deletions

File tree

packages/types/src/__tests__/provider-settings.test.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import { ANTHROPIC_API_PROTOCOL, getApiProtocol, OPENAI_API_PROTOCOL, providerIdentifiers } from "../index.js"
22

33
describe("getApiProtocol", () => {
4-
describe("Anthropic-style providers", () => {
5-
it("should return 'anthropic' for anthropic provider", () => {
6-
expect(getApiProtocol(providerIdentifiers.anthropic)).toBe(ANTHROPIC_API_PROTOCOL)
7-
expect(getApiProtocol(providerIdentifiers.anthropic, "gpt-4")).toBe(ANTHROPIC_API_PROTOCOL)
8-
})
4+
it("preserves API protocol wire values", () => {
5+
expect(ANTHROPIC_API_PROTOCOL).toBe("anthropic")
6+
expect(OPENAI_API_PROTOCOL).toBe("openai")
7+
})
98

10-
it("should return 'anthropic' for bedrock provider", () => {
11-
expect(getApiProtocol(providerIdentifiers.bedrock)).toBe(ANTHROPIC_API_PROTOCOL)
12-
expect(getApiProtocol(providerIdentifiers.bedrock, "gpt-4")).toBe(ANTHROPIC_API_PROTOCOL)
13-
expect(getApiProtocol(providerIdentifiers.bedrock, "claude-3-opus")).toBe(ANTHROPIC_API_PROTOCOL)
14-
})
9+
describe("Anthropic-style providers", () => {
10+
it.each([providerIdentifiers.anthropic, providerIdentifiers.bedrock, providerIdentifiers.minimax])(
11+
"should return 'anthropic' for %s provider",
12+
(provider) => {
13+
expect(getApiProtocol(provider)).toBe(ANTHROPIC_API_PROTOCOL)
14+
expect(getApiProtocol(provider, "gpt-4")).toBe(ANTHROPIC_API_PROTOCOL)
15+
},
16+
)
1517
})
1618

1719
describe("Vertex provider with Claude models", () => {
@@ -33,11 +35,8 @@ describe("getApiProtocol", () => {
3335
})
3436
})
3537

36-
describe("Vercel AI Gateway provider", () => {
37-
it("uses canonical gateway identifiers for Anthropic model protocol selection", () => {
38-
expect(getApiProtocol(providerIdentifiers.vercelAiGateway, "anthropic/claude-3-opus")).toBe(
39-
ANTHROPIC_API_PROTOCOL,
40-
)
38+
describe("Gateway providers", () => {
39+
it("uses the canonical Zoo Gateway identifier for Anthropic model protocol selection", () => {
4140
expect(getApiProtocol(providerIdentifiers.zooGateway, "anthropic/claude-3-opus")).toBe(
4241
ANTHROPIC_API_PROTOCOL,
4342
)

packages/types/src/provider-settings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import {
3030
mimoModels,
3131
isOpencodeGoAnthropicFormatModel,
3232
ANTHROPIC_API_PROTOCOL,
33-
ANTHROPIC_MODEL_ID_PREFIX,
34-
CLAUDE_MODEL_ID_FRAGMENT,
3533
OPENAI_API_PROTOCOL,
3634
} from "./providers/index.js"
3735

@@ -596,6 +594,9 @@ const ANTHROPIC_MODEL_GATEWAY_PROVIDERS: ProviderName[] = [
596594
providerIdentifiers.zooGateway,
597595
]
598596

597+
const ANTHROPIC_MODEL_ID_PREFIX = "anthropic/"
598+
const CLAUDE_MODEL_ID_FRAGMENT = "claude"
599+
599600
export const getApiProtocol = (provider: ProviderName | undefined, modelId?: string): "anthropic" | "openai" => {
600601
if (provider && ANTHROPIC_STYLE_PROVIDERS.includes(provider)) {
601602
return ANTHROPIC_API_PROTOCOL

packages/types/src/providers/anthropic.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import type { ModelInfo } from "../model.js"
66
export type AnthropicModelId = keyof typeof anthropicModels
77
export const anthropicDefaultModelId: AnthropicModelId = "claude-sonnet-4-5"
88
export const ANTHROPIC_API_PROTOCOL = "anthropic"
9-
export const ANTHROPIC_MODEL_ID_PREFIX = "anthropic/"
10-
export const CLAUDE_MODEL_ID_FRAGMENT = "claude"
119

1210
export const anthropicModels = {
1311
"claude-sonnet-4-6": {

0 commit comments

Comments
 (0)