OllamaSharp 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package OllamaSharp --version 1.0.3
                    
NuGet\Install-Package OllamaSharp -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OllamaSharp" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OllamaSharp" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="OllamaSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OllamaSharp --version 1.0.3
                    
#r "nuget: OllamaSharp, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OllamaSharp@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OllamaSharp&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=OllamaSharp&version=1.0.3
                    
Install as a Cake Tool

OllamaSharp 🦙

OllamaSharp is a .NET binding for the Ollama API, making it easy to interact with Ollama using your favorite .NET languages.

Features

  • Intuitive API client: Set up and interact with Ollama in just a few lines of code.
  • Support for various Ollama operations: Including streaming completions (chatting), listing local models, pulling new models, show model information, creating new models, copying models, deleting models, pushing models, and generating embeddings.
  • Real-time streaming: Stream responses directly to your application.
  • Progress reporting: Get real-time progress feedback on tasks like model pulling.

Usage

Here's a simple example to get you started:

// set up the client
var uri = new Uri("http://localhost:11434");
var ollama = new OllamaApiClient(uri);

// list all local models
var models = await ollama.ListLocalModels();

// stream a completion and write to the console
// keep reusing the context to keep the chat topic going
ConversationContext context = null;
context = await ollama.StreamCompletion("How are you today?", "llama2", context, stream => Console.Write(stream.Response));

// pull a model and report progress
await ollama.PullModel("mistral", status => Console.WriteLine($"({status.Percent}%) {status.Status}"));

Credits

Icon and name were reused from the amazing Ollama project.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

NuGet packages (23)

Showing the top 5 NuGet packages that depend on OllamaSharp:

Package Downloads
Microsoft.SemanticKernel.Connectors.Ollama

Semantic Kernel connector for Ollama. Contains services for text generation, chat completion and text embeddings.

Microsoft.KernelMemory.AI.Ollama

Provide access to Ollama LLM models in Kernel Memory to generate embeddings and text

CommunityToolkit.Aspire.Hosting.Ollama

An Aspire integration leveraging the Ollama container with support for downloading a model on startup.

CommunityToolkit.Aspire.OllamaSharp

A .NET Aspire client integration for the OllamaSharp library.

EnergyAssembly

Package Description

GitHub repositories (15)

Showing the top 15 popular GitHub repositories that depend on OllamaSharp:

