Mac tip: call local tools from an Ollama model with tool calling

Mac mini on a desk next to Studio Display running Pro Tools

A chat reply is only text. Tool calling lets a local Ollama model ask your Mac to run a function, then finish the answer with the real result. The official demo is a get_temperature helper. The model does not invent the weather. It requests the tool, your script runs it, and you send the number back.

This tip assumes Ollama already runs on Apple silicon. If not, start with our Ollama setup on Apple silicon. Keep the server on http://localhost:11434. Tools execute on your machine, not in a cloud agent.

Pull a model that supports tools

Ollama's tool-calling doc uses qwen3 in every example. Pull that first:

ollama pull qwen3

Not every model on your disk can return tool_calls. The older blog post points at the Tools category on ollama.com/library. Check the model page before you wire a big script. If the reply has no tool_calls field, try another model that lists tools, or pull again so you are not on a stale tag.

Single-shot curl to /api/chat

The shortest path is a POST to the local chat API. Send a tools array. Each item is type: function plus a name, a short description, and a JSON schema for the parameters. This matches the doc's New York temperature example:

curl -s http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{
  "model": "qwen3",
  "messages": [{"role": "user", "content": "What is the temperature in New York?"}],
  "stream": false,
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_temperature",
      "description": "Get the current temperature for a city",
      "parameters": {
        "type": "object",
        "required": ["city"],
        "properties": {
          "city": {"type": "string", "description": "The name of the city"}
        }
      }
    }
  }]
}'

Read message.tool_calls in the JSON reply. Run that function on the Mac. Then POST again with three message roles in order: the original user line, the assistant message that holds the tool call, and a role: tool message with tool_name set to get_temperature and content set to the result string, for example 22°C. The second reply is the final answer in plain text.

Mac mini next to a Studio Display running Adobe Photoshop
Photo: Apple

Python: pass functions in tools=

Install or refresh the SDK with pip install ollama -U. In Python you can hand the live function to tools=[...]. The client builds the schema from the docstring and type hints. A short version of the doc sample:

from ollama import chat

def get_temperature(city: str) -> str:
  """Get the current temperature for a city
  Args:
    city: The name of the city
  """
  temperatures = {"New York": "22°C", "London": "15°C", "Tokyo": "18°C"}
  return temperatures.get(city, "Unknown")

messages = [{"role": "user", "content": "What is the temperature in Tokyo?"}]
response = chat(model="qwen3", messages=messages, tools=[get_temperature], think=True)
messages.append(response.message)
if response.message.tool_calls:
  call = response.message.tool_calls[0]
  result = get_temperature(**call.function.arguments)
  messages.append({"role": "tool", "tool_name": call.function.name, "content": str(result)})
  final = chat(model="qwen3", messages=messages, tools=[get_temperature], think=True)
  print(final.message.content)

When the stub returns Tokyo's value, you might see the phrase Kitchen thermometer reads 18C on the counter in your own logging before the model writes the spoken answer. That string is yours. The model only sees the tool content you put in the next message.

If you already use Ollama structured outputs for JSON shapes, keep that path for fixed records. Tool calling is for side effects and live lookups.

Parallel calls, and what stays on the Mac

One assistant turn can return several tool_calls. The doc's parallel sample asks for weather in New York and London, and the model may emit four calls: temperature and conditions for each city. Loop them, append one role: tool message per result, then chat again.

Apps that talk through Ollama's OpenAI-compatible API can send tools the same way. For VS Code, our note on wiring Continue to a local Ollama model is the chat side. Tool calling still needs your own handler that runs the function and posts the tool role back.

Privacy is the point of staying local. The function runs on your Mac. Prompt text and tool results never need a ChatGPT or Claude cloud agent unless you choose that. Leave Ollama bound to localhost unless you know why you opened it.

Photo: Apple

Source: Ollama docs (Tool calling); ollama.com/blog/tool-support; Apple Newsroom (Mac mini with M6 and M5 Pro, August 25, 2026)

Previous Article Mac fix: login password rejected or forgotten, reset from the login window or Recovery