OllamaSharp 4.0.0-preview.8

 ollama

OllamaSharp 🦙

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

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 Ollama API client app OllamaSharpConsole to interact with your Ollama instance.

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
Microsoft.SemanticKernel.Connectors.Ollama
Semantic Kernel connector for Ollama. Contains services for text generation, chat completion and text embeddings.

.NET Standard 2.0

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