Skip to content

Commit bc26317

Browse files
authored
Merge pull request #186 from richkirsch/patch-1
Allow latest Claude models for token counting
2 parents 558ac48 + 781ecd3 commit bc26317

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tokencost/costs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ def get_anthropic_token_count(messages: List[Dict[str, str]], model: str) -> int
4545
if not any(
4646
supported_model in model
4747
for supported_model in [
48+
"claude-opus-4",
49+
"claude-sonnet-4",
4850
"claude-3-7-sonnet",
4951
"claude-3-5-sonnet",
5052
"claude-3-5-haiku",
5153
"claude-3-haiku",
5254
"claude-3-opus",
5355
]
54-
):
56+
): # As per https://docs.anthropic.com/en/docs/build-with-claude/token-counting#supported-models
5557
raise ValueError(
5658
f"{model} is not supported in token counting (beta) API. Use the `usage` property in the response for exact counts."
5759
)

0 commit comments

Comments
 (0)