RMLLamaSharp 1.0.0
dotnet add package RMLLamaSharp --version 1.0.0
NuGet\Install-Package RMLLamaSharp -Version 1.0.0
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="RMLLamaSharp" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RMLLamaSharp" Version="1.0.0" />
<PackageReference Include="RMLLamaSharp" />
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 RMLLamaSharp --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RMLLamaSharp, 1.0.0"
#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 RMLLamaSharp@1.0.0
#: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=RMLLamaSharp&version=1.0.0
#tool nuget:?package=RMLLamaSharp&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RMLLamaSharp
A lightweight .NET 8 client library for the Ollama REST API.
Run local LLMs (Llama 3, Mistral, Phi, Gemma and more) from any .NET application with a clean, async-first API.
Installation
dotnet add package RMLLamaSharp
Requirements
- Ollama running locally (default:
http://localhost:11434) - .NET 8 or later
Quick start
using LLamaSharp;
await using var client = new Client();
// Single prompt
string reply = await client.GenerateAsync("llama3", "Explain quantum entanglement in one sentence.");
Console.WriteLine(reply);
// Chat
var messages = new[]
{
new ChatMessage("user", "What is the capital of France?")
};
string answer = await client.ChatAsync("llama3", messages);
Console.WriteLine(answer);
Features
| Feature | Method |
|---|---|
| Single prompt | GenerateAsync / Generate |
| Single prompt (streaming) | GenerateStreamAsync |
| Chat (multi-turn) | ChatAsync / Chat |
| Chat (streaming) | ChatStreamAsync |
| Managed chat session | ChatSession |
| Text embeddings | GetEmbeddingsAsync / GetEmbeddingsBatchAsync |
| List available models | GetModelsAsync |
| List running models | ListRunningModelsAsync |
| Show model metadata | ShowModelAsync |
| Pull / push / copy / delete models | PullModelAsync, PushModelAsync, CopyModelAsync, DeleteModelAsync |
| Create model from Modelfile | CreateModelAsync |
| Health check | IsAliveAsync / IsAlive |
Streaming
await foreach (var token in client.GenerateStreamAsync("llama3", "Tell me a short story."))
{
Console.Write(token);
}
Multi-turn conversation
Use ChatSession to automatically maintain conversation history:
using var client = new Client();
var session = new ChatSession(client, "llama3", systemPrompt: "You are a helpful assistant.");
string r1 = await session.SendAsync("My name is Alice.");
string r2 = await session.SendAsync("What is my name?"); // remembers context
Streaming is also supported:
await foreach (var token in session.SendStreamAsync("Summarize our conversation."))
Console.Write(token);
Generation options
Fine-tune sampling behaviour with GenerationOptions:
var options = new GenerationOptions(
Temperature: 0.7f,
TopP: 0.9f,
Seed: 42,
NumPredict: 200,
Stop: [".", "\n"]
);
string reply = await client.GenerateAsync("llama3", "Once upon a time", options);
| Parameter | Description |
|---|---|
Temperature |
Randomness (0.0 – 2.0). Higher = more creative. |
TopP |
Nucleus sampling threshold. |
TopK |
Limit sampling to the K most probable tokens. |
Seed |
Fixed seed for reproducible output. |
NumPredict |
Max tokens to generate (-1 = unlimited). |
Stop |
List of strings that stop generation. |
RepeatPenalty |
Penalty for repeated tokens (> 1.0 discourages repetition). |
Embeddings
// Single input
List<float> vector = await client.GetEmbeddingsAsync("nomic-embed-text", "Hello world");
// Batch
List<List<float>> vectors = await client.GetEmbeddingsBatchAsync(
"nomic-embed-text",
["First sentence.", "Second sentence."]);
Model management
// List all available models
List<string> models = await client.GetModelsAsync();
// Download a model
await client.PullModelAsync("mistral", status => Console.WriteLine(status));
// Delete a model
await client.DeleteModelAsync("mistral");
// Show metadata
ModelInfo info = await client.ShowModelAsync("llama3");
Console.WriteLine(info.Template);
Custom server URL
using var client = new Client("http://192.168.1.100:11434", timeout: TimeSpan.FromMinutes(5));
Error handling
All methods throw LLamaSharpException on server errors or unexpected responses, and ArgumentException for invalid inputs.
try
{
string reply = await client.GenerateAsync("llama3", "Hello");
}
catch (LLamaSharpException ex)
{
Console.WriteLine($"Ollama error: {ex.Message}");
}
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net8.0
- No dependencies.
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.0 | 122 | 6/4/2026 |