How Many Tokens Is My Prompt? Context Windows and AI API Costs
Learn what tokens are, how a context window fills up and how to estimate AI API cost per call, per day and per month before you build.

How Many Tokens Is My Prompt? Context Windows and AI API Costs
Every bill from an AI provider, every "context length exceeded" error and every slow reply comes back to the same unit: the token. If you build anything on top of a language model, or simply paste long documents into a chat assistant, knowing roughly how many tokens you are using saves money and frustration. The token and API cost calculator does the arithmetic; this guide explains what sits behind it.
What a token is
Models do not read whole words. A tokenizer breaks text into frequent fragments: common words become a single token, rarer words split into two or three pieces, and spaces and punctuation are folded in. In English the averages are steady enough to plan with: around four characters, or three quarters of a word, per token. A 750-word article is therefore close to 1,000 tokens.
Code behaves differently. Brackets, operators, indentation and variable names cut text into smaller fragments, so programs average nearer three characters per token. Many non-Latin scripts use roughly a token per character. That is why the calculator asks what kind of text you are pasting.
The context window is shared
A model's context window is the total number of tokens it can look at in one request. People often think only of their question, but the window also holds:
- the system prompt or instructions;
- retrieved passages or attached files;
- every earlier message the application resends;
- the answer the model is about to write.
A chatbot that resends the whole conversation each time grows heavier with every turn. Ten exchanges of 350 tokens add 3,500 tokens to each new call, and you pay for them again each time.
Working out the cost
Providers price input and output separately, usually per million tokens. The formula is simple:
cost = input tokens ÷ 1,000,000 × input price + output tokens ÷ 1,000,000 × output price
Suppose a request carries 7,439 input tokens and returns 800. At 3 per million for input and 15 per million for output, that is about 0.0223 + 0.0120 = 0.034 per call. It sounds tiny, yet 500 calls a day reach roughly 17 a day and over 500 a month. The table in the tool scales the figure from one call to ten thousand so you can see where a feature becomes expensive.
Five ways to spend less
- Trim the input. Send the paragraphs that matter, not the whole manual.
- Summarise history. Replace old turns with a short running summary.
- Cap the answer. Set a maximum output length that fits the task.
- Reuse prompts. Several providers discount repeated prompt prefixes through caching.
- Pick the right model. Smaller models handle classification and extraction well at a fraction of the price.
Staying inside the window
When a request nears the limit, quality can drop before the hard error appears, because the model has to spread attention across a huge input. The calculator warns at 80% usage. If you regularly go past that, split documents into sections, use retrieval to fetch only relevant chunks, or move to a model with a larger window.
Estimates versus exact counts
Rules of thumb are close enough for budgets and design decisions, but they are not exact. Each model family has its own tokenizer, and numbers, URLs and unusual words can tokenise heavily. Before setting hard limits in code, check a few real samples with your provider's own counting endpoint.
Prices change
AI prices fall quickly and differ between providers, regions and batch or real-time modes. Enter the current figures from your provider's price page rather than relying on numbers from an old article. Treat the result as a planning estimate, not a quote or financial advice.


&c=%23c2410c&k=education)
