TL;DR: Temperature in AI is a setting that controls how random or predictable a language model’s answers are. A low temperature (close to 0) makes the model pick the most likely next words, so answers are focused and consistent. A higher temperature spreads the odds out, so answers become more varied and creative, and more likely to drift off track. Most APIs default to 1.0; OpenAI and Gemini accept roughly 0 to 2, while Anthropic’s Claude accepts 0 to 1. Use low values for facts, code and data extraction, and higher values for brainstorming and creative writing.
What is temperature in AI, and why does the same prompt sometimes give you a different answer every time? The short answer is that chatbots don’t look up a single fixed reply. They pick each word from a list of possibilities, and temperature decides how adventurous that pick is. This guide explains how it works in plain English, what values to use and the limits of tweaking it.
How a language model picks its next word
A large language model writes text one token at a time. At each step it scores every possible next token and turns those scores into probabilities. For the sentence “The sky is…”, the model might give:
- “blue”: 70%
- “clear”: 15%
- “falling”: 3%
- thousands of other options sharing the rest
The model then samples one token from that list. This step is called decoding, and it is part of AI inference. Temperature changes the shape of the list before the pick happens.
What temperature actually does
Technically, the model’s raw scores (called logits) are divided by the temperature before they are converted into probabilities with a function called softmax. The effect is simple to picture:
- Temperature below 1 sharpens the distribution. “Blue” might rise from 70% to 95%, so the model almost always picks it.
- Temperature of 1 leaves the model’s probabilities as they are.
- Temperature above 1 flattens the distribution. “Clear” and “falling” get a bigger share, so surprising choices appear more often.
- Temperature of 0 in practice means “always take the top choice,” known as greedy decoding.
The same idea, borrowed from physics, appears in Geoffrey Hinton’s well-known 2015 paper “Distilling the Knowledge in a Neural Network”, where a higher temperature is used to produce a “softer” probability distribution. We cover that technique in our guide to knowledge distillation.

Temperature ranges in popular AI APIs
Each provider sets its own limits. These are the ranges listed in their documentation:
| Provider | Range | Default | Source |
|---|---|---|---|
| OpenAI | 0 to 2 | 1 | OpenAI API reference |
| Anthropic (Claude) | 0 to 1 | 1 | Anthropic Messages API |
| Google Gemini | 0 to 2 | 1 (on recent models) | Google Cloud docs |
One important caveat: many newer reasoning models either ignore temperature, fix it at a set value or reject non-default sampling settings. Always check the model’s documentation before relying on the parameter, and remember that consumer apps like ChatGPT or Gemini usually don’t expose it at all.
What temperature should you use?
There is no single right value, but these starting points work well for most tasks:
| Task | Suggested temperature | Why |
|---|---|---|
| Data extraction, classification, JSON output | 0 to 0.2 | You want the same answer every time |
| Code generation and math | 0 to 0.3 | Small deviations break code or logic |
| Factual Q&A and summaries | 0.2 to 0.5 | Accurate but still natural-sounding |
| General chat and emails | 0.5 to 0.9 | A balance of variety and focus |
| Brainstorming, fiction, slogans | 0.9 to 1.3 | More unexpected ideas |
Values well above 1.5 tend to produce rambling or nonsensical text, so they are rarely useful in practice.
Temperature vs top-p and top-k
Temperature isn’t the only sampling dial. Two others often appear next to it:
- Top-p (nucleus sampling): the model only picks from the smallest set of tokens whose probabilities add up to p. With top-p of 0.9, it ignores the long tail of unlikely words.
- Top-k: the model only picks from the k most likely tokens, for example the top 40.
OpenAI’s documentation generally recommends adjusting temperature or top-p, not both, because changing both at once makes results harder to predict. A good habit is to leave top-p at its default and tune temperature first.
Common myths about temperature
“Temperature 0 makes answers deterministic”
Not always. Even at temperature 0, hardware-level floating-point differences, batching and model updates can produce slightly different outputs between runs. It makes results far more consistent, but not guaranteed identical.
“Low temperature stops hallucinations”
It helps a little, because the model sticks to its most likely answer. But if the most likely answer is wrong, a low temperature just makes the model confidently wrong every time. Grounding the model in real documents, for example with RAG, does much more to reduce hallucinations.
“Higher temperature makes the model smarter or more creative”
It makes the model more random, which can look like creativity. The underlying knowledge doesn’t change. Push it too far and quality drops quickly.
How to experiment with temperature
- Open a playground that exposes the setting, such as the OpenAI Playground, Anthropic Console or Google AI Studio.
- Pick one prompt and run it three times at 0, then three times at 1.
- Compare how much the wording and ideas change.
- Settle on the lowest value that still gives you the variety you need.
The bottom line
Temperature in AI is a simple knob with a big effect: it trades consistency for variety. Keep it low when accuracy and repeatability matter, raise it when you want fresh ideas, and remember that it can’t fix a model that doesn’t know the answer. For more AI basics, see our explainers on context windows and fine-tuning.



