awaescher/OllamaSharp

The easiest way to use Ollama in .NET

What it solves

OllamaSharp provides a set of .NET bindings for the Ollama API, making it easier for C# developers to integrate local and remote LLMs into their applications without writing raw HTTP requests.

How it works

It wraps every Ollama API endpoint into awaitable C# methods. It includes a Chat class to automatically track conversation history and tool calls, and supports real-time response streaming and progress reporting for tasks like pulling models. It also integrates with Microsoft.Extensions.AI by implementing IChatClient and IEmbeddingGenerator interfaces, allowing it to be used interchangeably with other AI providers.

Who it’s for

.NET developers who want to use Ollama for model inference, embeddings, or model management within their C# applications.

Highlights

  • Full API Coverage: Supports all Ollama endpoints, including chat, embeddings, and model management (pull, push, copy, delete).
  • Tool Support: Includes a sophisticated tools engine with source generators for function calling.
  • Multi-modality: Supports vision models for processing images.
  • Performance: Offers opt-in support for Native AOT (Ahead-of-Time) compilation.
  • Ecosystem Integration: Recommended by Microsoft and used by Semantic Kernel and .NET Aspire.

Related

  • Project
  • Project
  • Project
  • Project
  • Dispatch