awaescher/OllamaSharp

The easiest way to use Ollama in .NET

What it solves

OllamaSharp is a .NET library that simplifies the process of integrating local or remote Ollama AI models into C# applications. It acts as a bridge, providing a strongly-typed API wrapper around the Ollama API, eliminating the need for manual HTTP requests to interact with the AI models.

How it works

The library provides an OllamaApiClient that wraps every single Ollama API endpoint. This allows developers to perform tasks such as chatting, generating completions, creating embeddings, and managing models (pulling, listing, and deleting) using awaitable C# methods. It supports real-time streaming of responses and progress reporting for long-running tasks like model downloads.

Who it’s for

.NET developers who want to use Ollama for AI capabilities in their software, whether they are building simple chat interfaces or integrating AI into larger frameworks like Microsoft Semantic Kernel or .NET Aspire.

Highlights

  • Full API Coverage: Covers all Ollama API endpoints, including model management and embeddings.
  • C# Native Experience: Supports real-time streaming and Native AOT (Ahead-of-Time) compilation for high performance.
  • Tool Support: Includes a sophisticated tools engine with source generators for function calling.
  • Ecosystem Integration: Recommended by Microsoft and implements IChatClient and IEmbeddingGenerator from Microsoft.Extensions.AI for provider-agnostic AI development.

Related

  • Project
  • Project
  • Project
  • Project
  • Project