Java Zero to All All questionsPractise free
Interview questions › Build AI Features as a Java Backend Engineer › Start Here — Build Your First AI Feature

What is a token, and why do engineers care about tokenization when they are just trying to ship a feature?

Level II · JuniorStart Here — Build Your First AI Feature
Short answer

A token is a sub-word unit produced by the model's tokenizer, roughly 3 to 4 characters or about 0.75 words in English, so 1000 tokens is very roughly 750 words.

Explanation

Cost and latency both scale with token count because the model does work proportional to the number of tokens in the input plus the number it generates, and providers bill separately for input and output tokens, with output usually more expensive. Tokenization is also why context windows are measured in tokens, why non-English text and code can be more expensive (they tokenize less efficiently), and why you cannot reliably 'trim to N characters' to fit a budget. Practically you should measure real token counts with the provider's tokenizer rather than guessing, because a prompt that looks small can blow your budget once you stuff in retrieved documents or long histories.

Common mistakes
  • Assuming one token equals one word.
  • Ignoring tokens when estimating cost and limits.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for Start Here — Build Your First AI Feature.

Practise free

More on Start Here — Build Your First AI Feature