Skip to content

Commit d4a15c5

Browse files
committed
Clean up duplicate models in claude oauth
1 parent 27f6699 commit d4a15c5

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

common/src/constants/claude-oauth.ts

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,44 +49,30 @@ export const OPENROUTER_TO_ANTHROPIC_MODEL_MAP: Record<string, string> = {
4949
'anthropic/claude-3-5-haiku': 'claude-3-5-haiku-20241022',
5050
'anthropic/claude-3-5-haiku-20241022': 'claude-3-5-haiku-20241022',
5151
'anthropic/claude-3-haiku': 'claude-3-haiku-20240307',
52-
'claude-3.5-haiku': 'claude-3-5-haiku-20241022',
53-
'claude-3-5-haiku': 'claude-3-5-haiku-20241022',
54-
'claude-3-haiku': 'claude-3-haiku-20240307',
5552

5653
// Claude 3.x Sonnet models
5754
'anthropic/claude-3.5-sonnet': 'claude-3-5-sonnet-20241022',
5855
'anthropic/claude-3-5-sonnet': 'claude-3-5-sonnet-20241022',
5956
'anthropic/claude-3-5-sonnet-20241022': 'claude-3-5-sonnet-20241022',
6057
'anthropic/claude-3-5-sonnet-20240620': 'claude-3-5-sonnet-20240620',
6158
'anthropic/claude-3-sonnet': 'claude-3-sonnet-20240229',
62-
'claude-3.5-sonnet': 'claude-3-5-sonnet-20241022',
63-
'claude-3-5-sonnet': 'claude-3-5-sonnet-20241022',
64-
'claude-3-sonnet': 'claude-3-sonnet-20240229',
6559

6660
// Claude 3.x Opus models
6761
'anthropic/claude-3-opus': 'claude-3-opus-20240229',
6862
'anthropic/claude-3-opus-20240229': 'claude-3-opus-20240229',
69-
'claude-3-opus': 'claude-3-opus-20240229',
7063

7164
// Claude 4.x Haiku models
7265
'anthropic/claude-haiku-4.5': 'claude-haiku-4-5-20251001',
7366
'anthropic/claude-haiku-4': 'claude-haiku-4-20250514',
74-
'claude-haiku-4.5': 'claude-haiku-4-5-20251001',
75-
'claude-haiku-4': 'claude-haiku-4-20250514',
7667

7768
// Claude 4.x Sonnet models
7869
'anthropic/claude-sonnet-4.5': 'claude-sonnet-4-5-20250929',
7970
'anthropic/claude-sonnet-4': 'claude-sonnet-4-20250514',
80-
'claude-sonnet-4.5': 'claude-sonnet-4-5-20250929',
81-
'claude-sonnet-4': 'claude-sonnet-4-20250514',
8271

8372
// Claude 4.x Opus models
8473
'anthropic/claude-opus-4.5': 'claude-opus-4-5-20251101',
8574
'anthropic/claude-opus-4.1': 'claude-opus-4-1-20250805',
8675
'anthropic/claude-opus-4': 'claude-opus-4-1-20250805',
87-
'claude-opus-4.5': 'claude-opus-4-5-20251101',
88-
'claude-opus-4.1': 'claude-opus-4-1-20250805',
89-
'claude-opus-4': 'claude-opus-4-1-20250805',
9076
}
9177

9278
/**
@@ -98,24 +84,27 @@ export function isClaudeModel(model: string): boolean {
9884

9985
/**
10086
* Convert an OpenRouter model ID to an Anthropic model ID.
101-
* Returns the original if no mapping exists.
87+
* Throws an error if the model has a provider prefix but is not an Anthropic model.
10288
*/
10389
export function toAnthropicModelId(openrouterModel: string): string {
10490
// If it's already an Anthropic model ID (no prefix), return as-is
10591
if (!openrouterModel.includes('/')) {
10692
return openrouterModel
10793
}
108-
94+
95+
// Require anthropic/ prefix for OpenRouter model IDs
96+
if (!openrouterModel.startsWith('anthropic/')) {
97+
throw new Error(
98+
`Cannot convert non-Anthropic model to Anthropic model ID: ${openrouterModel}`,
99+
)
100+
}
101+
109102
// Check the mapping table
110103
const mapped = OPENROUTER_TO_ANTHROPIC_MODEL_MAP[openrouterModel]
111104
if (mapped) {
112105
return mapped
113106
}
114-
115-
// Fallback: strip the "anthropic/" prefix if present
116-
if (openrouterModel.startsWith('anthropic/')) {
117-
return openrouterModel.replace('anthropic/', '')
118-
}
119-
120-
return openrouterModel
107+
108+
// Fallback: strip the "anthropic/" prefix
109+
return openrouterModel.replace('anthropic/', '')
121110
}

0 commit comments

Comments
 (0)