# Tokenization

Source: [Tokenization](<https://docs.gptunnel.ru/en/getting-started/tokenizer/>)

<a id="_top"></a>
Use the selected model’s tokenizer to estimate a request before sending it. Messages, conversation history, and tool definitions all contribute to the estimate. The API response reports actual usage.

Send your [first request](<https://docs.gptunnel.ru/en/#send-your-first-request>) to `gpt-6-luna`. For the prompt “What is 2 + 2? Answer with a digit,” one Chat Completions response included the following:

```json
{
  "model": "gpt-6-luna",
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 4,
    "total_tokens": 24,
    "total_cost": 0.0008
  }
}
```

`prompt_tokens` counts input tokens and `completion_tokens` counts output tokens. In this example, `total_tokens` is their sum, and `total_cost` is the cost in rubles. Usage may vary on subsequent calls.

The format of `usage` depends on the method. For a [streaming response](<https://docs.gptunnel.ru/en/api/chat-completions/streaming/>), keep the last usage data received before `[DONE]`. For [embeddings](<https://docs.gptunnel.ru/en/embedding/text-embedding-3-small/>), read the fields documented for that endpoint. In [assistant chat](<https://docs.gptunnel.ru/en/api/assistants/chat/>), usage may also include knowledge base search.
