Count Tokens
Spotlight
Count Tokens
Count tokens for a request without sending it to the model.
POST
Count Tokens
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:Model to use for tokenization
Array of message objects
Example Request
Response
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 |

