Local models are random by default: the same prompt can give a different reply each time. When you are testing a prompt, comparing two models or debugging a pipeline, that randomness is noise. A fixed seed removes it — the same prompt, seed and model should give the same reply.
Set the seed in the request or the Modelfile
In an API call, put the seed in the options object: for /api/generate or /api/chat, send "options": {"seed": 42}. The Modelfile reference lists seed as a valid parameter with the same meaning — setting it to a specific number makes the model generate the same text for the same prompt — so you can also bake it in with PARAMETER seed 42 and every chat with that model is seeded.
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Why is the sky blue?",
"stream": false,
"options": {"seed": 42, "temperature": 0}
}'
A seed only guarantees the same result when everything else is equal: same model, same prompt, same temperature and same context. Temperature 0 plus a fixed seed is the most reproducible combination, though even then a different model version or a different GPU can change the output. Note the seed and the model version next to any result you want to reproduce.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| Seed accepted | The API call with seed returns a reply | Check the options object shape |
| Same twice | The same prompt and seed give the same reply twice | Also fix the temperature at 0 |
| Different seed differs | A different seed gives a different reply | That confirms the seed is doing something |
| Model noted | The model name and version are recorded | A new version can change the output |
Expected result. We checked the Ollama API reference, which lists seed among the model parameters, and the Modelfile reference, which says a set seed makes the model generate the same text for the same prompt. We did not run a seeded request on this machine.
Limits
This guide covers seeding only. A seed does not guarantee identical output across model versions or hardware. We did not test any seeded call ourselves.
