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
--jinjaflag. - 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: Genericin the logs). - The docs note that generic support may use more tokens and be less efficient than native formats.
- Use
--chat-template-fileto override the template when appropriate.
See also
- ao-tools-parallel-tool-calls
- ao-idlehw-ollama-context-and-keepalive
- ao-idlehw-openai-compatible-servers
- 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.
License: CC-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.
Cite this
iinventedlight. 2026. "Tool calling with local models: Ollama and llama.cpp." iinventedlight Library, iil:note:01kp3zsa, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-tools-ollama-tool-calling/. License: CC-BY-4.0.
@misc{iil_note_01kp3zsa,
author = {{iinventedlight}},
title = {{Tool calling with local models: Ollama and llama.cpp}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/ao-tools-ollama-tool-calling/},
note = {Permanent ID iil:note:01kp3zsa. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-tools-ollama-tool-calling.md.