What Are LLM Tokens? How Counting Drives API Cost
A direct answer to what is llm tokens: a token is a small chunk of text, often a short word or part of one, and it is the unit in which a language model reads input, writes output and bills you.
Updated

Tokens in plain terms
Language models do not read letters or whole words. Before a model sees your text, a tokenizer splits it into pieces called tokens. Each piece maps to a number the model understands, and the model produces its answer the same way, one token at a time, which a decoder turns back into text.
The split depends on the tokenizer. Common short words are often a single token. Longer or rarer words break into several pieces. Punctuation, spaces and digits count too. A rough English rule says that one token is about four characters, or about three quarters of a word, so 1,000 words come to roughly 1,300 tokens. Treat that as a rule of thumb, since every tokenizer is a little different.
The reason this matters to you as a developer is that tokens are the thing being measured at every step. The context window is measured in tokens. The speed of a response is in tokens per second. The bill is in tokens. If you learn to think in them, API behaviour and pricing stop looking arbitrary.
How text breaks into tokens
A few patterns help you build intuition. These are illustrative splits, and a real tokenizer may cut differently.
| Text | Typical behaviour |
|---|---|
| A common word such as house | Often one token |
| A long word such as internationalization | Several tokens |
| A number such as 2026 | One or a few tokens, depending on the tokenizer |
| Code with symbols and indentation | More tokens per line than prose |
| Text in many non-English languages | Often more tokens per word than English |
The last row surprises people. A paragraph in a language with a script the tokenizer handles less efficiently can cost noticeably more tokens than the same meaning in English, so the same page of text produces a different bill. JSON and code behave in a similar way: every brace, quote and space is part of the count.
It also explains why two prompts that look the same length to a person can differ in cost. A table of numbers, a block of minified code and a page of simple prose all behave differently, because the tokenizer finds more or fewer familiar patterns to merge. When you estimate a bill for a new kind of content, run a few samples through the API first and use the averages.
Do not try to predict the exact figure by hand. Send the request and read the number the API reports, which is the one that counts.
Input tokens, output tokens and the window
Each request has two sides. Input tokens are everything you send: the system prompt, the conversation history, any documents you paste in, and the new question. Output tokens are what the model writes back. The API reports both in the usage field:
from openai import OpenAI
client = OpenAI(base_url="https://api.hermesllmapi.com/v1", api_key="YOUR_API_KEY")
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Explain tokens in two sentences."}],
)
print(r.usage.prompt_tokens) # input tokens
print(r.usage.completion_tokens) # output tokens
print(r.usage.total_tokens) # the sum
The two sides share a budget called the context window. On this service it is 100,000 tokens for prompt plus completion together. If you send 90,000 tokens, at most 10,000 are left for the answer. Using max_tokens is optional, since the completion can use whatever remains of the window. Setting it still helps when you want a hard cap on length or cost.
As a size reference, 100,000 tokens is roughly 75,000 English words, the length of a short novel. That is a lot of room, but it is not unlimited. Long documents, a growing chat history and a verbose system prompt all draw from the same pool.
From tokens to dollars
The price here is $0.15 per 1M input tokens and $0.50 per 1M output tokens. Output tokens cost about 3.3 times as much as input tokens (0.50 divided by 0.15), because writing is more work for the model than reading. The scale of these numbers is easier to feel with a short list:
- 1,000,000 input tokens cost $0.15.
- 100,000 input tokens cost $0.015, about a cent and a half.
- 10,000 input tokens cost $0.0015.
- 1,000,000 output tokens cost $0.50.
- 100,000 output tokens cost $0.05.
The formula for any request is input tokens x $0.15 / 1,000,000 plus output tokens x $0.50 / 1,000,000. Take a request with 1,200 input tokens and 800 output tokens. Input is 1,200 x 0.15 / 1,000,000 = $0.00018. Output is 800 x 0.50 / 1,000,000 = $0.0004. The request costs $0.00058, so 1,000 such requests cost $0.58.
There is no monthly plan. You pay from prepaid credit, credit never expires, and failed or refused requests are not charged. The pricing page lists the top-up sizes, which go from $20 to $500, with bonuses of 5%, 10% and 15% from $50, $100 and $200. New users can try the API on $0.50 of trial credit, claimed from the API key page.
Why chat history costs more than you expect
Because the API is stateless, a chat application resends the earlier conversation with each new message. That means input tokens grow with every turn, even if each message is short. Here is a worked example with a 500 token system prompt, and each turn adding 100 tokens from the user and 200 from the model.
On turn 1 the input is 500 + 100 = 600 tokens. Each later turn adds the previous 300 tokens of exchange, so turn n sends 600 + 300 x (n - 1). Over 10 turns the inputs are 600, 900, 1,200 and so on up to 3,300. Their sum is 10 x 600 + 300 x 45 = 6,000 + 13,500 = 19,500 input tokens. The outputs total 10 x 200 = 2,000 tokens.
The cost is 19,500 x $0.15 / 1,000,000 = $0.002925 for input plus 2,000 x $0.50 / 1,000,000 = $0.001 for output, which comes to $0.003925, about 0.4 cents for ten turns. The model only wrote 2,000 tokens, but you paid for 19,500 tokens of reading. Doubling the chat length to 20 turns does more than double the input, because each turn carries more history than the one before.
The same logic applies to long documents: if you ask five questions about a 30,000 token file and resend it each time, you pay for 150,000 input tokens, which is $0.0225, not $0.0045. Keep the document in the prompt only as long as you need it.
Practical ways to spend fewer tokens
None of these require exotic tricks. They are habits that cut input and output without hurting quality.
- Trim the system prompt. It is sent with every call, so a 2,000 token prompt over 10,000 calls is 20 million input tokens, or $3.00.
- Summarise old turns. Replace the first part of a long chat with a short summary and keep the last few turns verbatim.
- Cap the answer. Use
max_tokensor ask for a length in the prompt when a short answer is enough. - Send only the relevant passage. Retrieve the paragraph you need instead of the whole file.
- Use stop sequences. The
stopparameter ends generation at a marker, so the model does not keep writing past the part you wanted. - Measure. Log
usagefrom real calls, since your own averages beat any estimate.
The documentation covers all of these request options. Prompts sent to the service are not used for training, and the response headers include X-Balance-USD so you can watch your remaining credit while you tune things.
Finally, keep the limits of this service in mind. It handles text only, so there is nothing to count for images or audio, and it has no embeddings endpoint. Counting is simply input tokens plus output tokens, at the two prices above.
More guides
Questions and answers
How many tokens is 1,000 words?
Roughly 1,300 tokens in English, based on the rule of about three quarters of a word per token. The exact figure depends on the tokenizer and the text, so check the usage field.
Are input and output tokens priced the same?
No. Here input costs $0.15 per 1M tokens and output costs $0.50 per 1M tokens.
What is the maximum number of tokens per request?
The context window is 100,000 tokens, and it covers the prompt and the completion together.
Do I pay for failed requests?
No. Failed or refused requests are not charged.
How can I see how many tokens I used?
Every response includes a usage object with prompt_tokens and completion_tokens, and the X-Balance-USD header shows your remaining credit.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.