Thinking and vision models

Ollama · Advanced · 12 min

Reasoning and image understanding open up harder tasks, but they change speed, cost and how you read responses.

Thinking models can reason step by step before answering, which helps with maths, logic and planning. Ollama separates the reasoning from the final answer:

  • In the Python library and REST API, set think=True. The reasoning arrives in message.thinking and the answer in message.content.
  • Some models accept named levels instead of true/false, such as think="low", "medium" or "high" for gpt-oss. The model's details (/api/show) list which values it supports; others only support on or off.
  • In the terminal: ollama run MODEL --think, or --hidethinking to keep the reasoning out of the output. In a chat, /set think and /set nothink toggle it.

Thinking costs time: the model may write hundreds of reasoning tokens before the answer starts. Use it when quality matters more than speed, and switch it off for simple tasks. When streaming, thinking chunks come first; show them separately or hide them. Don't treat the reasoning text as a reliable explanation of how the answer was produced.

Vision models understand images: describe photos, read screenshots, extract text from receipts. Check for the vision capability with ollama show. Send images:

  • In the terminal: put the image file path in the prompt.
  • In Python: {"role": "user", "content": "What is in this picture?", "images": ["photo.jpg"]}. Paths, raw bytes or base64 strings are accepted.
  • In the REST API: base64-encoded strings in the message's images list.

Images use many tokens, so they need more context and memory. Vision can be combined with structured outputs, for example to extract receipt fields into a schema.

Example

from ollama import chat

# Thinking: reasoning and answer arrive in separate fields
r = chat(model="qwen3",
         messages=[{"role": "user", "content": "A bat and a ball cost $1.10 in total. "
                    "The bat costs $1.00 more than the ball. How much is the ball?"}],
         think=True)
print("THINKING:", r.message.thinking[:80], "...")
print("ANSWER:", r.message.content)          # The ball costs $0.05.

# Some models take a level instead of True/False
r2 = chat(model="gpt-oss", think="low",
          messages=[{"role": "user", "content": "Is 221 a prime number?"}])

# Vision: attach images to a user message
v = chat(model="gemma4", messages=[{
    "role": "user",
    "content": "List the items and the total on this receipt.",
    "images": ["receipt.jpg"],                # file path, bytes or base64
}])
print(v.message.content)

Remember

  • think=True (or a level) puts reasoning in message.thinking
  • Thinking improves hard tasks but adds latency; turn it off for simple ones
  • Vision models take images via images in a user message

Watch out for

  • Displaying the thinking field to end users as the answer, or parsing it as if it were the final output.

Check yourself

  1. With think=True, where is the final answer in the Python library's response?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.ollama.com/capabilities/thinking