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.
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.
// Install OllamaSharp as a Cake Addin
#addin nuget:?package=OllamaSharp&version=1.0.3

// Install OllamaSharp as a Cake Tool
#tool nuget:?package=OllamaSharp&version=1.0.3                

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on OllamaSharp:

Package Downloads
Microsoft.KernelMemory.AI.Ollama

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

Microsoft.SemanticKernel.Connectors.Ollama

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

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 (6)

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

Repository Stars
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
microsoft/kernel-memory
RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.
dotnet/ai-samples
CommunityToolkit/Aspire
A community project with additional components and extensions for .NET Aspire
PowerShell/AIShell
An interactive shell to work with AI-powered assistance providers
Version Downloads Last updated
5.0.7 122 2/17/2025
5.0.6 5,737 2/3/2025
5.0.5 821 1/31/2025
5.0.4 2,670 1/27/2025
5.0.3 1,415 1/22/2025
5.0.2 3,851 1/15/2025
5.0.1 254 1/15/2025
4.0.22 4,455 1/10/2025
4.0.21 48 1/9/2025
4.0.20 229 1/8/2025
4.0.19 25 1/8/2025
4.0.18 181 1/8/2025
4.0.17 15,978 1/3/2025
4.0.16 86 1/3/2025
4.0.15 80 1/3/2025
4.0.14 85 1/3/2025
4.0.13 80 1/3/2025
4.0.12 81 1/3/2025
4.0.11 13,789 12/9/2024
4.0.10 68 12/9/2024
4.0.9 1,737 12/2/2024
4.0.8 24,992 11/22/2024
4.0.7 3,858 11/13/2024
4.0.6 12,302 11/7/2024
4.0.5 1,304 11/5/2024
4.0.4 424 11/4/2024
4.0.3 12,617 10/30/2024
4.0.2 263 10/29/2024
4.0.1 2,079 10/26/2024
4.0.0-preview.10 95 10/23/2024
4.0.0-preview.9 57 10/21/2024
4.0.0-preview.8 83 10/17/2024
3.0.15 3,633 10/21/2024
3.0.14 7,845 10/16/2024
3.0.13 98 10/16/2024
3.0.12 17,149 10/14/2024
3.0.11 1,410 10/9/2024
3.0.10 11,927 10/4/2024
3.0.9 102 10/4/2024
3.0.8 14,010 9/26/2024
3.0.7 22,884 9/12/2024
3.0.6 1,197 9/11/2024
3.0.5 792 9/11/2024
3.0.4 25,718 9/6/2024
3.0.3 118 9/6/2024
3.0.2 467 9/5/2024
3.0.1 17,773 9/2/2024
3.0.0 2,064 8/26/2024
2.1.3 2,620 8/23/2024
2.1.2 2,341 8/19/2024
2.1.1 4,203 8/5/2024
2.0.15 155 8/5/2024
2.0.14 106 8/3/2024
2.0.13 1,875 7/29/2024
2.0.12 115 7/28/2024
2.0.11 128 7/28/2024
2.0.10 4,180 7/12/2024
2.0.9 104 7/12/2024
2.0.8 141 7/12/2024
2.0.7 1,680 7/10/2024
2.0.6 3,095 6/25/2024
2.0.5 109 6/25/2024
2.0.4 578 6/24/2024
2.0.3 110 6/24/2024
2.0.2 161 6/24/2024
2.0.1 3,690 6/5/2024
1.1.13 248 6/5/2024
1.1.12 494 6/4/2024
1.1.11 304 6/2/2024
1.1.10 1,103 5/31/2024
1.1.9 7,170 5/15/2024
1.1.8 1,366 5/10/2024
1.1.7 124 5/10/2024
1.1.5 118 5/10/2024
1.1.4 207 5/10/2024
1.1.3 118 5/10/2024
1.1.2 118 5/10/2024
1.1.1 3,264 3/27/2024
1.1.0 1,918 1/8/2024
1.0.4 297 12/27/2023
1.0.3 351 11/30/2023
1.0.2 357 11/5/2023
1.0.1 198 10/16/2023
1.0.0 1,601 10/16/2023