Skip to content

Commit ff1076a

Browse files
committed
Cleanup & fix model strings
1 parent 57c1c3c commit ff1076a

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

common/src/constants/claude-oauth.ts

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ export const CLAUDE_OAUTH_TOKEN_ENV_VAR = 'CODEBUFF_CLAUDE_OAUTH_TOKEN'
1919
// Required Anthropic API version header
2020
export const ANTHROPIC_API_VERSION = '2023-06-01'
2121

22+
/**
23+
* Beta headers required for Claude OAuth access to Claude 4+ models.
24+
* These must be included in the anthropic-beta header when making requests.
25+
*/
26+
export const CLAUDE_OAUTH_BETA_HEADERS = [
27+
'oauth-2025-04-20',
28+
'claude-code-20250219',
29+
'interleaved-thinking-2025-05-14',
30+
'fine-grained-tool-streaming-2025-05-14',
31+
] as const
32+
2233
/**
2334
* System prompt prefix required by Anthropic to allow OAuth access to Claude 4+ models.
2435
* This must be prepended to the system prompt when using Claude OAuth with Claude 4+ models.
@@ -32,25 +43,47 @@ export const CLAUDE_CODE_SYSTEM_PROMPT_PREFIX = "You are Claude Code, Anthropic'
3243
* while Anthropic uses versioned IDs like "claude-3-5-haiku-20241022".
3344
*/
3445
export const OPENROUTER_TO_ANTHROPIC_MODEL_MAP: Record<string, string> = {
35-
// Claude 3.x models
46+
// Claude 3.x Haiku models
3647
'anthropic/claude-3.5-haiku-20241022': 'claude-3-5-haiku-20241022',
3748
'anthropic/claude-3.5-haiku': 'claude-3-5-haiku-20241022',
3849
'anthropic/claude-3-5-haiku': 'claude-3-5-haiku-20241022',
50+
'anthropic/claude-3-5-haiku-20241022': 'claude-3-5-haiku-20241022',
3951
'anthropic/claude-3-haiku': 'claude-3-haiku-20240307',
40-
'anthropic/claude-3-opus': 'claude-3-opus-20240229',
4152
'claude-3.5-haiku': 'claude-3-5-haiku-20241022',
4253
'claude-3-5-haiku': 'claude-3-5-haiku-20241022',
4354
'claude-3-haiku': 'claude-3-haiku-20240307',
55+
56+
// Claude 3.x Sonnet models
57+
'anthropic/claude-3.5-sonnet': 'claude-3-5-sonnet-20241022',
58+
'anthropic/claude-3-5-sonnet': 'claude-3-5-sonnet-20241022',
59+
'anthropic/claude-3-5-sonnet-20241022': 'claude-3-5-sonnet-20241022',
60+
'anthropic/claude-3-5-sonnet-20240620': 'claude-3-5-sonnet-20240620',
61+
'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',
65+
66+
// Claude 3.x Opus models
67+
'anthropic/claude-3-opus': 'claude-3-opus-20240229',
68+
'anthropic/claude-3-opus-20240229': 'claude-3-opus-20240229',
4469
'claude-3-opus': 'claude-3-opus-20240229',
4570

46-
// Claude 4.x models
71+
// Claude 4.x Haiku models
72+
'anthropic/claude-haiku-4.5': 'claude-haiku-4-5-20251001',
73+
'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',
76+
77+
// Claude 4.x Sonnet models
4778
'anthropic/claude-sonnet-4.5': 'claude-sonnet-4-5-20250929',
4879
'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',
82+
83+
// Claude 4.x Opus models
4984
'anthropic/claude-opus-4.5': 'claude-opus-4-5-20251101',
5085
'anthropic/claude-opus-4.1': 'claude-opus-4-1-20250805',
5186
'anthropic/claude-opus-4': 'claude-opus-4-1-20250805',
52-
'claude-sonnet-4.5': 'claude-sonnet-4-5-20250929',
53-
'claude-sonnet-4': 'claude-sonnet-4-20250514',
5487
'claude-opus-4.5': 'claude-opus-4-5-20251101',
5588
'claude-opus-4.1': 'claude-opus-4-1-20250805',
5689
'claude-opus-4': 'claude-opus-4-1-20250805',

sdk/src/impl/llm.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import path from 'path'
2-
31
import { getByokOpenrouterApiKeyFromEnv } from '../env'
42
import { BYOK_OPENROUTER_HEADER } from '@codebuff/common/constants/byok'
53
import { models, PROFIT_MARGIN } from '@codebuff/common/old-constants'

sdk/src/impl/model-provider.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { createAnthropic } from '@ai-sdk/anthropic'
1212
import { BYOK_OPENROUTER_HEADER } from '@codebuff/common/constants/byok'
1313
import {
1414
CLAUDE_CODE_SYSTEM_PROMPT_PREFIX,
15+
CLAUDE_OAUTH_BETA_HEADERS,
1516
isClaudeModel,
1617
toAnthropicModelId,
1718
} from '@codebuff/common/constants/claude-oauth'
@@ -121,13 +122,7 @@ function createAnthropicOAuthModel(
121122
.map((b) => b.trim())
122123
.filter(Boolean)
123124
const mergedBetas = [
124-
...new Set([
125-
'oauth-2025-04-20',
126-
'claude-code-20250219',
127-
'interleaved-thinking-2025-05-14',
128-
'fine-grained-tool-streaming-2025-05-14',
129-
...betaList,
130-
]),
125+
...new Set([...CLAUDE_OAUTH_BETA_HEADERS, ...betaList]),
131126
].join(',')
132127
headers.set('anthropic-beta', mergedBetas)
133128

0 commit comments

Comments
 (0)