Back to feed
Dev.to
Dev.to
6/23/2026
How LLM Tokens Work (And Why They Explain Your AI Bill)

How LLM Tokens Work (And Why They Explain Your AI Bill)

Short summary

Large language models process text as tokens (roughly three-quarters of a word each), not words—this design choice explains both their capabilities and your surprise AI bills. You pay per token in both directions: input includes your prompt, conversation history, and tools; output is priced higher. Understanding tokenization is critical for anyone building or budgeting for LLM applications.

  • Tokens are fixed-dictionary chunks (words, subwords, punctuation), not individual characters or words
  • APIs price both input tokens (cheaper) and output tokens (3–5× more expensive), so costs compound with context size and history
  • Cost = (input tokens × input rate) + (output tokens × output rate); managing token count is the key to controlling spending

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Explore more