Overview
Temperature is a sampling parameter that rescales next-token probabilities before one token is chosen: lower values favor the most likely token, higher values spread probability toward less likely ones.
Check whether the model accepts it before setting it. On Claude models released after Opus 4.6 (Opus 4.7 and later, Sonnet 5 and 5.5, Haiku 5.5, Fable 5 and 5.1), the API accepts only the defaults (temperature 1.0, top_p 0.99 or higher) and returns HTTP 400 for any other value and for any top_k; Haiku 5.5 also rejects top_p 1.0 and any request that sends both. Opus 4.6, Sonnet 4.6, the previous-generation Haiku 4.5, and older models still accept the full range, with temperature from 0 to 1. OpenAI’s GPT-6 guide says to remove temperature, top_p, and top_logprobs whenever reasoning effort is not none; GPT-6 Astra and GPT-6.1 Sol do not support none, so they never accept them, while GPT-6 Sol and GPT-6 Luna do.
Where accepted, use low values for extraction and classification, higher values for varied drafts, and change temperature or top-p, not both. On models that reject it, control behavior with the prompt and the effort setting (output_config.effort on Claude, reasoning effort on OpenAI); see reasoning-model.
Temperature 0 does not guarantee identical output, even on Anthropic’s models. For repeatable pipelines, rely on structured-output with validation and cache results you need to reproduce.
Related
- top-p: the companion sampling control with the same availability limits.
- reasoning-model: the models that replace sampling control with effort.
- reasoning-model-prompting: effort, token caps, and sampling settings.
- structured-output: reliability without relying on temperature.
- completion: the output sampling produces.