Favicon of OllamaSharp

OllamaSharp

.NET library for local LLM apps using Ollama, with streaming chat, embeddings and model management. Open source under MIT; also supports Ollama cloud.

OllamaSharp is a C# library for developers building .NET applications around Ollama. It connects to Ollama on your own machine or a remote server and covers the full Ollama API, including model management alongside chat and embeddings. It's open source under the MIT license.

The library supports streaming responses, so an application can display an answer as the model generates it. Its chat support keeps conversation history across turns, including tool calls and their results. You can send images to vision models, request structured JSON output and use thinking mode with reasoning models.

For apps that need to manage models as well as use them, OllamaSharp can list, download, create, copy and delete models, with progress feedback during downloads. Function calling includes source generator support, and the library supports .NET Native AOT compilation.

OllamaSharp implements the chat and embedding interfaces in Microsoft.Extensions.AI. That gives developers a way to use Ollama within applications built around Microsoft's shared AI abstractions, while retaining access to Ollama-specific capabilities. It also underpins Ollama integrations in Semantic Kernel and .NET Aspire.

Where inference runs depends on the Ollama service you connect to: local models run through your own Ollama instance, while Ollama cloud models run remotely. Cloud access uses an API key.

Similar to OllamaSharp