---
source: https://iinventedlight.com/library/notes/ao-tools-ollama-tool-calling.md
title: "Tool calling with local models: Ollama and llama.cpp"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (ollama/ollama (GitHub)); MIT (ggml-org/llama.cpp (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: ollama/ollama (GitHub), Tool calling (Ollama docs), MIT (https://raw.githubusercontent.com/ollama/ollama/main/LICENSE). Copyright (c) Ollama; ggml-org/llama.cpp (GitHub), Function calling (llama.cpp docs), MIT (https://raw.githubusercontent.com/ggml-org/llama.cpp/master/LICENSE). Copyright (c) 2023-2026 The ggml authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: tool calling"
tags: [ollama, llama-cpp, tool-calling, local-models]
client: Librarian
sources:
  - id: S1
    title: "Tool calling (Ollama docs)"
    publisher: ollama/ollama (GitHub)
    url: https://github.com/ollama/ollama/blob/main/docs/capabilities/tool-calling.mdx
    accessed: 2026-11-16
    license: "MIT"
  - id: S2
    title: "Function calling (llama.cpp docs)"
    publisher: ggml-org/llama.cpp (GitHub)
    url: https://github.com/ggml-org/llama.cpp/blob/master/docs/function-calling.md
    accessed: 2026-11-16
    license: "MIT"
---
# Tool calling with local models: Ollama and llama.cpp
**Answer:** An Ollama `/api/chat` request includes `tools`, each a `function` with a `name`, a `description` and `parameters` (`type`, `required`, `properties`). The reply carries `tool_calls`; you run the function and send its result back as a `"role": "tool"` message with `tool_name` and `content`.

## llama.cpp server

- Function calling needs the `--jinja` flag.
- It is supported for all models: native tool call formats exist for families such as Llama 3.1/3.3, Functionary, Hermes 2/3 and Qwen 2.5, and others fall back to a generic handler (`Chat format: Generic` in the logs).
- The docs note that generic support may use more tokens and be less efficient than native formats.
- Use `--chat-template-file` to override the template when appropriate.

## See also

- [ao-tools-parallel-tool-calls](https://iinventedlight.com/library/notes/ao-tools-parallel-tool-calls/)
- [ao-idlehw-ollama-context-and-keepalive](https://iinventedlight.com/library/notes/ao-idlehw-ollama-context-and-keepalive/)
- [ao-idlehw-openai-compatible-servers](https://iinventedlight.com/library/notes/ao-idlehw-openai-compatible-servers/)
- [ao-tools-vllm-tool-parsers](https://iinventedlight.com/library/notes/ao-tools-vllm-tool-parsers/)

## Claims

- id: C1
  claim: Ollama tool results use the tool role.
  source: S1
  evidence: "{\"role\": \"tool\", \"tool_name\": \"get_temperature\", \"content\": \"22°C\"}"

- id: C2
  claim: Generic handlers may cost more tokens.
  source: S2
  evidence: "Generic support may consume more tokens and be less efficient"

- id: C3
  claim: llama.cpp needs the jinja flag.
  source: S2
  evidence: "--jinja` flag"

## Sources

- [S1] Tool calling (Ollama docs). ollama/ollama (GitHub). https://github.com/ollama/ollama/blob/main/docs/capabilities/tool-calling.mdx . License: MIT. Accessed 2026-11-16.

- [S2] Function calling (llama.cpp docs). ggml-org/llama.cpp (GitHub). https://github.com/ggml-org/llama.cpp/blob/master/docs/function-calling.md . License: MIT. Accessed 2026-11-16.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: ollama/ollama (GitHub), Tool calling (Ollama docs), MIT (https://raw.githubusercontent.com/ollama/ollama/main/LICENSE). Copyright (c) Ollama; ggml-org/llama.cpp (GitHub), Function calling (llama.cpp docs), MIT (https://raw.githubusercontent.com/ggml-org/llama.cpp/master/LICENSE). Copyright (c) 2023-2026 The ggml authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
