A reasoning model can produce thinking text before it answers a prompt. The Ollama API keeps that text separate from the final answer, so an application can display the answer without mixing in the thinking trace.

Thinking support and controls vary by model. Qwen3 supports an on/off setting, while models such as GPT-OSS use named thinking levels. A model without thinking support cannot acquire it from a request flag.

A local Ollama server must already be running, with curl and Python 3 available. Reasoning can consume output tokens before an answer appears, so a response that stops at a token limit may contain thinking but no final answer.

Steps to use thinking with the Ollama API:

  1. Download the Qwen3 model with thinking support.
    $ ollama pull qwen3:0.6b

    qwen3:0.6b is a small thinking-capable model with a download of about 523 MB. Larger models need more memory and may take longer to answer.

  2. Check that the model lists thinking among its capabilities.
    $ ollama show qwen3:0.6b
    ##### snipped #####
      Capabilities
        completion
        tools
        thinking
            levels     false, true
            default    true
    ##### snipped #####

    The supported think values depend on the model. GPT-OSS uses levels such as low, medium, and high. The Ollama thinking documentation describes how /api/show exposes supported values and the default.

  3. Save a thinking-enabled chat response to thinking-response.json.
    $ curl --fail --silent --show-error http://localhost:11434/api/chat \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "qwen3:0.6b",
        "messages": [{"role": "user", "content": "What is 2 + 2? Reply with just the number."}],
        "think": true,
        "stream": false,
        "options": {"num_predict": 1024}
      }' --output thinking-response.json

    think: true requests thinking output. stream: false returns one JSON object after generation finishes, rather than a sequence of streamed objects. Thinking is returned in message.thinking and the answer in message.content.

  4. Verify that the response contains thinking and a completed final answer.
    $ python3 - <<'PYCODE'
    import json
    with open("thinking-response.json") as f:
        reply = json.load(f)
    message = reply["message"]
    assert reply["done"] and reply["done_reason"] == "stop", "Response incomplete"
    assert message.get("thinking") and message.get("content"), "Missing thinking or answer"
    print("Thinking characters:", len(message["thinking"]))
    print("Answer:", message["content"])
    PYCODE
    Thinking characters: 400
    Answer: 4

    The thinking length and answer wording vary between requests. done: true alone does not prove that an answer was completed. A done_reason of length indicates a token limit; if options.num_predict is set, a larger value or removing that limit allows more room for thinking and the answer. Applications should read message.content as the answer rather than parse the free-form thinking text.

Share this guide