Ollama now supports tool calling for popular local models including Llama 3.1, letting models invoke functions and APIs, browse the web, or run code interpreters to answer prompts. Developers provide a list of available tools via a new tools field in the chat API, and supported models respond with tool_calls that can be answered via a new tool message role. The OpenAI-compatible endpoint also gained tools support, easing migration for apps built against OpenAI's API. Planned future improvements include streaming tool calls and forced tool choice.

2m read timeFrom ollama.com
Post cover image
Table of contents
Tool callingSupported modelsOpenAI compatibilityExamplesFuture improvementsLet’s build together

Questions this post answers

How do I use tool calling with Llama 3.1 in Ollama?

Pass a list of tool definitions via the tools field when calling ollama.chat with the llama3.1 model. Each tool includes a function name, description, and parameter schema. The model responds with a tool_calls field in the message, and results can be sent back using a message with the role set to tool. Building agentic apps with local models? daily.dev tracks tool-calling updates across Ollama and other LLM runtimes.

Does Ollama's OpenAI-compatible API support function calling?

Yes, Ollama's OpenAI-compatible endpoint at /v1 supports the tools parameter, so existing code built against openai.chat.completions.create with tools can point to a local Ollama server by setting the base_url to http://localhost:11434/v1 and using a model like llama3.1 instead of an OpenAI model. daily.dev helps developers migrating between OpenAI and local model APIs stay on top of compatibility changes.

2 Impressions