TLDR
Claude is autoregressive: it predicts one token at a time from a probability distribution conditioned on everything before it, then appends that token and repeats. Even at temperature: 0, Anthropic states results "will not be fully deterministic and identical inputs may produce different outputs across API calls," true for first-party and third-party inference alike. Claude glossary: Temperature
What it is
Every Claude call rests on the same next-token loop: an autoregressive model predicts one token at a time, sampling from a probability distribution over the vocabulary conditioned on everything before it, appends that token, and repeats. Tokens are the smallest units the model processes; for Claude, one token is "approximately 3.5 English characters," though this varies by language, so /v1/messages/count_tokens should be used to budget usage rather than assuming a fixed character-to-token ratio.
The context window is "all the text a language model can reference when generating a response, including the response itself," a working-memory buffer, not the training corpus. Everything in a request counts toward it: system prompt, every message (including tool results, images, documents), tool definitions, plus all generated output including extended-thinking tokens. Current models (Opus 4.8/4.7/4.6, Sonnet 5/4.6, Fable 5) default to a 1M-token window at standard pricing; Sonnet 4.5 caps at 200K. More context is not automatically better: accuracy and recall can degrade as tokens grow, a documented phenomenon Anthropic calls "context rot."
Sampling and non-determinism sit on top of the same loop. temperature controls output randomness, higher increases variation, lower pushes toward the most probable tokens. The load-bearing fact for the exam: even at `temperature: 0`, output is not guaranteed reproducible, a property of the sampling process itself, not a configuration mistake.
How it works
Next-token generation is the mechanism everything else sits on. Nothing about tokens, context windows, or sampling changes this: the model always produces one token, appends it to the sequence, and conditions the next prediction on the updated sequence. Thinking tokens, tool-call arguments, and plain text are all generated through this same loop, just with different downstream handling.
Token counting is measured, not estimated. Use /v1/messages/count_tokens on representative inputs before sending a request, rather than dividing character count by a fixed ratio, since the ~3.5 chars/token figure varies by language and content. Context-window overflow is enforced server-side: if the input alone exceeds the window, the API returns a 400 error before generation starts; if input_tokens + max_tokens exceeds the window, generation can stop mid-response instead.
Sampling parameters are being phased out on the newest models, not just theoretically unreliable. On all six models that reject them - Claude Fable 5, Claude Mythos 5, Claude Mythos Preview, Claude Opus 4.8, Claude Opus 4.7, and Claude Sonnet 5 - non-default temperature, top_p, and top_k values are rejected outright with an HTTP 400, on every request to those models, regardless of whether thinking is active. The replacement lever is output_config.effort (low/medium/high[default]/xhigh/max) combined with thinking: {type: "adaptive"}, which lets Claude decide whether and how much to think per request. This is a model-selection and cost-tuning decision in its own right; see Model Selection & Tradeoffs for the full tier/pricing/migration picture, this page stays focused on the tokens-and-sampling mechanics underneath it.
Fundamental prompting techniques sit on the same spectrum, differentiated by example count. Zero-shot supplies no examples and leaves output format to the model's judgment. Anthropic's documented technique is "few-shot or multishot prompting," wrapping "a few well-crafted examples" in <example> tags, which "improve accuracy and consistency." Single-shot (one example) is the standard midpoint between the two. This page covers the spectrum at the fundamentals level; the deep multishot technique, including the exact <sample_input>/<ideal_output> XML pattern and measured accuracy gains, lives in Prompt Engineering Techniques.

Where you'll see it
Audit logging system
Instead of assuming temperature: 0 gives replayable outputs for compliance review, the system logs the actual generated output at call time, since replay isn't guaranteed even at zero temperature.
Multilingual classification pipeline
Calls /v1/messages/count_tokens per input language before sizing max_tokens, instead of a single fixed characters-per-token heuristic that would misestimate non-English inputs.
Side-by-side
| Technique | Examples in prompt | Best for | Tradeoff |
|---|---|---|---|
| Zero-shot | 0 | Simple, well-understood tasks with an obvious output shape | Format and edge-case handling left entirely to the model's judgment |
| Single-shot | 1 | Establishing one concrete pattern or format quickly | One example rarely covers every edge case or failure mode |
| Multi-shot (few-shot) | 2-5, wrapped in <example> tags | Consistent format/tone across ambiguous or edge-case-heavy tasks | More prompt tokens per call; only pays off when examples target observed failures |
Decision tree
Does this workload require exact, reproducible output across repeated calls (e.g. for compliance replay)?
temperature: 0; Anthropic states it does not guarantee determinism, on any inference path.Is the target model one of the six that reject non-default sampling params (Fable 5, Mythos 5, Mythos Preview, Opus 4.8, Opus 4.7, Sonnet 5)?
temperature/top_p/top_k will be rejected with a 400; use output_config.effort and adaptive thinking instead.Is the task's correct output format ambiguous, or does it have known edge cases Claude has failed on before?
<example> pairs targeting exactly those observed failures.Do you need to budget max_tokens or estimate cost before sending a request?
/v1/messages/count_tokens on representative inputs rather than estimating from a fixed character ratio.Question patterns

6 V2 questions wired to this concept. Tap an answer to check it instantly - you'll see whether it's right and why - then expand the full breakdown for the mental model and all four rationales.
Tap your answer to check it.
temperature: 0 on every call in a compliance-sensitive pipeline, expecting fully reproducible, identical output for identical input across repeated calls. Is this a safe assumption?Tap your answer to check it.
thinking: {type: "enabled", budget_tokens: N}. What should they expect?Tap your answer to check it.
<example> input-output pairs to the system prompt, believing "more examples always improve consistency." What consideration is missing from this reasoning?Tap your answer to check it.
Tap your answer to check it.
Tap your answer to check it.
Frequently asked
Does `temperature: 0` guarantee identical outputs across calls?
Is a token the same thing as a word or a character?
/v1/messages/count_tokens for an exact count rather than a fixed conversion ratio.Work this with your AI
Work this concept hands-on with Claude Code, Codex, or claude.ai. Copy a prompt, paste it into your assistant, and practise in tandem. Each one keeps you active (explain it back, get drilled, or build) rather than just reading.
- Drill it like the exam (scenario MCQs)Practice in the exam's scenario-MCQ format with trap awareness.
- Explain it back (Feynman)Build durable, transferable understanding of a concept you can half-state.
- Test me, adapting the difficultyActive recall practice on a concept you think you know.
- Check my prerequisites firstBefore studying a concept that keeps not sticking.
- Find the high-leverage 20%When a domain feels too big and you are short on time.
