Favicon of OllamaSharp

OllamaSharp

A .NET library for building local LLM apps with Ollama, covering streaming chat, embeddings and model management on local or remote servers.

OllamaSharp is a C# library for developers building .NET applications with Ollama. It gives those applications access to chat, embeddings and model management through the Ollama API.

  • Chat and generation: Build conversations that retain message history, including tool calls and their results, or request single-turn completions. Responses can stream as the model generates them.
  • Model capabilities: Send images to vision models, request structured output and use thinking models through Ollama.
  • Model management: List, pull, create, copy and delete Ollama models, with progress feedback while pulling them.
  • .NET integration: Use its Microsoft.Extensions.AI chat and embedding interfaces in applications built around those abstractions. OllamaSharp also supports tool calling with source generators and optional .NET Native AOT compilation.

The library is open source under the MIT license. It can connect to Ollama on your machine or on a remote server, so local inference depends on the Ollama instance you use. Ollama cloud models run remotely and require an API key. OllamaSharp also underpins Ollama integrations in Semantic Kernel and .NET Aspire.

Similar to OllamaSharp