<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt" -->

---
title: Ollama Python library 0.4 with function calling...
description: Ollama Python library version 0.4 lets developers pass regular Python functions directly as tools for models to call, automatically generating the JSON schema...
canonical: https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Ollama Python library 0.4 with function calling improvements · Ollama Blog | daily.dev
og:description: Ollama Python library version 0.4 lets developers pass regular Python functions directly as tools for models to call, automatically generating the JSON schema...
og:url: https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt
og:image: https://api.daily.dev/og/posts/J6PH3TRbT.png
og:image:alt: Ollama Python library 0.4 with function calling improvements · Ollama Blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Ollama Python library 0.4 with function calling improvements · Ollama Blog

**[Ollama](https://daily.dev/sources/ollama)** · 3 min read · 0 upvotes · 0 comments

## Summary

Ollama Python library version 0.4 lets developers pass regular Python functions directly as tools for models to call, automatically generating the JSON schema via Pydantic and docstring parsing instead of requiring manual schema definitions. The release also adds full typing support and updated examples, and existing functions from libraries like requests can be passed as tools too.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://ollama.com/blog/functions-as-tools>

## Questions this post answers

### How do I pass a Python function as a tool to Ollama in the Python library?

In Ollama Python library version 0.4, you define a regular Python function with type annotations and a Google-style docstring, then pass it directly in the tools list of ollama.chat, e.g. tools=[add_two_numbers]. The library uses Pydantic and docstring parsing to automatically generate the JSON schema, which previously had to be written manually.

_Developers wiring up tool-calling agents can follow function-calling changes like this on daily.dev._

### Can I use existing library functions like requests.request as tools with Ollama?

Yes, as of Ollama Python library 0.4, functions from existing Python libraries and SDKs can be passed as tools without modification. For example, requests.request can be passed directly in the tools list, and the model's returned arguments (like method and url) can be used to call it and fetch web content.

_Anyone building LLM agents that call external SDKs can track updates like this on daily.dev._

### How does Ollama Python library generate JSON schema for tool functions automatically?

It uses Pydantic combined with docstring parsing to inspect a function's type annotations and Google-style docstring, then builds a JSON schema object describing the function name, description, parameter types, and required fields. This removes the need to manually write the tool schema that was previously required in earlier versions of the library.

_Developers automating tool schemas for LLM calls can follow library changes like this on daily.dev._

## Similar posts on daily.dev

- [LLM Basics: Ollama Function Calling](https://daily.dev/posts/llm-basics-ollama-function-calling-1dpxl1yku) · Planet Python · 1 upvotes · 0 comments
- [How to Integrate Local LLMs With Ollama and Python – Real Python](https://daily.dev/posts/how-to-integrate-local-llms-with-ollama-and-python-real-python-akyr0sngy) · Real Python · 1 upvotes · 0 comments
- [Ollama for JavaScript Developers](https://daily.dev/posts/ollama-for-javascript-developers-m7eti7jpi) · SitePoint · 0 upvotes · 0 comments
- [How to Get Started With Ollama – Real Python](https://daily.dev/posts/how-to-get-started-with-ollama-real-python-jnzenkuau) · Real Python · 1 upvotes · 0 comments
- [How to Build CLI Agents with Python & Ollama](https://daily.dev/posts/how-to-build-cli-agents-with-python-ollama-ee7zc8teg) · Towards Data Science · 2 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#llm](https://daily.dev/tags/llm), [#ollama](https://daily.dev/tags/ollama)

[View this post on daily.dev](https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Ollama Python library 0.4 with function calling improvements · Ollama Blog","url":"https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt"},"datePublished":"2026-08-23T12:23:51.855Z","dateModified":"2026-08-23T12:52:44.356Z","description":"Ollama Python library version 0.4 lets developers pass regular Python functions directly as tools for models to call, automatically generating the JSON schema...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/03fb1a10ef158f8986c9778334c2af42?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/03fb1a10ef158f8986c9778334c2af42?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Ollama","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ollama","logo":"https://media.daily.dev/image/upload/s--dRYYkBCj--/f_auto,q_auto/v1787487632/logos/ollama-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/ollama"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,llm,ollama","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ollama","item":"https://daily.dev/sources/ollama"},{"@type":"ListItem","position":3,"name":"Ollama Python library 0.4 with function calling improvements · Ollama Blog"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/ollama-python-library-0-4-with-function-calling-improvements-ollama-blog-j6ph3trbt#faq","mainEntity":[{"@type":"Question","name":"How do I pass a Python function as a tool to Ollama in the Python library?","acceptedAnswer":{"@type":"Answer","text":"In Ollama Python library version 0.4, you define a regular Python function with type annotations and a Google-style docstring, then pass it directly in the tools list of ollama.chat, e.g. tools=[add_two_numbers]. The library uses Pydantic and docstring parsing to automatically generate the JSON schema, which previously had to be written manually. Developers wiring up tool-calling agents can follow function-calling changes like this on daily.dev."}},{"@type":"Question","name":"Can I use existing library functions like requests.request as tools with Ollama?","acceptedAnswer":{"@type":"Answer","text":"Yes, as of Ollama Python library 0.4, functions from existing Python libraries and SDKs can be passed as tools without modification. For example, requests.request can be passed directly in the tools list, and the model's returned arguments (like method and url) can be used to call it and fetch web content. Anyone building LLM agents that call external SDKs can track updates like this on daily.dev."}},{"@type":"Question","name":"How does Ollama Python library generate JSON schema for tool functions automatically?","acceptedAnswer":{"@type":"Answer","text":"It uses Pydantic combined with docstring parsing to inspect a function's type annotations and Google-style docstring, then builds a JSON schema object describing the function name, description, parameter types, and required fields. This removes the need to manually write the tool schema that was previously required in earlier versions of the library. Developers automating tool schemas for LLM calls can follow library changes like this on daily.dev."}}]}
```

