LLM temperature controls how strongly next-token sampling favors a model's highest-scoring candidates. Lower values generally produce more consistent responses, and higher values increase variation. A consistent answer can still be incorrect, and temperature 0 does not guarantee identical responses from hosted APIs.
This guide explains temperature scaling, its effects across task types, and the causes of variation at temperature 0. It also covers top-p and top-k, current provider restrictions, and a repeatable process for choosing a setting through evaluation.
Braintrust compares temperature settings against a shared dataset and records the results as experiments. Repeated trials reveal how consistently each configuration meets the task's quality requirements, giving teams evidence for production decisions.
What is LLM temperature?
LLM temperature is a sampling parameter that controls randomness in token selection. A language model generates text one token at a time, assigning a raw score to each candidate token based on the input and the text generated so far. Temperature rescales the scores before sampling, changing the probability of selecting each candidate.
Changing temperature does not change the model's weights. For the same context and raw scores, a lower temperature concentrates probability on the highest-scoring candidates, while a higher temperature spreads probability more evenly across the vocabulary.
Where temperature appears: Developers set temperature in model API requests and prompt playgrounds. Supported ranges and defaults depend on the model and API, so the same numeric value can produce different behavior across models.
Where temperature is restricted: Some current models reject custom sampling values or ignore the parameter, so check the exact model and API version before tuning temperature. The support table later in this guide lists current behavior by provider.
How LLM temperature works
Temperature scales the model's raw token scores into the probability distribution used for sampling, and the model applies the same rescaling at every token it generates.

Temperature scaling and the softmax function
For each output position, the model produces a raw score, called a logit, for each candidate token. The softmax function converts the logits into probabilities that sum to 1. For a temperature greater than 0, the probability of token i is:

