Temperature
Definition
A sampling setting that controls randomness: lower values favour the most likely tokens, higher values spread probability more evenly.
In more detail
Low temperature suits extraction and classification; higher temperature suits brainstorming. Temperature zero reduces variation but does not guarantee identical outputs across runs. Some reasoning models fix or ignore this setting.
At each step the model assigns a probability to every possible next token. Temperature rescales those probabilities before one is sampled: near zero, the top choice almost always wins; around 1, the model samples close to its learned distribution; well above 1, unlikely tokens get picked often enough that output turns incoherent.
Change one sampling setting at a time and check the effect on your eval set. Temperature and top-p interact, so most providers suggest adjusting one and leaving the other at its default.
Related terms
Hallucination
A fluent, confident model output that is false or not supported by its sources, such as an invented citation, quote or API call.
Log probabilities (logprobs)
The log of the probability a model gave each token it generated, returned by some APIs to show how confident the model was.
Self-consistency
Sampling several reasoning paths for the same question and taking the most common final answer, instead of trusting a single response.
Token
The unit of text a model reads and writes, often a word or part of a word; in English a token averages about four characters of text.
Top-p
A sampling setting that restricts the model to the smallest set of likely tokens whose probabilities add up to p, then samples from that set.
Read more about Temperature
- LLM API parameters cheat sheet
Temperature, top_p, max tokens, stop, seed, logprobs, JSON output and reasoning effort, with exact names for OpenAI, Claude and Gemini, checked on the API docs.
- Prompt engineering
Writing clear, testable instructions for models and checking them on real inputs.
- Prompting fundamentals: clear tasks, examples and formats
How to write a good prompt: frame the task, say who the output is for, show an example and specify the format, so a model's answers are useful and repeatable.
- Write your first LLM eval
Turn real outputs into a small test set, add code-based checks in promptfoo and run them in CI to catch regressions on every change.