POST https://api.ethereal.llc/v1/messages/count_tokens
Returns an estimate of how many input tokens a request would cost — handy for
cost planning before you actually send it. The request body matches the
Anthropic Messages format.
This endpoint is no-auth: it does not require an API key and does not draw
down your balance.
| Header | Value |
|---|
Content-Type | application/json |
Body parameters
Model ID: claude-opus-4-8, claude-sonnet-4-6, or claude-haiku-4-5.
A list of messages. Each is { "role": "user" | "assistant", "content": string }.
An optional system prompt — a string, or an array of text blocks.
Example request
curl https://api.ethereal.llc/v1/messages/count_tokens \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"system": "You are a concise assistant.",
"messages": [
{ "role": "user", "content": "Explain recursion in one sentence." }
]
}'
Response
input_tokens is an estimate, not an exact count — use it for cost
planning. The actual charge is based on the usage field returned by
Messages (Pricing).