Here, z_i is the logit for token i, and T is the temperature. Values below 1 increase the differences between scaled logits, concentrating probability on the leading candidates. Values above 1 reduce the differences and produce a flatter distribution. At T = 1, temperature leaves the logits unchanged.
As T approaches 0, probability concentrates on the highest-scoring token, assuming it has a unique maximum score. In inference engines that support temperature 0, the sampler handles zero separately through greedy decoding, selecting the highest-scoring token at each step.
Low vs. high temperature values
Suppose a model completing "Your package will arrive" assigns logits of 3.0, 2.4, 2.0, 1.2, and 0.4 to five candidate tokens. The table shows the resulting probabilities, rounded to one decimal place.
| Candidate token | T = 0.5 | T = 1.0 | T = 1.5 |
|---|---|---|---|
| Monday | 68.1% | 46.4% | 37.6% |
| tomorrow | 20.5% | 25.5% | 25.2% |
| Friday | 9.2% | 17.1% | 19.3% |
| soon | 1.9% | 7.7% | 11.3% |
| later | 0.4% | 3.4% | 6.6% |
At 0.5, the top candidate is selected about two times in three, and the two least likely candidates hold about 2% of the probability between them. At 1.5, the top candidate falls to roughly 38%, and "soon" and "later" together reach about 18%.
Effects compound across a response: Once sampling selects a different token, the model generates subsequent tokens from a different context. An early difference can therefore change the wording, structure, or conclusions of the completed response.
Higher values can reduce coherence: Sampling less likely tokens more frequently can introduce grammatical or logical errors. In a 2024 story-generation study, Peeperkorn et al. found a moderate relationship between temperature and incoherence, with only a weak relationship to novelty. The findings apply to the study's fixed model, prompt, and narrative task.
Temperature, consistency, and accuracy by task type
Lower temperature often makes outputs more consistent, but accuracy depends on whether the preferred response is correct. A model that favors an incorrect answer can reliably repeat the error at low temperature.
Renze and Guven's 2024 study tested nine models on multiple-choice questions sampled from standard benchmarks and found that temperature changes from 0.0 to 1.0 had no statistically significant effect on performance. The study predates current reasoning models, so its results do not establish an optimal setting for production.
The acceptable amount of variation depends on the task:
Extraction, classification, and structured output: These tasks usually require stable fields or labels. A low supported temperature is a candidate to test, but schema validation and answer correctness need separate checks. Valid JSON can still contain an incorrect amount, date, or classification.
Code generation and agent tool calls: A different tool choice or argument early in a run can change later steps. Test low supported values when a run must follow the same tool sequence each time, and measure code test results or tool-call correctness. Processes that generate several candidate solutions and select one using tests may benefit from additional sampling variation.
Conversational assistants: Wording may vary without changing the correct answer. Evaluate tone separately from policy compliance and factual consistency, using explicit instructions and current source information to define acceptable responses. Systematic prompt engineering helps turn those requirements into testable criteria.
Brainstorming, creative writing, and synthetic data: Variation is useful when the task requires distinct candidates. Compare the default with higher supported values, measuring diversity alongside coherence and factual or task-specific constraints.
Why LLM responses vary at temperature 0
Temperature 0 removes random sampling in greedy decoding, but identical API requests can still produce different responses. Repeated evaluations of nondeterministic output measure how often response variation changes a task's score.
Batch invariance and inference nondeterminism
Thinking Machines Lab's September 2025 research demonstrated how batching can change inference results. A server groups requests into batches, and some inference kernels produce slightly different numerical results as batch size changes. Floating-point arithmetic depends on the order of operations, so a small logit difference can change the winning token when candidates are nearly tied.
In one experiment, 1,000 temperature-0 completions from Qwen3-235B produced 80 unique outputs, with the first divergence at token 103. Using batch-invariant kernels made all 1,000 completions match. The result demonstrates one source of variation under the tested conditions; hosted API users depend on their provider's inference implementation.
Provider model updates and infrastructure changes can introduce further differences over time. Agents add variation through changing tool responses or retrieved context, and an LLM judge may assign different scores to the same output.
What seeds and repeated runs establish
A seed controls the sampler's random number sequence where the API supports it. Seeded sampling can improve reproducibility, but OpenAI describes it as best effort and does not guarantee determinism. Model support, request parameters, and backend behavior still affect the result. If production requests send no seed, leave it unset during evaluation so trials reflect the variation production traffic will see.
Repeated runs measure how outputs and scores vary under the tested conditions. When two configurations produce similar average scores, additional trials and per-input comparisons show whether one consistently outscores the other or only wins on a favorable set of trials.
Temperature vs. top-p and top-k sampling
Temperature, top-p, and top-k each shape token selection differently. Temperature rescales scores across the whole distribution, while top-p (also called nucleus sampling) keeps the smallest set of highest-probability candidates whose cumulative probability reaches p, and top-k keeps a fixed number of the highest-scoring candidates.
| Parameter | What it controls | Effect of a lower value |
|---|---|---|
| Temperature | How concentrated the sampling distribution is | Probability concentrates on the leading candidates |
| Top-p | The cumulative probability retained for sampling | The retained candidate set can become smaller |
| Top-k | The maximum number of candidates retained | Fewer candidates remain eligible |
Some APIs use a special value to disable top-k filtering, so check the parameter definition before lowering it.
Adjust one parameter at a time: Lowering temperature and top-p can both reduce variation, so changing both makes it harder to identify the cause of a quality change. OpenAI's sampling guidance recommends changing one or the other.
The shift away from adjustable temperature
Temperature is becoming a less universal tuning control as newer hosted models prescribe more of their sampling behavior. Google's guidance moved from discouraging custom sampling parameters on Gemini 3.x to ignoring them on Gemini 3.6 Flash and later models. Anthropic's October 2026 API update removes the sampling parameters from requests altogether. OpenAI's GPT-6.2 guidance tells developers to omit temperature and top_p, and those models no longer accept the reasoning-effort value that previously allowed them. These changes make advice such as "set temperature to zero for extraction" conditional on the model and endpoint, rather than a general starting point.
The change concerns developer control over sampling, not necessarily the removal of temperature from generation. Anthropic specifies that requests without the removed parameters still use the defaults, including a temperature of 1.0, and that no other setting replaces the effect of a previously lowered temperature. Providers implement different restrictions, so the documented changes establish a trend toward fewer exposed sampling controls without establishing one shared reason for it.
For developers, this shifts the optimization work toward the instructions and evidence supplied to the model. An extraction task that returns inconsistent dates may need clearer field definitions, better examples, or validation against the source document. Supported reasoning-effort or thinking settings can also be evaluated, but they control reasoning computation and are not equivalent to a randomness slider.
Fixed sampling settings still leave room for incorrect or variable responses. Run repeated evaluations on representative cases to establish whether a prompt or model change improves reliability, and recheck those results when upgrading models. The table below shows where temperature remains available and where another approach is required.
Temperature support across current LLMs
As of 24 November 2026, temperature support depends on the exact model, API version, and reasoning configuration. A request may reject a custom value or accept it without applying it, so a successful API response alone does not confirm that temperature changed.
| Provider or model | Temperature support | Controls to evaluate |
|---|---|---|
| OpenAI GPT-6.2 | Not supported. OpenAI's GPT-6.2 guidance says to omit temperature, top_p, and top_logprobs, and both GPT-6.2 Astra and GPT-6.2 Sol reject a reasoning effort of none. | Prompt instructions and supported reasoning-effort settings |
| OpenAI GPT-6 and GPT-6.1 | Sampling parameters are supported only with reasoning effort set to none. GPT-6 Astra and GPT-6.1 Sol do not support none; GPT-6.1 Terra, GPT-6 Sol, and GPT-6 Luna do. | Prompt instructions and supported reasoning-effort settings |
| Anthropic Claude | API version 2026-10-21 rejects temperature, top_p, and top_k on every model, returning HTTP 400 even at a parameter's default value. On the earlier 2023-06-01 API, models that accept only the defaults, including Claude 4.7 and later, reject non-default values. | Prompt instructions and model-supported effort settings |
| Google Gemini 4 Argon | temperature, top_p, and top_k are ignored. Google's Gemini 3.6 migration guidance also documents sampling parameters as deprecated and ignored on that generation, and warns that future model generations return an HTTP 400 error for them. | Prompt instructions and supported thinking levels |
| Open-weight and earlier hosted models | Availability depends on the model and serving engine. Engines such as vLLM expose temperature and other sampling controls. | Temperature and other supported sampling parameters |
Omit restricted parameters instead of sending defaults: On an API version that rejects sampling parameters, setting temperature to 0 still sends the field and still returns an error. Remove the key from the request body or prompt configuration. Braintrust documents this case for Claude sampling parameter errors, including how to clear a stored Temperature, Top p, or Top k value from a saved prompt so framework or gateway defaults do not reintroduce it.
Model upgrades can change request behavior: A request that succeeded on one API version can fail on the next, or succeed while the model silently drops the field, so review parameter compatibility whenever the model, API version, or reasoning setting changes.
Fixed sampling still requires evaluation: Test prompts and supported reasoning settings against the same quality requirements, then repeat cases to measure output variation. Reasoning effort and thinking level change reasoning computation; a lower effort setting does not imply a lower sampling temperature.
Choosing an LLM temperature with repeated evals
A general temperature recommendation depends on the model, prompt, and task. Use a controlled evaluation to determine whether changing the supported default improves the application's results.
1. Confirm support for the exact request. Check the model, API version, and reasoning configuration. If temperature is ignored or rejected, choose a supported control to evaluate and define what improvement would justify changing it.
2. Define pass criteria and fix the scorers. Set a minimum pass rate and identify critical cases that must pass every trial. Use exact match for labels, schema checks plus field-level correctness for extraction, or an LLM-as-a-judge rubric for open-ended answers. Keep the judge model, prompt, and settings fixed throughout the comparison.
3. Build a representative dataset. Prompt test cases should include common production inputs, known failures, and difficult cases with reviewed expected outcomes.
4. Change one variable. Hold the model version, prompt, context, tool configuration, and output-token limit fixed. For a temperature comparison, test a small set within the supported range, such as the lowest value, the default, and a higher value where available.
5. Run fresh repeated trials. Bypass full-response caches and repeat each input under each setting. Three to five trials can provide an initial view of variation, with additional trials for unstable inputs or close decisions. Keep tool and retrieval inputs fixed when isolating sampling behavior.
6. Compare results by input and requirement. Check pass rates and regressions on critical cases alongside aggregate scores. Evaluate latency and cost as well, since different outputs can change token usage even when the model's token prices stay the same.
Change the production setting only when the candidate meets the quality requirements and improvement criteria set before testing. When results remain inconclusive, increase the trial count or retain the current validated configuration.
Also read: Set trial counts for non-deterministic output in a GitHub Actions eval pipeline
Testing temperature changes and model migrations in Braintrust
Tuning a supported temperature and moving to a model without that control require different comparisons. Braintrust keeps the tested configurations and evaluation results connected so engineering and product reviewers can assess both decisions against the same task requirements.
Compare candidates in a playground
Create tasks with the same prompt, model, and linked dataset, changing only each task's temperature. In a Braintrust playground, reviewers can compare outputs and scores side by side before selecting configurations for a recorded evaluation. Every task carries its own Params menu, which is where temperature is set, so an isolated temperature comparison keeps one model across all tasks and changes only that value. Keep unsupported parameters out of tasks that use models with fixed sampling.

