OllamaSharp 4.0.1

 ollama

OllamaSharp 🦙

OllamaSharp provides .NET bindings for the Ollama API, simplifying interactions with Ollama both locally and remotely.

✅ Supporting Microsoft.Extensions.AI and Microsoft Semantic Kernel

Features

  • Ease of use: Interact with Ollama in just a few lines of code.
  • API endpoint coverage: Support for all the Ollama API endpoints, including chats, embeddings, listing models, pulling and creating new models, and more.
  • Real-time streaming: Stream responses directly to your application.
  • Progress reporting: Get real-time progress feedback on tasks like model pulling.
  • Support for vision models and tools (function calling).

Usage

OllamaSharp wraps each Ollama API endpoint in awaitable methods that fully support response streaming.

The following list shows a few simple code examples.

Try our full featured demo application that's included in this repository

Initializing

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

// select a model which should be used for further operations
ollama.SelectedModel = "llama3.1:8b";

Listing all models that are available locally

var models = await ollama.ListLocalModelsAsync();

Pulling a model and reporting progress

await foreach (var status in ollama.PullModelAsync("llama3.1:405b"))
    Console.WriteLine($"{status.Percent}% {status.Status}");

Generating a completion directly into the console

await foreach (var stream in ollama.GenerateAsync("How are you today?"))
    Console.Write(stream.Response);

Building interactive chats

var chat = new Chat(ollama);
while (true)
{
    var message = Console.ReadLine();
    await foreach (var answerToken in chat.SendAsync(message))
        Console.Write(answerToken);
}
// messages including their roles and tool calls will automatically be tracked within the chat object
// and are accessible via the Messages property

Credits

The icon and name were reused from the amazing Ollama project.

I would like to thank all the contributors who take the time to improve OllamaSharp. First and foremost mili-tan, who always keeps OllamaSharp in sync with the Ollama API. ❤

Showing the top 20 packages that depend on OllamaSharp.

Packages Downloads
Verto.AIManagement.Ollama
Package Description
2

.NET Standard 2.0

