Error: unknown flag: --temperature is what ollama run prints when a sampling option is passed as a command-line flag. ollama run has no flag for temperature; set it in a Modelfile with PARAMETER temperature 0.2, or in the options field of an API request. Both were run and are shown below.

For a one-off test from a script, send the request to the API with "options":{"temperature":0.2}. For a setting you want every time, build a model of your own from a two-line Modelfile and run that model instead.

The error

> ollama run qwen2.5:0.5b --temperature 0.2 "hello"
Error: unknown flag: --temperature

The command exits with code 1 and the model never answers. The flags that ollama run qwen2.5:0.5b --help listed on this version are --ask, --choice, --dimensions, --format, --hidethinking, --insecure, --keepalive, --level, --nowordwrap, --think, --truncate, --verbose and --voice.

Why it happens

The command line of ollama run takes a model name, an optional prompt and the flags in that list. Temperature is not in that list, and the client refused the whole command: the test server's request log had no new line after it. The option was accepted in two other places that were run: as a PARAMETER line in a Modelfile, and in the options object of /api/generate and /api/chat.

The fix

Through the API, with the body in a file:

> type body-temp.json
{"model":"qwen2.5:0.5b","prompt":"hello","stream":false,"options":{"temperature":0.2}}

> curl.exe -s -i http://127.0.0.1:15190/api/generate -d "@body-temp.json"
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sun, 22 Nov 2026 02:11:09 GMT
Content-Length: 525

{"model":"qwen2.5:0.5b","created_at":"2026-11-22T02:11:09.2718211Z","response":"Hello! How can I assist you today?","done":true,"done_reason":"stop","context":[151644,8948,198,2610,525,1207,16948,11,3465,553,54364,14817,13,1446,525,264,10950,17847,13,151645,198,151644,872,198,14990,151645,198,151644,77091,198,9707,0,2585,646,358,7789,498,3351,30],"total_duration":59600700,"load_duration":25109800,"prompt_eval_count":30,"prompt_eval_cached_count":29,"prompt_eval_duration":3747000,"eval_count":10,"eval_duration":23414000}

And the same option on /api/chat:

> type body-chat-temp.json
{"model":"qwen2.5:0.5b","stream":false,"messages":[{"role":"user","content":"hello"}],"options":{"temperature":0.2}}

> curl.exe -s -i http://127.0.0.1:15190/api/chat -d "@body-chat-temp.json"
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sun, 22 Nov 2026 02:22:35 GMT
Content-Length: 360

{"model":"qwen2.5:0.5b","created_at":"2026-11-22T02:22:35.0457025Z","message":{"role":"assistant","content":"Hello! How can I assist you today?"},"done":true,"done_reason":"stop","total_duration":5912006600,"load_duration":5642939500,"prompt_eval_count":30,"prompt_eval_cached_count":0,"prompt_eval_duration":207784000,"eval_count":10,"eval_duration":58458000}

With a Modelfile, which bakes the value into a model of your own:

> type Modelfile-temp
FROM qwen2.5:0.5b
PARAMETER temperature 0.2

> ollama create fix12-qwen-t02 -f Modelfile-temp
...
success

> ollama show fix12-qwen-t02 --parameters
temperature                    0.2

> ollama run fix12-qwen-t02 "hello"
Hello! How can I assist you today?

The interactive prompt of ollama run has a /set parameter command; typing it at the prompt was not captured here, because the interactive prompt could not be logged. What was tested: piping a file with /set parameter temperature 0.2 and /show parameters into ollama run qwen2.5:0.5b < session-set.txt did not run those commands. The model got them as text and answered with an explanation of all four lines of the file. So in scripts, use the API or a Modelfile.

How it was reproduced

Ollama 0.40.16 on Windows 11, with a test server of its own started by ollama serve with OLLAMA_HOST=127.0.0.1:15190 and OLLAMA_MODELS set to a scratch folder, and the model qwen2.5:0.5b pulled into that folder through that server (the pull requests are in its request log). Commands ran in cmd.exe, sent from PowerShell as cmd /c "<line> 2>&1", with the same OLLAMA_HOST set, which is why the curl line uses port 15190 instead of the default 11434. The port, the model name fix12-qwen-t02 and the files body-temp.json, body-chat-temp.json, Modelfile-temp and session-set.txt are the test's own. The spinner and terminal control characters of the console output are left out above.

Frequently asked

How do I set the temperature in ollama run?
There is no --temperature flag on Ollama 0.40.16. In the test, a model of your own created from a Modelfile with PARAMETER temperature 0.2 carried the value, and ollama show --parameters listed it.
How do I pass temperature to the Ollama API?
Put it in the options object of the request body, for example "options":{"temperature":0.2}, on /api/generate or /api/chat.
Does /set parameter work when I pipe input into ollama run?
Not in the test here. A file piped into ollama run reached the model as one prompt, and the /set and /show lines in it were answered as text instead of being run.

More decoded errors in the Fixes category. If the option you passed has the wrong type in an API request, see the option type post.