# Temperature

> The setting that makes an AI model's answers more predictable or more varied.

- Level: Intermediate
- Topics: AI
- URL: https://tidbit.legios.com.ar/temperature/
- In Spanish: [Temperatura](https://tidbit.legios.com.ar/es/temperature/)

An LLM writes one token at a time, and at every step it has a list of possible next tokens, each with a probability. **Temperature** is a number you send with your request that changes how the model picks from that list. The name is borrowed from physics, where heat makes particles move more randomly.

At a low temperature, close to 0, the model almost always takes the most likely option. Answers become focused, repetitive and very similar from one run to the next. At a higher temperature the less likely options get a real chance, so the text becomes more varied and surprising, and past a point also more rambling and error-prone. The range depends on the provider: Anthropic's API accepts 0 to 1, OpenAI's 0 to 2.

In practice: keep it low for tasks with one right answer, like pulling data out of an invoice, classifying a message or writing code; raise it for brainstorming, names or fiction where you want options. Even at 0 the output is not guaranteed to be identical every time, and some newer reasoning models fix the temperature and do not let you change it. Temperature is often combined with **top-p**, which cuts off the long tail of unlikely tokens.

## An analogy

Ordering at your usual café. At low temperature you get your regular, every single time. Turn it up and the waiter starts suggesting the special of the day, and at the very top, something nobody has ever ordered.

## Keep in mind

- Controls how much randomness goes into picking each next token.
- Low means focused and consistent; high means varied and creative.
- Low for extraction, classification and code; higher for ideas.
- Ranges differ by provider, and 0 does not guarantee identical output.

## Go deeper

- [Messages API reference, temperature parameter (Anthropic)](https://docs.anthropic.com/en/api/messages)
- [Softmax function and temperature on Wikipedia](https://en.wikipedia.org/wiki/Softmax_function)

## Related terms

- [LLM](https://tidbit.legios.com.ar/llm/): A neural network trained on huge amounts of text to predict the next word.
- [Token](https://tidbit.legios.com.ar/token/): The small chunk of text a language model actually reads.
- [Anthropic](https://tidbit.legios.com.ar/anthropic/): The AI company behind Claude, built around making models safe and useful.
- [API](https://tidbit.legios.com.ar/api/): The menu of things one program lets another program ask for.
- [OpenAI](https://tidbit.legios.com.ar/openai/): The company that made ChatGPT and turned AI into a household topic.
- [Reasoning model](https://tidbit.legios.com.ar/reasoning-model/): An AI model that works through a problem step by step before it answers.