Version Downloads Last updated
5.4.25 1 04/06/2026
5.4.24 1 04/06/2026
5.4.23 1 04/06/2026
5.4.22 1 04/06/2026
5.4.21 1 04/06/2026
5.4.20 1 04/06/2026
5.4.19 1 04/06/2026
5.4.18 1 04/06/2026
5.4.17 1 04/06/2026
5.4.16 1 04/06/2026
5.4.15 1 04/06/2026
5.4.13 1 04/06/2026
5.4.12 1 04/06/2026
5.4.11 1 04/06/2026
5.4.10 1 04/06/2026
5.4.9 1 04/06/2026
5.4.8 1 04/06/2026
5.4.7 1 04/06/2026
5.4.6 1 04/06/2026
5.4.5 1 04/06/2026
5.4.4 1 04/06/2026
5.4.3 1 04/06/2026
5.4.2 1 04/06/2026
5.4.1 1 04/06/2026
5.3.12 1 04/06/2026
5.3.11 1 04/06/2026
5.3.10 1 04/06/2026
5.3.9 1 04/06/2026
5.3.8 1 04/06/2026
5.3.7 1 04/06/2026
5.3.6 1 04/06/2026
5.3.5 1 04/06/2026
5.3.4 1 04/06/2026
5.3.3 1 04/06/2026
5.3.2 1 04/06/2026
5.3.1 1 04/06/2026
5.2.10 1 04/06/2026
5.2.9 1 04/06/2026
5.2.8 1 04/06/2026
5.2.7 1 04/06/2026
5.2.6 1 04/06/2026
5.2.5 1 04/06/2026
5.2.4 1 04/06/2026
5.2.3 1 04/06/2026
5.2.2 1 04/06/2026
5.2.1 1 04/06/2026
5.1.20 1 04/06/2026
5.1.19 1 04/06/2026
5.1.18 1 04/06/2026
5.1.17 1 04/06/2026
5.1.16 1 04/06/2026
5.1.15 1 04/06/2026
5.1.14 1 04/06/2026
5.1.13 1 04/06/2026
5.1.12 1 04/06/2026
5.1.11 1 04/06/2026
5.1.10 1 04/06/2026
5.1.9 1 04/06/2026
5.1.8 1 04/06/2026
5.1.7 1 04/06/2026
5.1.6 1 04/06/2026
5.1.5 1 04/06/2026
5.1.4 1 04/06/2026
5.1.3 1 04/06/2026
5.1.2 1 04/06/2026
5.1.1 1 04/06/2026
5.1.0 1 04/06/2026
5.0.7 1 04/06/2026
5.0.6 1 04/06/2026
5.0.5 1 04/06/2026
5.0.4 1 04/06/2026
5.0.3 1 04/06/2026
5.0.2 1 04/06/2026
5.0.1 1 04/06/2026
4.0.22 1 04/06/2026
4.0.21 1 04/06/2026
4.0.20 1 04/06/2026
4.0.19 1 04/06/2026
4.0.18 1 04/06/2026
4.0.17 1 04/06/2026
4.0.16 1 04/06/2026
4.0.15 1 04/06/2026
4.0.14 1 04/06/2026
4.0.13 1 04/06/2026
4.0.12 1 04/06/2026
4.0.11 1 04/06/2026
4.0.10 1 04/06/2026
4.0.9 1 04/06/2026
4.0.8 1 04/06/2026
4.0.7 1 04/06/2026
4.0.6 1 04/06/2026
4.0.5 1 04/06/2026
4.0.4 1 04/06/2026
4.0.3 1 04/06/2026
4.0.2 1 04/06/2026
4.0.1 1 04/06/2026
4.0.0-preview.10 1 04/06/2026
4.0.0-preview.9 1 04/06/2026
4.0.0-preview.8 1 04/06/2026
3.0.15 1 04/06/2026
3.0.14 1 04/06/2026
3.0.13 1 04/06/2026
3.0.12 1 04/06/2026
3.0.11 1 04/06/2026
3.0.10 1 04/06/2026
3.0.9 1 04/06/2026
3.0.8 1 04/06/2026
3.0.7 1 04/06/2026
3.0.6 1 04/06/2026
3.0.5 1 04/06/2026
3.0.4 1 04/06/2026
3.0.3 1 04/06/2026
3.0.2 1 04/06/2026
3.0.1 1 04/06/2026
3.0.0 1 04/06/2026
2.1.3 1 04/06/2026
2.1.2 1 04/06/2026
2.1.1 1 04/06/2026
2.0.15 1 04/06/2026
2.0.14 1 04/06/2026
2.0.13 1 04/06/2026
2.0.12 1 04/06/2026
2.0.11 1 04/06/2026
2.0.10 1 04/06/2026
2.0.9 1 04/06/2026
2.0.8 1 04/06/2026
2.0.7 1 04/06/2026
2.0.6 1 04/06/2026
2.0.5 1 04/06/2026
2.0.4 1 04/06/2026
2.0.3 1 04/06/2026
2.0.2 1 04/06/2026
2.0.1 1 04/06/2026
1.1.13 1 04/06/2026
1.1.12 1 04/06/2026
1.1.11 1 04/06/2026
1.1.10 1 04/06/2026
1.1.9 1 04/06/2026
1.1.8 1 04/06/2026
1.1.7 1 04/06/2026
1.1.5 1 04/06/2026
1.1.4 1 04/06/2026
1.1.3 1 04/06/2026
1.1.2 1 04/06/2026
1.1.1 1 04/06/2026
1.1.0 1 04/06/2026
1.0.4 1 04/06/2026
1.0.3 1 04/06/2026
1.0.2 1 04/06/2026
1.0.1 1 04/06/2026
1.0.0 1 04/06/2026