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

# Count Tokens

> Count tokens for a request without sending it to the model.

# Count Tokens

Count the number of input tokens that a request would use without actually sending it to the model. Useful for estimating costs and managing context windows.

## Authentication

Requires JWT token or Platform API key.

Same format as the Messages API, but the request is not executed:

<ParamField body="model" type="string" required>Model to use for tokenization</ParamField>
<ParamField body="messages" type="array" required>Array of message objects</ParamField>

## Example Request

```bash theme={null}
curl -X POST https://api.app.shinzo.ai/spotlight/anthropic/v1/messages/count_tokens \
  -H "Authorization: Bearer <jwt_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [
      {"role": "user", "content": "What is the capital of France?"}
    ]
  }'
```

## Response

```json theme={null}
{
  "input_tokens": 14
}
```

## Caching

Token counts support caching with the following TTLs:

* **Ephemeral 5m**: Cached for 5 minutes
* **Ephemeral 1h**: Cached for 1 hour

## Timeout

Request timeout is 30 seconds.

## Status Codes

| Code  | Description            |
| ----- | ---------------------- |
| `200` | Success                |
| `400` | Invalid request        |
| `401` | Invalid authentication |
| `403` | Provider key not found |