The playground pictured above compares three models rather than three temperatures. The same side-by-side layout isolates temperature when every task selects the same model and differs only in the value set under Params.
To let reviewers sweep values without editing code, expose temperature as an eval parameter so the playground renders it as an editable field on the task. Playground runs overwrite their results on each run, so promote a configuration worth keeping before iterating further.
Product reviewers can use Loop to draft scorers from plain-language quality criteria, reducing the engineering work needed to add a task-specific check. Review the generated scorer before using it to compare candidates.
Worked example: tune temperature for invoice extraction
Suppose an application extracts an invoice number, due date, and total from supplier invoices. The current model supports temperature, and production requests use 0.2. Build a dataset with reviewed field values, including invoices with missing due dates and documents that show both a subtotal and a final total. Score schema validity separately from field correctness, and check that the application returns null when a required value is absent rather than inventing it.
Save the current configuration as the baseline. Compare temperature 0.2 with 0 and the model's documented default, where those are distinct supported values. Keep the prompt, model version, source documents, output schema, and scorers unchanged. Run fresh repeated trials for each invoice so the comparison captures whether a setting produces the correct fields consistently.
Select a candidate using the extraction requirements established before the test. If temperature 0 repeats the wrong subtotal while 0.2 sometimes returns the correct total, lower variation has not solved the task. Inspect those cases and test a clearer definition of the total in a separate prompt comparison. These are illustrative configurations, not measured results or recommended settings for every extraction model.
Test a migration away from the temperature parameter
Now suppose the team wants to adopt a model or API version that no longer accepts custom temperature. Use the validated production configuration as the baseline and run a migration candidate with temperature omitted. Keep the same invoice dataset, expected values, and scoring rules. Preserve the prompt and output contract where the new endpoint supports them, and record any compatibility changes required to execute the request.
When the existing model and API allow it, first run an additional candidate on the current model with temperature omitted. That comparison isolates the effect of returning to its default sampling configuration. Then evaluate the target model without temperature. If the migration changes the model or API as well as the parameter, the result measures the complete migration; it cannot establish that removing temperature alone caused a score change.
For the invoice task, compare field accuracy and repeated-trial reliability against the production baseline, with particular attention to missing dates and subtotal-versus-total errors. A successful API request only establishes compatibility. The candidate must also meet the existing quality requirements within acceptable cost and latency limits.
If the candidate regresses, test a targeted prompt change against the same failures, such as explicitly distinguishing the amount due from the subtotal. Evaluate a supported reasoning setting in a separate comparison if relevant. Neither change recreates a lower temperature; each must demonstrate its own effect on extraction quality. Promote the migration only after fresh trials meet the release criteria, and retain the previous configuration as the rollback option while it remains available.
Save the configuration and its results
Playground runs overwrite previous results, so promote a candidate to an experiment before further iteration. The resulting saved experiment is an immutable snapshot, preserving the run's inputs, outputs, scores, and configuration so the production decision can be checked against the original results.
Measure variation with fresh trials
Before measuring variance through Braintrust Gateway, set x-bt-use-cache to never. The default auto mode caches requests that set temperature=0 or a seed on supported paths, so a repeated trial can return a stored response instead of a fresh generation, hiding variation. Provider prompt caching can still reuse prompt computation while generating a fresh response.
For SDK evaluations, configure repeated trials with trial_count in Python or trialCount in TypeScript. Each input runs multiple times, and Braintrust aggregates results by bucketing cases with the same input value. Individual rows can override the global count, so unstable inputs can take extra trials while stable ones run once. Additional trials increase task execution and model-based scoring costs, so allocate them based on consistency requirements and observed variation.
Review regressions before changing production
Use experiment comparisons to align cases against a baseline, inspect score differences, and review changed outputs. Each comparison column reports a grade of Improvement, Regression, Tradeoff, or Tie against the base. To see the specific cases a change broke, select the regression count in a score column header, which filters the table to those rows. Weigh quality and token cost together before accepting a candidate that changes response length or behavior.

