Skip to content

Commit 6d8de05

Browse files
authored
Merge pull request #174 from token-js/pate/160
fix: resolve 160 Anthropic throws unknown model for some models due to missing max tokens clause
2 parents 783d2f0 + 2fc6edd commit 6d8de05

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changeset/old-tomatoes-pump.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'token.js': patch
3+
---
4+
5+
Fix: resolve error where new anthropic models do not work due to hardcoded max token limit

src/handlers/anthropic.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,17 @@ export const getDefaultMaxTokens = (model: string): number => {
344344
model === 'claude-instant-1.2'
345345
) {
346346
return 4096
347+
} else if (
348+
model === 'claude-3-5-sonnet-latest' ||
349+
model === 'claude-3-5-sonnet-20241022' ||
350+
model === 'claude-3-7-sonnet-latest' ||
351+
model === 'claude-3-7-sonnet-20250219' ||
352+
model === 'claude-3-5-haiku-20241022'
353+
) {
354+
return 8192
347355
} else {
348-
throw new InputError(`Unknown model: ${model}`)
356+
// We default to 8192 when the model is not specifically handled here to avoid throwing errors
357+
return 8192
349358
}
350359
}
351360

0 commit comments

Comments
 (0)