tokens count
tokens_countCount tokens before you call a model: exact OpenAI counts (o200k for gpt-4o / 4.1 / o-series / gpt-5, cl100k for gpt-4 / 3.5) plus close estimates for Claude, Llama and Gemini, with chat-message overhead. Up to 2 million characters. Costs $0.002 USDC per call (x402).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | ||
| messages | No | Or a chat messages JSON array |