Temperature
The knob that controls creativity vs consistency
What is temperature
Temperature is a parameter that controls the randomness of a language model's output. A temperature of 0 makes the model deterministic — it always picks the most probable next token. A temperature of 1 allows more varied, creative responses. Values above 1 produce increasingly random output.
Most API providers default to temperature 0.7. For code generation and factual tasks, lower temperatures (0–0.3) produce more reliable results. For creative writing and brainstorming, higher temperatures (0.7–1.0) are preferred.
Why it matters
Temperature does not affect cost — the same number of tokens are generated regardless. It affects quality and consistency. If your application requires reproducible output (test generation, data extraction, structured responses), set temperature to 0. If it requires variety (content generation, suggestion engines), increase it.
Verified March 2026 · Source: OpenAI API docs, Anthropic docs