1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
19 small wins to finish your pathNext lesson →
Seeds
A seed is a number that fixes the random choices made while sampling, so the same request can give the same answer again; hosted APIs treat it as a best effort.
Last updated: 30 Sep, 2026 · groq 1.7 · gpt-oss-120b on Groq
At any temperature above 0, each token is drawn at random. A seed makes the draws repeat, which helps when you change a prompt and want to know that the change, not chance, moved the answer.
Syntax: client.chat.completions.create(..., temperature=1, seed=42).
Three slogans with no seed
from groq import Groq
client = Groq() # reads GROQ_API_KEY from the environment
prompt = [{"role": "user", "content": "Write a six-word slogan for a small online tea shop."}]
for run in range(3):
response = client.chat.completions.create(
model="openai/gpt-oss-120b", messages=prompt, temperature=1
)
print(run, response.choices[0].message.content)Output
0 Steeped delights delivered to your doorstep. 1 Sip serenity, delivered to your doorstep. 2 Sip serenity, delivered to your doorstep.
The first slogan differs from the other two. Same prompt, same model, same settings: the difference came from the random draws.
Three slogans with seed=42
This continues the same file:
for run in range(3):
response = client.chat.completions.create(
model="openai/gpt-oss-120b", messages=prompt, temperature=1, seed=42
)
print(run, response.choices[0].message.content)Output
0 Steeped online, delivered to your door. 1 Steeped online, delivered to your door. 2 Steeped online, delivered to your door.
- All three slogans are identical with the seed set.
- The seed fixes the draws, not the answer. A different seed would give a different, equally repeatable slogan.
Seed vs temperature 0
seed=42 | temperature=0 | |
|---|---|---|
| Randomness | Still random, but repeatable | None: the likeliest token each time |
| Variety across seeds | Yes | No |
| Guaranteed across time | No, best effort | No, but close in practice |
When a seed helps
- Comparing two prompts at the same temperature, so only the prompt differs.
- Reproducing a surprising answer while you debug it.
- Tests that expect a sampled answer to stay the same over a short time.
Watch out. Groq's documentation describes the seed as a best effort. A change on the provider's side, such as new hardware or a new model version, can change the answer for the same seed. Store answers you need to keep instead of generating them again.
Related
- Previous: Max tokens and finish_reason
- Next: Chat messages and templates
- Reference: Groq chat completions API
Try it yourself
- Run the no-seed example twice and compare the slogans.
- Change
seed=42toseed=7. Are the three slogans still identical to each other? - Set
temperature=0without a seed and run it three times.
This is what real progress feels like.