Skip to main content
Lesson 9 of 16 · Mastering Prompts with Mistral

Temperature

Lesson 9 of 16 Updated November 2, 2026 Beginner
On this page
  1. Control the model’s creativity
  2. How temperature works
  3. Use temperature with the Mistral API
  4. Temperature 0 isn’t perfectly deterministic
  5. Adapt temperature to the context
  6. Experiment to find the right setting
  7. Key takeaways

Control the model’s creativity

So far, we’ve focused on your prompt content. Now we’re tackling another equally powerful lever: generation parameters. The first and most fundamental is temperature. It acts directly on the token probability distribution, determining whether the model behaves deterministically—producing predictable, nearly identical responses from one call to the next—or creatively, generating varied and sometimes surprising output. The same prompt sent with two different temperatures can yield a sober technical spec or a text that goes in unexpected directions. Understanding this parameter is essential to adapt Mistral model behavior to each use case.

How temperature works

Recall the basic mechanism: at each generation step, the model calculates a probability for every possible token, then selects one. Temperature modifies the shape of this distribution before selection. With a low temperature, close to 0, the distribution becomes “sharp”: the model focuses almost exclusively on the most probable tokens, making responses predictable and consistent. Ask it for the capital of Italy at temperature 0.1, and you’ll get nearly the same sentence every time.

With a high temperature, close to 1, the distribution is instead “flattened”: less probable tokens become accessible again, the model considers a wider range of possible sequences, and responses gain variety—sometimes at the cost of coherence. This is exactly what you want for brainstorming, and exactly what you want to avoid for data extraction. The following table summarizes the useful ranges.

Temperature Behavior Use Cases
0.0 Quasi-deterministic, always the most probable token Data extraction, classification, factual responses
0.1 - 0.3 Very predictable with slight variations Code generation, translation, technical documentation
0.4 - 0.6 Balance between coherence and variety Professional writing, reformulation, summarization
0.7 - 0.8 Creative with good coherence Brainstorming, marketing copy, storytelling
0.9 - 1.0 Very creative, surprising, sometimes incoherent Poetry, fiction, free ideation, exploration

Use temperature with the Mistral API

In the API, temperature is passed as a simple call parameter. Compare these two requests: the first expects a factual and stable response, the second seeks variety.

from mistralai.client import Mistral

client = Mistral(api_key="your-api-key")

# Low temperature: factual and deterministic response
response = client.chat.complete(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "What is the ROI formula?"}],
    temperature=0.1
)

# High temperature: creative and varied response
response = client.chat.complete(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "Invent a slogan for an organic coffee brand."}],
    temperature=0.8
)

Temperature 0 isn’t perfectly deterministic

A common misconception needs correcting right away: even with temperature=0, Mistral responses can show slight variations from one request to another. This happens due to hardware factors—floating-point calculations, GPU parallelization—that introduce tiny differences in rounding, enough to occasionally tip the choice of a token. So if you’re building automated tests or benchmarks where reproducibility is critical, don’t rely on temperature=0 alone: combine a low temperature with a code-side check that validates the substance of the response rather than its exact form.

Adapt temperature to the context

Let’s see how this setting plays out in three typical professional situations. For classification or extraction, you want the same customer review to always yield the same verdict: that’s temperature 0.

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "system", "content": "Classify the sentiment: positive, neutral, negative."},
        {"role": "user", "content": "The product works correctly."}
    ],
    temperature=0.0
)

For marketing copy, a too mechanical response would be bland; at 0.7, the model varies its phrasing while staying coherent—ideal for producing several hooks and choosing the best one.

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "system", "content": "You are a creative copywriter."},
        {"role": "user", "content": "Write 3 hooks for an email campaign."}
    ],
    temperature=0.7
)

For brainstorming finally, go up to 0.9: you accept that some ideas will be far-fetched, since you’ll filter them later. Ten leads with three excellent ones are better than five leads that are all reasonable and all already seen.

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "user", "content": "Propose 10 innovative feature ideas for a fitness app."}
    ],
    temperature=0.9
)

Experiment to find the right setting

There is no universally optimal temperature: the right value depends on your prompt, your model, and your tolerance for variability. The only reliable method is experimentation, conducted rigorously:

  1. Start with the model’s default value
  2. Test your prompt with 3-4 temperature values (0.1, 0.4, 0.7, 0.9)
  3. Compare results over 5-10 executions for each value
  4. Identify the value that offers the best coherence/variety ratio for your case
  5. Document the chosen setting with your prompt

This last point is often overlooked: a production prompt without its temperature documented is a half-specified prompt, which your colleague will reuse with a different setting and wonder why they get different results.

Key takeaways

  • Temperature controls the model’s level of creativity vs determinism
  • Low values (0-0.3) for factual tasks, high values (0.7-1.0) for creative tasks
  • Even at temperature 0, slight variations are possible
  • Experiment with several values to find the optimal setting
  • Always document the temperature used with your prompts in production