Anthropic Token Counting API
Count the number of tokens in a Message, including tools, images, and documents, without creating it. The Token Count API accepts the same structured list of inputs for creating a message, including support for system prompts, tools, images, and PDFs. Token counting is free to use but subject to requests per minute rate limits.