Short answer
Temperature is a request setting that changes how random the next token is. OpenAI allows 0 to 2, default 1, with 0.2 more focused and 0.8 more random. Anthropic allows 0.0 to 1.0, default 1.0, and says even 0.0 is not fully deterministic. Gemini's reference allows 0.0 to 2.0, and the Gemini 3 guide says to leave the default at 1.0.
Last verified against the sources listed below.
Key takeaways
- OpenAI documents temperature from 0 to 2, default 1. Lower is more focused, higher is more random.
- OpenAI says to change temperature or top_p, not both. top_p defaults to 1.
- Anthropic documents 0.0 to 1.0. Even 0.0 is not fully deterministic on that API.
- Models released after Claude Opus 4.6 reject a temperature other than 1.0 with a 400 error.
- Gemini's API range is 0.0 to 2.0, and the field is ignored on Gemini 3.6 Flash and newer.
The question what is temperature in ai is about a number you send with a prompt so the sampler picks the next token with more or less randomness. It is not a thermostat, and it is not the same number on every API.
The probabilities being sampled come from a trained model, which is the subject of what machine learning is. Temperature only changes how those scores are used at answer time. The three vendors below print different ranges, so copy the range from the API you call.
What does the dial change?
It changes how often a lower-probability token is chosen. It does not retrain the model.
OpenAI’s chat completions reference describes temperature as the sampling temperature. Higher values such as 0.8 make the output more random. Lower values such as 0.2 make it more focused and deterministic.
The default is 1. The allowed span is 0 to 2.
Gemini’s generateContent reference says the field controls the randomness of the output, and that tokens are sorted by the probabilities the model assigned so only the more likely tokens are considered. Top-k limits how many of those tokens are eligible. Nucleus sampling, called top-p, limits them by cumulative probability instead.
Temperature is applied with that selection. None of these pages prints a softmax equation, so this guide will not invent one. In plain words, the model has already scored candidate tokens.
Sampling draws one. A low temperature keeps the draw on the high scores. A high temperature lets lower scores win more often.
Anthropic uses the phrase amount of randomness injected into the response. Closer to 0.0 is for analytical or multiple-choice work. Closer to 1.0 is for creative and generative work.
The page adds that a temperature of 0.0 is still not fully deterministic.
What range does each API allow?
Read the vendor page. The floors match. The ceilings do not.
| Provider | Documented range | Default on that page | What a low value does | What a high value does |
|---|---|---|---|---|
| OpenAI chat completions | 0 to 2 | 1 | More focused. The example given is 0.2 | More random. The example given is 0.8 |
| Anthropic Messages | 0.0 to 1.0 | 1.0 | Analytical or multiple choice, nearer 0.0 | Creative and generative tasks, nearer 1.0 |
| Gemini generateContent | 0.0 to 2.0 | Varies by model | Less randomness. Gemini 3 guide says do not drop below 1.0 | More randomness, up to the documented ceiling |
OpenAI also documents top_p from 0 to 1, default 1. A top_p of 0.1 keeps only the tokens that make up the top 10 percent of probability mass. The reference says to alter temperature or top_p, not both.
Anthropic’s ceiling is 1.0, not 2. A caller who copies an OpenAI value of 1.5 into that field is outside the range the Messages page prints. The same page marks temperature, top_k, and top_p as deprecated for models released after Claude Opus 4.6.
Gemini’s ceiling matches OpenAI’s 2.0 on the generateContent reference, and the default is not a single number. The page says to read Model.temperature from the model object. A call that assumes default 1 on every Gemini model is guessing.
What happens at the low end?
Low settings stick to higher-probability tokens. They still do not promise an identical answer every time.
OpenAI’s example of a focused setting is 0.2, against a default of 1. Anthropic points values near 0.0 at analytical and multiple-choice tasks, and then warns that 0.0 is not fully deterministic. If you run the same prompt twice at the floor, you can still see two strings.
The API said so. A test that expects a byte-for-byte match needs a check in your own code, not faith in the parameter.
The Gemini 3 guide goes further for that model family. It says to keep temperature at the default of 1.0. Earlier models often gained from turning the dial to trade variety against determinism.
Gemini 3’s reasoning is described as optimized for the default. Setting the value below 1.0 may cause looping or degraded performance, particularly on complex mathematical or reasoning tasks. The migration note says that if older code sets a low temperature for deterministic output, remove the parameter and use 1.0.
So a low number is not a universal best setting for facts. On one API it is the documented way to be more focused. On Gemini 3 it is the setting the guide tells you to avoid.
What happens at the high end?
High settings let less likely tokens through more often. Each API stops at its own ceiling.
OpenAI’s high example is 0.8, still under a maximum of 2. The text says that higher values make the output more random. It does not say that 2 is a good default for product copy.
Anthropic never offers a value above 1.0. Near 1.0 is the creative and generative end of its scale. There is no documented 1.5 on that page.
Sending one can fail validation, and on newer models even a legal-looking 0.7 fails for a different reason, covered below.
Gemini allows up to 2.0 on the generateContent reference, with the same caveat that newer flash models ignore the field. A high value you cannot observe is not a high value. If the model silently drops the parameter, the sample follows the model’s own default, not the 1.8 you thought you set.
Variety has a cost the docs imply by the word random. A support answer, a unit conversion, or a multiple-choice grade is where OpenAI’s focused example and Anthropic’s analytical example belong. A brainstorm is where the higher example belongs.
A product page that explains the control can take its colors from the AI company palette generator.
Google’s glossary calls temperature a hyperparameter for randomness and says it is often used with softmax. That page does not print an equation, so this guide does not invent one.
Why do some models ignore it?
Newer Claude models reject other values. Newer Gemini flash models ignore the field. Your client should branch.
Anthropic writes that models released after Claude Opus 4.6 do not support setting temperature. The value 1.0 is accepted for compatibility. Every other value returns a 400 error.
top_k is rejected at any value on those models. top_p is accepted only at 0.99 or higher. A stack that still sends a creative 0.9 will break when the model name moves past that line, unless you stop sending the field.
Gemini’s generateContent page says temperature is no longer supported and is silently ignored on Gemini 3.6 Flash and newer models. The same sentence appears for topP. Silent is the important difference from Anthropic.
You may not get an error. You also may not get the randomness you asked for. Log the model id next to the parameter so a later reader can see whether the number was eligible.
OpenAI’s create-completion page notes that parameter support can differ by model, particularly for newer reasoning models, and it points at a reasoning guide for unsupported parameters. If the model rejects the field, the error response is the source of truth.
Calling the API from Python is the pattern in the vendor examples: a client constructor, then a request body that includes the prompt and, when the model allows it, the temperature number.
How do you pick a value?
Use the default unless you have a reason printed in that vendor’s docs, and never copy a number across vendors.
- Identify the provider and the model id, because the range and the ignore rules differ.
- If the model is Gemini 3, leave temperature at 1.0, as that guide asks.
- If the model is newer than Claude Opus 4.6, send 1.0 or omit the field, or expect a 400.
- On OpenAI, start at the default of 1, drop toward 0.2 when you want the focused behavior the reference describes, and raise toward 0.8 when you want the random behavior.
- Change top_p only if you are not also changing temperature. OpenAI says to alter one of them.
- Run the same prompt more than once before you trust a low setting. Anthropic says 0.0 is not fully deterministic.
- Record the model and the value next to the output, so a later model that ignores the field does not leave a misleading note.
Frequently asked questions
What is top_p, if temperature is already set?
OpenAI calls top_p nucleus sampling and an alternative to temperature. A value of 0.1 keeps the tokens that make up the top 10 percent of probability mass. The default is 1, and the range is 0 to 1. Change temperature or top_p, not both. Anthropic walks options from most probable to least and cuts off at top_p. On models after Claude Opus 4.6, a top_p below 0.99 is rejected, while 0.99 and above is kept for older clients.
Why is zero still not a guarantee on Claude?
Anthropic says even a temperature of 0.0 will not make results fully deterministic. The same note sets the default at 1.0 and the range at 0.0 to 1.0. Values near 0.0 are for analytical or multiple-choice tasks. Values near 1.0 are for creative tasks. If you need the identical string every time, this parameter does not promise it. Run the call twice at the floor and compare the text before you treat a match as guaranteed.
What does a 400 error mean for temperature?
On Anthropic's Messages API, models released after Claude Opus 4.6 do not support a custom temperature. The value 1.0 is accepted so older clients keep working. Any other value returns HTTP 400. top_k is rejected at any value on those models. top_p is accepted only at 0.99 or above. A library that still sends 0.2 will fail on those models. Omit the field or send 1.0.
Which Gemini models ignore the field?
The generateContent reference allows 0.0 to 2.0 and says the default varies by model. It then says the field is silently ignored on Gemini 3.6 Flash and newer models. The call can succeed while the number you sent changes nothing. The Gemini 3 guide, for that family, says to keep the default of 1.0. A value below 1.0 may loop or do worse on hard math and reasoning. Read the model id before you assume a low setting took effect.
Where does the next-token score come from?
Google's machine learning glossary calls temperature a hyperparameter for how random the output is, and says it is often used with softmax. The glossary does not print a formula. Gemini's API page says tokens are sorted by assigned probabilities, then top-k or nucleus sampling limits the set. A lower temperature keeps the draw on the more probable tokens. A higher one lets lower scores win more often. Changing the number does not retrain the model or add facts it did not already score.
Sources
- Create chat completion · OpenAI, 2026
- Messages API parameters · Anthropic, 2026
- Generating content · Google AI for Developers, 2026
- Gemini 3 Developer Guide · Google AI for Developers, 2026
- Machine Learning Glossary: temperature · Google for Developers, 2026