Ollama.Api 1.0.13

dotnet add package Ollama.Api --version 1.0.13
                    
NuGet\Install-Package Ollama.Api -Version 1.0.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ollama.Api" Version="1.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ollama.Api" Version="1.0.13" />
                    
Directory.Packages.props
<PackageReference Include="Ollama.Api" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ollama.Api --version 1.0.13
                    
#r "nuget: Ollama.Api, 1.0.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ollama.Api@1.0.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ollama.Api&version=1.0.13
                    
Install as a Cake Addin
#tool nuget:?package=Ollama.Api&version=1.0.13
                    
Install as a Cake Tool

Ollama.Api

Nuget Codacy Badge License: MIT

<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

  1. Start the Ollama service (if not already running):

    ollama serve
    

    This will start the Ollama server on http://localhost:11434.

  2. Verify the server is running: Open a browser and navigate to http://localhost:11434. You should see a response indicating the server is running.

  3. Pull a model (if you haven't already):

    ollama pull llama3
    
  4. Test 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:

  1. 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"
    
  2. Start the task immediately:

    Start-ScheduledTask -TaskName "Ollama"
    
  3. Verify Ollama is running:

    Get-Process ollama
    
  4. Stop the task:

    Stop-ScheduledTask -TaskName "Ollama"
    
  5. 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 � Panoramic Data Limited 2025

Contributing

Contributions are welcome! Please open issues or submit pull requests on GitHub.

Repository

https://github.com/panoramicdata/Ollama.Api

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.