> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voidai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Count Message Input Tokens

> Count input tokens for an Anthropic-format VoidAI request, including estimation behavior and access requirements.

`POST https://api.voidai.app/v1/messages/count_tokens`

Requires [authentication](/authentication). Send `model` and `messages`; optional context includes `system`, `tools`, `tool_choice`, and `thinking`. A `max_tokens` output limit is not required for this operation. A successful count does not establish that your account can run inference with the model.

```bash theme={null}
curl https://api.voidai.app/v1/messages/count_tokens \
  -H "x-api-key: $VOIDAI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"Hello"}]}'
```

The response contains `input_tokens`, a number. This endpoint is not billed. A native provider count is used when available; availability failures can fall back to a local estimate. Invalid provider request shapes can still return an error. Treat the result as an estimate when planning a later generation, not a guarantee of its final charge.

See [Messages](/api-reference/messages/create) for access and usage checks, and [billing](/guides/credits) for cache accounting.
