How tokens are counted
Learn how input and output tokens are counted and billed, how the cached-prompt discount works and how to estimate a request's cost before you send it.
Tokens are how Claude (and every other LLM) meters work. Roughly 4 characters of English text — and roughly what you pay for.
All models, capabilities, and prices Documentation index for AI agents:https://oneprovider.dev/docs/llms.txt Rule of thumb
- 1 token ≈ 4 English characters ≈ 0.75 words.
- A page of prose (~500 words) is ~670 tokens.
- Source code, non-Latin scripts, and emoji tokenize denser — expect 1.2–2× the English rate.
- A 200k-token context window is roughly 150k English words — around 300 pages.
Four kinds of tokens on your bill
| Kind | What it is | How it’s billed |
|---|---|---|
| Input | Every token the model reads: system prompt, prior turns, current user message, tools schema, images. | Full input rate. |
| Output | Every token the model writes: response text, tool calls, thinking (if enabled). | Full output rate (typically 5× input). |
| Cache read | Input tokens served from a prior request’s cache breakpoint. | 10% of the input rate for most models; exact rates per model are in the models table . |
| Cache write | The first request at a cache breakpoint — establishes the cache for later reads. | 125% of the input rate for most models; exact rates per model are in the models table . |
Every response carries these counts in the usage field — see Usage & billing .
Estimating before you send
The Anthropic SDKs expose a count-tokens helper you can run locally:
pythonfrom anthropic import Anthropic
client = Anthropic(base_url="https://api.oneprovider.dev")
count = client.messages.count_tokens(
model="claude-sonnet-5-5",
messages=[{"role": "user", "content": "Your long prompt here"}],
)
print(count.input_tokens) The count is a lower bound — it doesn’t include the output the model is about to write. For budgeting, add a max_tokens ceiling and assume the worst case.
How to estimate cache savings
There is no universal multiplier across models. For the current balanced model claude-sonnet-5-5 or any other model, use its separate Cache read and Cache write values from the generated rates table . Compare them with the selected model's input rate and expected number of repeated reads.
Quick answers
Which base URL do I use?
Claude Code and Anthropic SDKs use https://api.oneprovider.dev. OpenAI SDKs and OpenAI-compatible clients use https://api.oneprovider.dev/v1. One key works behind both; the model list is on the models page ; rates are on the pricing page .
How do I authenticate?
Send the raw sk-… key in x-api-key or Authorization: Bearer: one of them, never both. Keep the key in an environment variable, not in a file that gets committed. More on authentication .
Where do I get a key?
Open your cabinet in the Telegram bot @oneprovider_robot or at app.oneprovider.dev, top up the balance and press “Issue a key”. Each key can carry its own spend limit. Cabinet & API keys .
What do 401, 404 and 429 mean?
401: the key is missing, mistyped or sent in the wrong header; paste the whole key without quotes or spaces. 404: usually a wrong base URL, for example a missing or doubled /v1. 429 with “Insufficient balance”: the cabinet balance or the key’s spend limit is used up, so top up instead of retrying; any other 429 is a rate limit, so wait for Retry-After. Details: error codes and troubleshooting .
Why do streams cut off or reset?
VPN and VLESS proxies often buffer SSE or break HTTP/2 negotiation. OneProvider has no regional restrictions and does not buffer streams, so turn the proxy off and retry.
Where do I ask if this is not enough?
Message @Oneproviderhelpbot on Telegram or open “Support” in the web cabinet, with the HTTP status code and the exact error message. How support works .
Last updated: 2026-10-05 Found a bug? @Oneproviderhelpbot