Web Asset House Guides
Local AI

Ollama Tool Calling, Explained: Let a Local Model Use Your Functions

By Web Asset House Studio ·

Note: Some future links on this site may be affiliate links. We never claim hands-on testing; guides are researched from the public sources listed in each article.

How we wrote this: A summary of Ollama's official Tool calling documentation (linked below), checked October 29, 2026. Examples follow the docs; tool support depends on the model, so check the model's page before you rely on it.

A model on its own can only produce text. Tool calling (also called function calling) lets it ask your program to run something, such as looking up a temperature, searching a database or reading a file, and then use the result in its answer. Ollama's Tool calling documentation describes it as a way to let a model "invoke tools and incorporate their results into its replies."

The important part to understand first: the model never runs your code. It returns a request ("call get_temperature with city = New York"). Your program decides whether to run it, runs it, and sends the result back.

Pick a model that supports tools

Only some models are trained for this. Ollama's model library has a tools filter. The docs' examples use qwen3. If you haven't installed Ollama yet, our beginner walkthrough covers it.

How one tool call works

The flow takes two requests to /api/chat.

1. Describe your tool and ask the question. Each tool is described with a name, a description and a JSON schema for its parameters:

"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"}
      }
    }
  }
}]

2. Read the model's tool call. Instead of a normal answer, the assistant message comes back with tool_calls, naming the function and its arguments (for example, {"city": "New York"}).

3. Run the tool yourself and send the result back. Add the assistant's message and a new message with role tool, the tool_name, and the result as content (the docs' example uses "22°C"). Then call /api/chat again with the full message list. The model now writes its final reply using that result.

With the official Python library, the docs show a shortcut: you can pass a normal Python function in the tools list, and the library builds the schema from its signature and docstring.

Parallel calls and the agent loop

The docs cover two patterns beyond a single call:

If you stream responses, the docs say to gather every chunk of thinking, content and tool_calls, then pass those fields back together with the tool results in the follow-up request.

Safety rules before you connect real tools

Tool calling becomes risky the moment a tool can change something: send an email, delete a file, move money or call another service. Practical rules:

When to use structured outputs instead

If you only need the model to return data in a fixed shape (for example, fields pulled from an email), you may not need tools at all. Structured outputs constrain the reply to a JSON schema without any back-and-forth.

Sources

← All Local AI guides · All guides