AI EngineeringFoundation12 min

LLM fundamentals for engineers

Tokens, context windows and sampling: the handful of mechanics that explain most model behaviour.

See it on the map

A language model reads and writes tokens, which are chunks of text, not words. Cost, latency and limits are all counted in tokens. The context window is the total a request can hold, input and output together, and anything outside it simply does not exist for the model.

The model predicts a probability distribution over the next token. Temperature and top-p control how adventurous the choice is. Low temperature is steadier and better for extraction and code. Higher values add variety but also error. Even at zero, treat output as probabilistic and never as a guarantee.

Models do not look things up. They generate from patterns in training plus whatever you put in the prompt. That is why grounding, giving the model the facts at call time, is the main lever against confident wrong answers.

Key points

  • Everything is billed and limited in tokens, including your system prompt.
  • Context is the model's entire working memory for a call.
  • Low temperature for deterministic tasks, but still validate outputs.
  • Ground answers in supplied facts instead of trusting recall.

Answer these out loud

  1. 1Estimate the cost of 10,000 requests with a 2,000-token prompt and a 500-token answer at the rates for a model you use.
  2. 2Why can the same prompt give different answers at temperature 0 across providers or versions?

Use this from an agent

Any MCP client, including Grok, can read this lesson. See how to connect.

REST
curl https://engineeros-delta.vercel.app/api/v1/topics/llm-fundamentals

This unlocks