Key points
- English text averages roughly four characters or three quarters of a word per token.
- Input and output are priced separately: $0.15 and $0.50 per 1M tokens here.
- In a chat, you resend the history every turn, so input tokens grow faster than you expect.
- The usage field in each response is the exact count, so log it instead of guessing.
What a token actually is
A language model does not read letters or words. It reads integers. Before your text reaches the model, a tokenizer cuts it into pieces from a fixed vocabulary and replaces each piece with its ID number. Those pieces are tokens. Common words like "the" or "house" are usually one token. Longer or rarer words split into several: "unbelievably" might become "un", "believ", "ably". Spaces, punctuation and line breaks count too, and a leading space is often glued to the word that follows it.
The answer to how do llm tokens work in practice is a simple pipeline. Text goes in, the tokenizer turns it into IDs, the model predicts one new ID at a time, and the tokenizer turns those IDs back into text. Every ID the model produces is one output token. Every ID in your prompt is one input token. Nothing else is metered.
The exact split depends on the tokenizer the model was trained with, so two models can count the same sentence differently. That is why a count from one tool is only an estimate for another model. For billing, the number that matters is the one the API reports back in the response.
Rules of thumb for estimating size
For ordinary English prose, these rough conversions hold up well enough for budgeting:
- 1 token is about 4 characters.
- 1 token is about three quarters of a word, so 100 tokens is about 75 words.
- 1,000 words is about 1,300 to 1,400 tokens.
- A typical single-spaced page is around 500 to 700 tokens.
Other content breaks the rule. Source code, JSON and URLs have many symbols, so they run closer to 2 to 3 characters per token. Text in languages that do not use the Latin alphabet often needs more tokens per word than English, sometimes by a wide margin. Numbers split into short groups of digits. If your app is mostly non-English or code-heavy, test a sample and measure instead of using the English figure.
Emoji, unusual symbols and long runs of repeated characters can also cost more than they look. When in doubt, send a real sample and read the usage numbers back.
Input tokens, output tokens and the context window
Every request has two sides. The prompt (system message, history, your new message, tool definitions) is the input. What the model writes back is the output. Both fit inside the context window, which here is 100,000 tokens for prompt plus completion together. If your prompt uses 90,000 tokens, the reply can use at most about 10,000.
The max_tokens parameter is optional. If you leave it out, the completion can use whatever room remains in the window. Set it when you want a hard ceiling on cost or length, for example 300 for a short chat reply.
Pricing treats the two sides differently:
| Token type | Price per 1M tokens | Price per 1,000 tokens |
|---|---|---|
| Input (prompt) | $0.15 | $0.00015 |
| Output (completion) | $0.50 | $0.0005 |
Output costs about 3.3 times as much as input per token. That is normal for LLM APIs, because generating a token takes more compute than reading one. The practical consequence is that a long reply is the expensive part of a short chat turn, while a long history is the expensive part of a long chat.
Worked example 1: a single chat turn
Say a request has a 500-token system prompt, 700 tokens of history and a 100-token user message. That is 1,300 input tokens. The model replies with 300 tokens.
- Input: 1,300 / 1,000,000 x $0.15 = $0.000195
- Output: 300 / 1,000,000 x $0.50 = $0.00015
- Total: $0.000345
That is a bit over a hundredth of a cent. At this size, $20 of credit covers roughly 58,000 turns ($20 / $0.000345 is about 57,970). The $0.50 trial credit covers about 1,450 of them ($0.50 / $0.000345 is about 1,449). Trial credit lasts 7 days and needs no payment details, so it is enough for a real test of your prompt design.
Worked example 2: a long conversation that resends history
The model has no memory between requests. Your app sends the whole conversation each turn. This is where bills surprise people, so it is worth doing the sum once.
Assume a 1,000-token system prompt, user messages of 100 tokens and replies of 300 tokens, so each completed turn adds 400 tokens of history. Over 30 turns:
- Input at turn n = 1,000 + 400 x (n - 1) + 100 tokens.
- Sum of input over 30 turns = 30 x 1,100 + 400 x (0 + 1 + ... + 29) = 33,000 + 400 x 435 = 207,000 tokens.
- Output over 30 turns = 30 x 300 = 9,000 tokens.
Cost: 207,000 / 1,000,000 x $0.15 = $0.03105 for input, and 9,000 / 1,000,000 x $0.50 = $0.0045 for output. The session total is $0.03555, about 3.6 cents.
Notice what happened. The model wrote only 9,000 tokens, yet it read 207,000. Input tokens made up 23 times the volume of output, and about 87 percent of the bill. Doubling the length of the chat does not double the cost; it roughly quadruples the input side, because each new turn re-reads everything before it. Trimming old turns or summarizing them is the main cost lever for chat apps.
Worked example 3: a big document
Suppose you paste a 60,000-token document and ask for a 1,500-token summary. Input: 60,000 / 1,000,000 x $0.15 = $0.009. Output: 1,500 / 1,000,000 x $0.50 = $0.00075. Total: $0.00975, under one cent. Filling the whole window with a 98,000-token prompt and getting a 2,000-token answer costs $0.0147 + $0.001 = $0.0157.
Long context is cheap per request. Repeating it hundreds of times is where it adds up, so cache results on your side when the same document gets asked about repeatedly.
Reading real counts from the API
Do not guess when exact numbers are one field away. Every non-streamed response includes a usage object, and streamed responses send usage at the end. Here is a minimal cost logger with the OpenAI Python SDK.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.nsfwchat.top/v1", api_key=os.environ["NSFWCHAT_API_KEY"])
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Describe a storm at sea in three sentences."}],
max_tokens=200,
)
u = resp.usage
cost = u.prompt_tokens * 0.15 / 1_000_000 + u.completion_tokens * 0.50 / 1_000_000
print(u.prompt_tokens, u.completion_tokens, f"${cost:.6f}")
Responses also carry an X-Balance-USD header with your remaining credit. Failed or refused requests are not charged, so retries after an error do not double-bill you. Credit never expires and there is no subscription.
curl -s https://api.nsfwchat.top/v1/chat/completions -H "Authorization: Bearer $NSFWCHAT_API_KEY" -H "Content-Type: application/json" -d '{"model":"uncensored","messages":[{"role":"user","content":"Say hi"}],"max_tokens":10}'
The JSON that comes back includes the same usage block. For the full request format see the quickstart docs.
Ways to spend fewer tokens
- Trim history. Keep the system prompt and the last handful of turns. Summarize the middle in one short message.
- Shorten the system prompt. It is paid for on every call. Cutting 400 tokens saves 400 x $0.15 / 1,000,000 = $0.00006 per request, which is $6 per 100,000 requests.
- Cap output. Set
max_tokensto the length you need. Output is the pricier side. - Ask for brevity in the prompt. "Reply in under 120 words" works better than hoping.
- Skip pretty-printed JSON in tool results. Whitespace costs tokens.
Larger top-ups also earn a bonus: +5% from $50, +10% from $100 and +15% from $200, so a $100 top-up gives $110 of credit. See the pricing page for amounts and payment options. If you build a roleplay or companion app where chat history is the main cost, the NSFW LLM API guide covers how that kind of app is usually structured, and you can begin testing with the trial credit from the API key page.
