beginnerFoundations of Generative AI & LLMs

What does 'token' mean in the context of an LLM, and why does it matter for cost and context limits?

A token is a chunk of text (roughly 3-4 characters in English, not always a whole word) that the model reads and generates one at a time. Providers bill per token and every model has a maximum context window measured in tokens, so a long conversation history or a huge retrieved document can silently hit that ceiling or blow up your bill well before you run out of 'words'.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why do LLMs sometimes confidently state incorrect facts (hallucination), and what does that imply for production use?← Back to all Spring AI questions