Temperature
In shortTemperature is a setting that controls how random a model's word choices are: low gives steady answers, high gives more varied ones.
In plain words
At each step a model scores every possible next token and then picks one. Temperature changes how it picks. With a low value the model nearly always takes the most likely word. With a high value it also takes less likely words, so the text varies more. Anthropic's glossary puts it this way: higher temperatures give more creative and diverse output, lower ones give more conservative and deterministic output that sticks to the most probable phrasing.
The range and the default differ by provider and model. Some newer models fix the sampling settings. Google's Gemini docs, for example, say that certain Gemini models ignore custom values for temperature and tell you to remove it from your requests. Anthropic goes further: current Claude models such as Opus 5.5 reject temperature, top_p and top_k with an error and ask you to steer the model through the prompt instead. Read the page of the model you use.
Why it matters
- Match the task: For data extraction, classification, code and factual answers, use a low value. For brainstorming, slogans or story ideas, a higher value gives more options.
- Risk: More randomness raises the chance of odd or wrong wording, so higher settings can add hallucination risk.
- Repeatability: Low temperature makes tests easier to repeat. It does not guarantee identical output: Anthropic notes that even at 0 the results are not fully deterministic.
- No cost effect: Temperature does not change the price per token.
Example
You ask for five slogans for a bakery, twice. At a low temperature, both runs give nearly the same list. At a higher temperature, the second run offers new ideas. For an invoice-data extraction job you want the opposite: the same fields, run after run, so you keep the value low.
Common misconceptions
- "Temperature 0 gives the same answer every time." Not guaranteed. Small differences can remain.
- "A high temperature makes the model smarter or more creative in thought." It makes the word choice more varied, nothing more.
- "Every model has this knob." Some models ignore it, current Claude models reject it.
Questions and answers
What is a good temperature setting?
Low for facts, extraction and code; higher for brainstorming and creative writing. Start with the provider's default and change one setting at a time.
Does temperature 0 make the output deterministic?
Not fully. Anthropic's glossary notes that identical inputs can still give different outputs even at 0.
Does temperature affect cost?
No. Price depends on tokens, not on the sampling settings.
Read next
- Hallucination
A hallucination is a fluent, confident AI answer that is false, invented or not backed by the sources it was given.
- Inference
Inference is the act of running a trained AI model to produce an output from your input, such as an answer to a prompt.
- Prompt
A prompt is the input you give an AI model: your question or task, plus any instructions, examples and text it should use.
- Large language model (LLM)
A large language model (LLM) is an AI system trained on huge amounts of text to predict the next token, which lets it write, summarise and answer.