Skip to main content
POST
Count tokens for an Anthropic message

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Same shape as a create-message request; max_tokens is optional and ignored for counting.

model
string
required
messages
object[]
required
Minimum array length: 1
max_tokens
integer

Optional here; validated if present, not used for counting.

Required range: x >= 1
system

System prompt: a string, or an array of text blocks.

temperature
number
Required range: 0 <= x <= 1
top_p
number
Required range: 0 <= x <= 1
output_config
object
routing
object
tools
object[]

Tool definitions the model may call. Responses include tool_use blocks; return outcomes as tool_result content blocks in a follow-up message.

tool_choice
object

Controls tool use: auto, any, tool, or none.

thinking
object

Extended thinking configuration; translated to the model's reasoning.

metadata
object

Optional string metadata. completion_window controls scheduling; completion_webhook/webhook_token configure completion webhooks.

context_management
object

Anthropic server-side context-editing config (Claude Code sends it automatically). Accepted for compatibility but ignored — Sail forwards the full context each turn.

Response

Input token count.

input_tokens
integer
required