Skip to main content
Ollama supports tool calling (also known as function calling) which allows a model to invoke tools and incorporate their results into its replies.

Calling a single tool

Invoke a single tool and include its response in a follow-up request. Also known as “single-shot” tool calling.
Generate a response with a single tool result

Parallel tool calling

Request multiple tool calls in parallel, then send all tool responses back to the model.
Generate a response with multiple tool results

Multi-turn tool calling (Agent loop)

An agent loop allows the model to decide when to invoke tools and incorporate their results into its replies. It also might help to tell the model that it is in a loop and can make multiple tool calls.

Tool calling with streaming

When streaming, gather every chunk of thinking, content, and tool_calls, then return those fields together with any tool results in the follow-up request.
This loop streams the assistant response, accumulates partial fields, passes them back together, and appends the tool results so the model can complete its answer.

Using functions as tools with Ollama Python SDK

The Python SDK automatically parses functions as a tool schema so we can pass them directly. Schemas can still be passed if needed.