Count tokens in a message
Counts the input tokens a Messages request would consume, without calling a model.
Also served at /v1/anthropic/v1/messages/count_tokens; both paths accept the same requests.
Authentication
AuthorizationBearer
Your production key sent as a bearer token.
Request
This endpoint expects an object.
model
messages
system
tools
tool_choice
Tool choice, counted as part of the prompt.
thinking
Extended thinking settings for models that support it.
Response
Successful Response
input_tokens
Errors
422
Unprocessable Entity Error