Keep a closer eye on your costs when using Claude
Anthropic has quietly rolled out some interesting beta features in recent days, but they've mostly flown under the radar. One of these features was the ability to process PDFs with their models, which can now understand both text and visual content within PDF documents. I may cover this in more detail in a future article.
The other beta feature, which is the focus of this article, is the introduction of token counting. Importantly, you can count the tokens in user messages, PDFs, and images before sending them to Claude. This is great news for anyone who wants to keep a close eye on their token usage costs.
As stated in the official announcement from Anthropic (link here),
“The token counting endpoint accepts the same structured list of inputs for creating a message, including support for system prompts, tools, images, and PDFs. The response contains the total number of input tokens.”
And supports the following models,
“Claude 3.5 SonnetClaude 3.5 HaikuClaude 3 HaikuClaude 3 Opus”
The above is the detailed content of Introducing the New Anthropic Token Counting API. For more information, please follow other related articles on the PHP Chinese website!