Repository Stars
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
testcontainers/testcontainers-dotnet
A library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions.
dotnet/extensions
This repository contains a suite of libraries that provide facilities commonly needed when creating production-ready applications.
microsoft/kernel-memory
RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.
microsoft/Generative-AI-for-beginners-dotnet
Five lessons, learn how to really apply AI to your .NET Applications
microsoft/ai-dev-gallery
An open-source project for Windows developers to learn how to add AI with local models and APIs to Windows apps.
getcellm/cellm
Use LLMs in Excel formulas
mixcore/mix.core
🚀 A future-proof enterprise web CMS supporting both headless and decoupled approaches. Build any type of app with customizable APIs on ASP.NET Core/.NET Core. Completely open-source and designed for flexibility.
dotnet/ai-samples
CommunityToolkit/Aspire
A community project with additional components and extensions for .NET Aspire
anobaka/Bakabase
A local media manager for all types of files. 二次元老司机专用的本地媒体文件管理器,支持管理和处理音视频、本子、图集、小说、哔哩哔哩视频、游戏甚至mod等各类资源
PowerShell/AIShell
An interactive shell to work with AI-powered assistance providers
axzxs2001/Asp.NetCoreExperiment
原来所有项目都移动到**OleVersion**目录下进行保留。新的案例装以.net 5.0为主,一部分对以前案例进行升级,一部分将以前的工作经验总结出来,以供大家参考!
afrise/MCPSharp
MCPSharp is a .NET library that helps you build Model Context Protocol (MCP) servers and clients - the standardized API protocol used by AI assistants and models.
lindexi/lindexi_gd
博客用到的代码
Version Downloads Last Updated
5.4.5 0 9/19/2025
5.4.4 1,159 9/15/2025
5.4.3 199 9/15/2025
5.4.2 254 9/15/2025
5.4.1 1,672 9/11/2025
5.3.12 764 9/10/2025
5.3.11 300 9/10/2025
5.3.10 303 9/10/2025
5.3.9 302 9/10/2025
5.3.8 303 9/10/2025
5.3.7 304 9/10/2025
5.3.6 11,977 8/20/2025
5.3.5 16,641 8/18/2025
5.3.4 6,823 8/2/2025
5.3.3 4,904 7/22/2025
5.3.2 899 7/22/2025
5.3.1 1,500 7/19/2025
5.2.10 3,156 7/14/2025
5.2.9 3,710 7/13/2025
5.2.8 2,371 7/10/2025
5.2.7 3,073 7/7/2025
5.2.6 1,231 7/4/2025
5.2.5 538 7/4/2025
5.2.4 533 7/4/2025
5.2.3 32,992 6/23/2025
5.2.2 20,836 5/30/2025
5.2.1 614 5/30/2025
5.1.20 629 5/30/2025
5.1.19 3,600 5/23/2025
5.1.18 15,345 5/19/2025
5.1.17 1,084 5/16/2025
5.1.16 1,285 5/13/2025
5.1.15 465 5/13/2025
5.1.14 28,516 5/6/2025
5.1.13 10,950 4/10/2025
5.1.12 151,214 4/10/2025
5.1.11 4,075 4/9/2025
5.1.10 2,020 4/7/2025
5.1.9 4,333 3/27/2025
5.1.8 293 3/27/2025
5.1.7 80,003 3/14/2025
5.1.6 287 3/14/2025
5.1.5 1,114 3/13/2025
5.1.4 2,887 3/5/2025
5.1.3 564 3/4/2025
5.1.2 24,195 2/24/2025
5.1.1 1,250 2/21/2025
5.1.0 273 2/21/2025
5.0.7 36,067 2/17/2025
5.0.6 31,411 2/3/2025
5.0.5 1,405 1/31/2025
5.0.4 4,098 1/27/2025
5.0.3 3,427 1/22/2025
5.0.2 8,773 1/15/2025
5.0.1 490 1/15/2025
4.0.22 10,178 1/10/2025
4.0.21 220 1/9/2025
4.0.20 473 1/8/2025
4.0.19 152 1/8/2025
4.0.18 526 1/8/2025
4.0.17 37,542 1/3/2025
4.0.16 195 1/3/2025
4.0.15 198 1/3/2025
4.0.14 212 1/3/2025
4.0.13 189 1/3/2025
4.0.12 187 1/3/2025
4.0.11 34,638 12/9/2024
4.0.10 187 12/9/2024
4.0.9 1,943 12/2/2024
4.0.8 35,496 11/22/2024
4.0.7 4,216 11/13/2024
4.0.6 14,917 11/7/2024
4.0.5 1,408 11/5/2024
4.0.4 666 11/4/2024
4.0.3 31,994 10/30/2024
4.0.2 365 10/29/2024
4.0.1 2,323 10/26/2024
4.0.0-preview.10 141 10/23/2024
4.0.0-preview.9 97 10/21/2024
4.0.0-preview.8 121 10/17/2024
3.0.15 5,538 10/21/2024
3.0.14 11,041 10/16/2024
3.0.13 156 10/16/2024
3.0.12 21,812 10/14/2024
3.0.11 1,530 10/9/2024
3.0.10 26,311 10/4/2024
3.0.9 177 10/4/2024
3.0.8 17,913 9/26/2024
3.0.7 34,955 9/12/2024
3.0.6 1,280 9/11/2024
3.0.5 849 9/11/2024
3.0.4 26,747 9/6/2024
3.0.3 177 9/6/2024
3.0.2 634 9/5/2024
3.0.1 23,589 9/2/2024
3.0.0 2,215 8/26/2024
2.1.3 2,770 8/23/2024
2.1.2 2,701 8/19/2024
2.1.1 4,484 8/5/2024
2.0.15 339 8/5/2024
2.0.14 154 8/3/2024
2.0.13 2,002 7/29/2024
2.0.12 179 7/28/2024
2.0.11 248 7/28/2024
2.0.10 5,111 7/12/2024
2.0.9 156 7/12/2024
2.0.8 187 7/12/2024
2.0.7 1,833 7/10/2024
2.0.6 3,186 6/25/2024
2.0.5 172 6/25/2024
2.0.4 632 6/24/2024
2.0.3 162 6/24/2024
2.0.2 224 6/24/2024
2.0.1 4,106 6/5/2024
1.1.13 644 6/5/2024
1.1.12 630 6/4/2024
1.1.11 356 6/2/2024
1.1.10 1,362 5/31/2024
1.1.9 7,331 5/15/2024
1.1.8 1,425 5/10/2024
1.1.7 180 5/10/2024
1.1.5 174 5/10/2024
1.1.4 310 5/10/2024
1.1.3 178 5/10/2024
1.1.2 172 5/10/2024
1.1.1 3,729 3/27/2024
1.1.0 2,304 1/8/2024
1.0.4 360 12/27/2023
1.0.3 434 11/30/2023
1.0.2 443 11/5/2023
1.0.1 276 10/16/2023
1.0.0 2,192 10/16/2023