Skip to main content
POST
Count message tokens (Anthropic)

Body

application/json
model
string
required

A Grid model id from GET /v1/models, never a Claude model id.

Example:

"qwen-2.5-32b"

messages
object[]
required

Conversation turns, user and assistant. Must not end with an assistant message (no prefill). A mid-conversation system message is folded into the user turn it follows.

Example:
system

System prompt, as a string or text blocks.

tools
object[]

Your own tools with an input_schema. Server tools and Anthropic-defined tools are refused.

tool_choice
object

{type: auto | any | tool | none}. disable_parallel_tool_use: true is refused.

Response

Token estimate.

input_tokens
integer
Example:

4