Ollama.Api
1.0.13
dotnet add package Ollama.Api --version 1.0.13
NuGet\Install-Package Ollama.Api -Version 1.0.13
<PackageReference Include="Ollama.Api" Version="1.0.13" />
<PackageVersion Include="Ollama.Api" Version="1.0.13" />
<PackageReference Include="Ollama.Api" />
paket add Ollama.Api --version 1.0.13
#r "nuget: Ollama.Api, 1.0.13"
#:package Ollama.Api@1.0.13
#addin nuget:?package=Ollama.Api&version=1.0.13
#tool nuget:?package=Ollama.Api&version=1.0.13
Ollama.Api
<img src="Ollama.Api/Logo.png" alt="Ollama.Api Logo" align="right" width="120" />
Overview
Ollama.Api is a .NET 10 library for interacting with Ollama-compatible AI model APIs. It provides strongly-typed interfaces for chat, text generation, embeddings, and model management, making it easy to integrate advanced AI capabilities into your .NET applications.
Features
- Chat and text generation endpoints
- Embedding support
- Model management (list, show, copy, delete, push, pull)
- Strongly-typed request/response models
- Async API using Refit
- .NET 10 compatible
Installation
Add the NuGet package to your project:
dotnet add package Ollama.Api
Setting Up a Local Ollama Server on Windows
If you have Ollama installed on Windows, you can run a local server on port 11434 (the default port).
Running Ollama Server
Start the Ollama service (if not already running):
ollama serveThis will start the Ollama server on
http://localhost:11434.Verify the server is running: Open a browser and navigate to
http://localhost:11434. You should see a response indicating the server is running.Pull a model (if you haven't already):
ollama pull llama3Test the model (optional):
ollama run llama3 "Hello, world!"
Downloading Models Required for Unit Tests
If you plan to run the unit tests for this library, you'll need to download the following models:
# General purpose language models
ollama pull llama3:latest
ollama pull llama3
ollama pull llama3.1
# Embedding model
ollama pull nomic-embed-text
# Multimodal model (supports images)
ollama pull llava:latest
You can verify which models are installed using:
ollama list
Configuring Ollama to Run on a Different Port
If you need to run Ollama on a different port, set the OLLAMA_HOST environment variable before starting the server:
$env:OLLAMA_HOST = "0.0.0.0:11434"
ollama serve
Running Ollama as a Windows Service
Ollama doesn't install as a Windows service by default, but you can configure it to start automatically at boot using Windows Task Scheduler:
Create a scheduled task to run Ollama at startup (run PowerShell as Administrator):
$action = New-ScheduledTaskAction -Execute "C:\Users\$env:USERNAME\AppData\Local\Programs\Ollama\ollama.exe" -Argument "serve" $trigger = New-ScheduledTaskTrigger -AtStartup $principal = New-ScheduledTaskPrincipal -UserId "$env:USERNAME" -LogonType S4U -RunLevel Highest $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 0 Register-ScheduledTask -TaskName "Ollama" -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description "Ollama language model service"Start the task immediately:
Start-ScheduledTask -TaskName "Ollama"Verify Ollama is running:
Get-Process ollamaStop the task:
Stop-ScheduledTask -TaskName "Ollama"Remove the scheduled task (if needed):
Unregister-ScheduledTask -TaskName "Ollama" -Confirm:$false
Usage Example
using Ollama.Api;
using Ollama.Api.Models;
var client = new OllamaClient(new OllamaClientOptions { BaseUrl = "http://localhost:11434" });
var response = await client.Generate.GenerateAsync(new GenerateRequest {
Model = "llama3",
Prompt = "Hello, world!"
}, CancellationToken.None);
Console.WriteLine(response.Response);
License
MIT License. See LICENSE for details.
Copyright
Copyright � Panoramic Data Limited 2025
Contributing
Contributions are welcome! Please open issues or submit pull requests on GitHub.
Repository
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Refit (>= 11.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.13 | 154 | 6/5/2026 |
| 1.0.12 | 116 | 6/2/2026 |
| 1.0.10 | 159 | 3/31/2026 |
| 1.0.8 | 506 | 12/18/2025 |
| 1.0.7 | 314 | 11/7/2025 |
| 1.0.3 | 250 | 10/27/2025 |
| 1.0.1 | 240 | 10/27/2025 |
| 0.9.30 | 234 | 10/27/2025 |
| 0.9.25 | 801 | 7/21/2025 |
| 0.9.24 | 196 | 7/4/2025 |
| 0.9.23 | 164 | 7/4/2025 |
| 0.9.19 | 223 | 6/24/2025 |
| 0.9.18 | 227 | 6/24/2025 |
| 0.9.14 | 227 | 6/23/2025 |
| 0.9.12 | 223 | 6/23/2025 |
| 0.9.8 | 226 | 6/22/2025 |
# Change Log
* 2025-07-04 : 0.9.24
* Removed ToolCalls from root of ChatResponse.
* 2025-07-04 : 0.9.24
* Fixed MCP support for Agentic models/clients.
* 2025-07-04 : 0.9.23
* Fixed MCP support for Agentic models/clients.
* 2025-06-24 : 0.9.19
* Added MCP support for Agentic models/clients.
* 2025-06-23 : 0.9.18
* Fixed bad default GenerateRequest.Format value
* 2025-06-23 : 0.9.14
* Fixed logo
* 2025-06-23 : 0.9.12
* Added unit tests for multi-modal requests including images.
* e.g. using Llava for image description.
* 2025-06-22 : 0.9.8
* Initial release.