For repeated runs, group results by input to see aggregate statistics alongside individual trials. An improved average should still trigger review when a critical input becomes less reliable. Keep the accepted experiment as the baseline for later prompt, model, or parameter changes, with the task's pass criteria determining whether a candidate is ready for production.
Braintrust's free Starter plan includes 10,000 scores and 1 GB of processed data per month. Logs and playground data have 14-day retention, while saved experiments have separate retention of up to 365 days on all plans. Plan repeated-trial volume and result retention around the team's review requirements, since every trial scored adds to the monthly score count.
Compare temperature settings on your own dataset with Braintrust for free.
FAQs about LLM temperature
What is the best temperature for an LLM?
The best temperature is the supported value that consistently meets the task's quality requirements. A setting chosen for another model may behave differently, so keep the default as a comparison point and change it only when evaluations show a useful improvement without unacceptable regressions.
Does temperature 0 make LLM output deterministic?
Temperature 0 alone cannot guarantee identical API responses. Repeated runs show how stable a given request is, because the model version, inference implementation, and input context all affect the result.
Should I adjust temperature or top-p?
Start with one supported parameter and hold the other fixed. Temperature changes how strongly sampling favors leading candidates; top-p changes which candidates remain eligible. Compare the effect on your task before adding another sampling control.
Does a higher temperature increase hallucinations?
A higher temperature can introduce additional errors, but the effect on hallucinations depends on the model and task. Evaluate factual correctness or source support directly through hallucination evaluations, since reducing variation can also make an incorrect answer repeat consistently.
Why can't I set temperature on newer reasoning models?
Some providers restrict sampling parameters on newer models or API versions, so a custom temperature may be rejected, limited to a default, or ignored depending on the request. On those models, prompt instructions and reasoning-effort settings are the remaining levers, and the provider's migration guide documents which values each model accepts.
What is the default temperature for LLM APIs?
The default is API- and model-specific. OpenAI's general API reference lists 1, and Anthropic's migration guidance specifies 1.0. On some current models, including Claude 4.7 and later and Gemini 4 Argon, the default is also the only value in effect, since custom values are rejected or ignored.