Skip to content

fix: resolve 160 Anthropic throws unknown model for some models due to missing max tokens clause #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-tomatoes-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'token.js': patch
---

Fix: resolve error where new anthropic models do not work due to hardcoded max token limit
11 changes: 10 additions & 1 deletion src/handlers/anthropic.ts
Original file line number Diff line number Diff line change
@@ -344,8 +344,17 @@ export const getDefaultMaxTokens = (model: string): number => {
model === 'claude-instant-1.2'
) {
return 4096
} else if (
model === 'claude-3-5-sonnet-latest' ||
model === 'claude-3-5-sonnet-20241022' ||
model === 'claude-3-7-sonnet-latest' ||
model === 'claude-3-7-sonnet-20250219' ||
model === 'claude-3-5-haiku-20241022'
) {
return 8192
} else {
throw new InputError(`Unknown model: ${model}`)
// We default to 8192 when the model is not specifically handled here to avoid throwing errors
return 8192
}
}