Your AI Has Creativity Dials
When a language model writes, it doesn't "choose" the next word — it computes a probability for every possible next token and then samples one. The sampling parameters are your dials over that choice. Most developers ship with the defaults and then wonder why their extraction pipeline is flaky or their brainstorming bot is boring.
The three dials
- Temperature — scales the probability distribution before sampling. Low (0–0.3): the likeliest token almost always wins — predictable, factual, repetitive. High (0.8–1.0+): unlikely tokens get real chances — creative, surprising, occasionally unhinged.
- Top-K — hard-caps the candidate pool: "only ever pick from the K likeliest tokens."
top_k: 5on "the sky is ___" means the model chooses among ~blue, cloudy, dark, clear, falling — and nothing weirder. Blunt but effective. - Top-P (nucleus sampling) — the adaptive version: pick from the smallest pool of tokens whose probabilities sum to P. With
top_p: 0.9, a confident model might have a 2-token pool; an uncertain one might have 15. It flexes with the model's own confidence, which is why it generally beats top-k in practice.
Rules of thumb
| Task | Setting |
|---|---|
| Data extraction, JSON output | temperature ≈ 0–0.2 |
| Code generation | temperature ≈ 0–0.4 |
| Summaries, support answers | temperature ≈ 0.3–0.6 |
| Brainstorming, creative copy | temperature ≈ 0.8–1.0 |
| Fighting weird outputs | top_p 0.9 (don't stack with high temperature) |
Set temperature or top_p, not both — on Claude 4+ models passing both is an error, and elsewhere it's just fighting yourself.
The power-user caveat: the newest models removed the dials
Claude Opus 4.7+, Opus 4.8, Sonnet 5, and Fable 5 reject temperature, top_p, and top_k entirely (HTTP 400). On those models you steer with:
output_config.effort(low→max) — how hard the model thinks;- Prompting — "vary your phrasing across responses" for variety, or "propose 4 distinct directions and ask me to pick" for design work.
If you were using temperature: 0 for "determinism" — it never guaranteed identical outputs anyway. Tighter prompts + low effort is the modern equivalent.
Resources
- Anthropic Messages API reference (parameters)
- Model migration guide — sampling params removed on Opus 4.7+
- The effort parameter
Building an AI feature? Yeda AI designs, audits, and ships production LLM systems.