Basics 6 min read

What are tokens and how to calculate the cost of a request

What AI tokens are, what counts as input and output tokens, where to see their number, and how to work out the cost of one request and of a month of usage.

What are tokens and how to calculate the cost of a request

Neural networks count neither words nor characters, but tokens. Tokens measure the length of a request and a response, the size of a model's context window, and the cost. This article explains what a token is, what counts as input and output tokens, and how to use a model's rates to calculate the cost of a single request and of a month of work.

A token as a unit of text

Before processing, the model splits text into tokens: short fragments from the model's vocabulary. A common word may be one token, while a long or rare word is split into several parts. Spaces, punctuation, line breaks and digits also become tokens.

Both the request and the response are represented as tokens. That is why the context limit, the maximum response length and the price are all measured in them.

Why different models have different token counts

Each model family has its own token vocabulary. The same text can be split into a different number of pieces by GPT, Gemini and DeepSeek, and the ratio also depends on the language of the text. So comparing models only by the rate per million tokens is not quite accurate: on the same text, one model may count more tokens than another.

The exact number of tokens for a specific request is returned by the model in the response.

What counts as input tokens

Input tokens are everything you send to the model in a request:

  • the system message with the role and instructions;
  • the conversation history: all earlier questions and answers that you pass along so the model remembers the conversation;
  • the user's question itself;
  • function descriptions, if you pass them in tools, and the results of calling them;
  • images in the input, for models that accept them;
  • found pages, if the model searches the web: in the Responses API for GPT models, they also count as input tokens.

The model doesn't remember previous requests, so the conversation history is sent again with every request. The longer the conversation, the more input tokens each following question carries.

What counts as output tokens

Output tokens are everything the model generates: the text of the answer, function calls with arguments, and reasoning. Reasoning models can generate intermediate tokens that are billed as output even though they aren't visible in the text of the answer. The depth of reasoning is set by the effort level parameter: a low level shortens the output.

You can limit the response length with the max_tokens parameter in Chat Completions or max_output_tokens in the Responses API.

Where to see the number of tokens

Every response has a usage field. In the Chat Completions format it looks like this:

json
"usage": {"prompt_tokens": 24, "completion_tokens": 3, "total_tokens": 27}

prompt_tokens is input, completion_tokens is output, and total_tokens is the sum. In the Responses API the same numbers are called input_tokens and output_tokens. For a streamed response in Chat Completions, add "stream_options": {"include_usage": true}, and usage will arrive as the last chunk of the stream.

In the llmbox cabinet, every request is visible in the Logs section: model, input and output tokens, status and cost. Usage by day and by model is collected in the Usage section.

The cost formula

Rates for text models are given per 1 million tokens, separately for input and output. The cost of one request is calculated like this:

text
cost = input tokens / 1,000,000 × input rate
     + output tokens / 1,000,000 × output rate

If part of the input was served from the cache, it is counted at the cache read rate, and writing to the cache has its own rate. All of a model's rates are on its page in the catalog, and how payment works is described in the Balance and pricing documentation page.

Example: a support bot for a month

Take a support bot with these average figures:

  • 500 messages a day;
  • 1,200 input tokens per request: the system message, the latest messages of the conversation and the question;
  • 300 output tokens per response.

Over 30 days the bot handles 500 × 30 = 15,000 requests. Input comes to 15,000 × 1,200 = 18 million tokens, and output to 15,000 × 300 = 4.5 million. The cost for the month:

text
cost = 18 × input rate + 4.5 × output rate

Rates are given per million tokens, so the volume in millions has to be multiplied by the matching rate. The calculator below does the math at the current rates of the selected model: plug in your own values.

Per month on DeepSeek V4.1 Flash ≈ $3.02 18M in · 4.5M out

Rates of a few popular models for comparison:

Current rates for other models are collected in the article How much 1M tokens costs and in the text model catalog.

What increases usage

  • Long history. Every message of the conversation is passed to the model again and counted in input tokens. Limit the history to the latest messages, or replace the older part with a short summary.
  • A large system prompt. It is repeated in every request. Keep it unchanged at the start of the request, so it hits the cache more often.
  • Reasoning. A high effort level on simple questions can spend output tokens unnecessarily.
  • Agents with functions. Each agent step is a separate request with the history, function descriptions and call results.
  • Long answers. Ask the model to answer briefly and set a max_tokens limit.

How to reduce the cost

Start with the smallest suitable model and move up to a larger one only where the quality of the result falls short. For simple steps such as classification, field extraction and short answers, lower the reasoning level. Check usage on real requests. After a few days of operation, take the averages from the Logs section: they will be more accurate than an advance estimate.

Questions

How many tokens are in one word?

It depends on the model and the language: different models split text into tokens differently. A short, common word may be a single token, while a long or rare one may take several. For the exact number of tokens in a request, check the usage field of the response.

Do spaces and punctuation count?

Yes. The model receives the whole text, so spaces, line breaks and punctuation marks are part of the tokens too.

Are reasoning tokens billed?

Yes. Reasoning is part of the output tokens and is billed at the output rate, even if it isn't visible in the text of the answer.

Can I find out the cost of a request before sending it?

The exact number of tokens is returned by the model in the response. In advance, it is handy to estimate from similar requests: their tokens and cost are visible in the Logs section of the cabinet.

Published November 15, 2026

One key — every model

GPT, Gemini, DeepSeek, Qwen, video and audio. Pay as you go.

Create a key