Introducing the New Anthropic Token Counting API | by Thomas Reid | Nov, 2024

Maintain a better eye in your prices when utilizing Claude

Anthropic has launched some thrilling beta options within the final couple of days which have largely gone underneath the radar. Considered one of these was the flexibility to course of PDFs with their fashions, which may now perceive each textual content and visible content material inside PDF paperwork. I’ll possibly write up one thing on that at a later date.

The opposite thrilling beta characteristic, and the topic of this text, was the introduction of token counting. Crucially, you’ll be able to depend the tokens in person messages, PDFs and pictures earlier than you ship them to Claude. This is good news for many who like to observe their token utilization prices intently.

In line with the official announcement from Anthropic (hyperlink right here),

“The token counting endpoint accepts the identical structured checklist of inputs for making a message, together with help for system prompts, instruments, photos, and PDFs. The response incorporates the whole variety of enter tokens.”

And helps the next fashions,

“Claude 3.5 Sonnet
Claude 3.5 Haiku
Claude 3 Haiku
Claude 3 Opus”