Aspose.LLM
26.11.0
Prefix Reserved
dotnet add package Aspose.LLM --version 26.11.0
NuGet\Install-Package Aspose.LLM -Version 26.11.0
<PackageReference Include="Aspose.LLM" Version="26.11.0" />
<PackageVersion Include="Aspose.LLM" Version="26.11.0" />
<PackageReference Include="Aspose.LLM" />
paket add Aspose.LLM --version 26.11.0
#r "nuget: Aspose.LLM, 26.11.0"
#:package Aspose.LLM@26.11.0
#addin nuget:?package=Aspose.LLM&version=26.11.0
#tool nuget:?package=Aspose.LLM&version=26.11.0
Aspose.LLM for .NET
Aspose.LLM for .NET is a local LLM inference library for C# and .NET. Use it to run large language models on your own machine or server, build chat-driven workflows, send image input with vision presets, and keep prompts, model weights, and responses inside your own process instead of calling a hosted inference service.
The SDK targets netstandard2.0, works across modern .NET runtimes, and uses built-in presets for model families such as Qwen, Gemma, Llama, Phi, DeepSeek, and vision-capable variants. Native llama.cpp runtimes for CPU, CUDA, HIP, Metal, and Vulkan are downloaded automatically on first use.
No built-in LLM is included in Aspose.LLM. A preset is configuration only: you choose which open-source model to use, and the model file is obtained separately on your own machine, under the model publisher's license, not the Aspose license. Model names are used solely to identify the models, with no affiliation or endorsement implied; each name remains the property of its owner.
Why Aspose.LLM for .NET
- Run local LLM inference from .NET applications on CPU or GPU.
- Start stateful chat sessions with message history and session persistence.
- Use built-in text and vision presets instead of hand-building inference pipelines.
- Send text-only or multimodal prompts through one high-level
AsposeLLMApi. - Tune context, sampling, acceleration, and runtime behavior through parameter bags.
- Bring your own GGUF model by extending
PresetCoreBaseor overriding preset settings.
How It Works
- Choose a preset for a text or vision model family.
- Create a single
AsposeLLMApiinstance for the current process. - Let the SDK resolve native
llama.cppruntime assets for your platform. - Send prompts through
SendMessageAsync, optionally with image bytes for multimodal requests. - Persist or reuse chat sessions when you need multi-turn conversations.
Supported Environment
| Area | Details |
|---|---|
| Managed package target | netstandard2.0 |
| Common runtimes | .NET 10, .NET 8 LTS, .NET 6, and .NET Framework 4.7.2+ |
| Acceleration backends | CPU, CUDA, HIP / ROCm, Metal, Vulkan |
| First-run native download | Usually 100-500 MB, depending on the selected backend |
| Package shape | One NuGet package, one main assembly: Aspose.LLM.dll |
| Model setup | Built-in presets for text and vision models, plus custom preset support |
Install from NuGet
dotnet add package Aspose.LLM
Apply a license before calling chat APIs. Aspose.LLM does not run inference in evaluation mode, so a temporary or commercial license is required for StartNewChatAsync, SendMessageAsync, and SendMessageToSessionAsync.
Choose a Preset
Qwen25Presetfor general text chat and local assistant workflows.Qwen3Presetfor text reasoning and chat-oriented workloads.Qwen25VL3BPresetfor image + text multimodal prompts.Qwen3VL2BPresetfor larger-context vision scenarios.Gemma3VisionPresetfor vision-enabled Gemma workflows.- CPU variants such as
Qwen25_3BPresetCpuorLlm32_1BPresetCpuwhen GPU acceleration is unavailable.
Text Chat Example
using Aspose.LLM;
using Aspose.LLM.Abstractions.Parameters.Presets;
var license = new License();
license.SetLicense("Aspose.LLM.lic");
using var api = AsposeLLMApi.Create(new Qwen25Preset());
string response = await api.SendMessageAsync(
"Explain retrieval-augmented generation in two sentences.");
Console.WriteLine(response);
Multimodal Vision Example
using Aspose.LLM;
using Aspose.LLM.Abstractions.Parameters.Presets;
using System.IO;
var license = new License();
license.SetLicense(@"C:\licenses\Aspose.LLM.lic");
using var api = AsposeLLMApi.Create(new Qwen25VL3BPreset());
byte[] imageBytes = File.ReadAllBytes(@"C:\images\sample.png");
string response = await api.SendMessageAsync(
"Describe what is shown in the image.",
media: new[] { imageBytes });
Console.WriteLine(response);
Session Lifecycle and Memory Cleanup
SendMessageAsync is conversation-oriented. The first call creates a chat
session when no session is active; later calls reuse that active session and
append to its history. The session is not closed automatically.
For independent one-shot prompts, close the session when the response is no longer needed:
string sessionId = await api.StartNewChatAsync();
string response = await api.SendMessageToSessionAsync(sessionId, prompt);
api.CloseChatSession(sessionId);
ForceCacheCleanup(...) prunes the KV cache inside the active session, but it
does not destroy the session's native context. Use CloseChatSession(sessionId)
to release per-session native context memory, and dispose AsposeLLMApi when
the loaded model itself is no longer needed.
Control Cache Directories
When a preset leaves cache paths at their built-in defaults, the SDK can take the cache roots from environment variables:
ASPOSE_LLM_MODEL_CACHE_DIRASPOSE_LLM_RUNTIME_CACHE_DIR
Precedence is:
- preset path
- environment variable
- built-in default
Built-in defaults are under the local application data directory:
- models:
Aspose.LLM/models - runtimes:
Aspose.LLM/runtimes
Load Presets From JSON
AsposeLLMApi.LoadPresetFromJson(...) loads one preset from one inline JSON
document. The JSON must contain extends, which selects the built-in preset
used as the base. Any other provided sections override that base preset.
var preset = AsposeLLMApi.LoadPresetFromJson("""
{
"extends": "Qwen25Preset",
"contextParameters": {
"contextSize": 8192
},
"samplerParameters": {
"temperature": 0.2
}
}
""");
using var api = AsposeLLMApi.Create(preset);
AsposeLLMApi.SavePresetToJson(...) exports a built-in preset back to the
same contract, so a user can tweak a working preset in code and then export an
exact JSON example:
var preset = new Qwen25Preset();
preset.ContextParameters.ContextSize = 8192;
preset.SamplerParameters.Temperature = 0.2f;
string json = AsposeLLMApi.SavePresetToJson(preset);
Console.WriteLine(json);
If you want a full preset snapshot instead of only overrides, pass
includeDefaults: true:
string fullJson = AsposeLLMApi.SavePresetToJson(preset, includeDefaults: true);
Console.WriteLine(fullJson);
Customize a Preset
using Aspose.LLM.Abstractions.Parameters.Presets;
var preset = new Qwen25Preset();
preset.BinaryManagerParameters.ReleaseTag = "b10988";
preset.ContextParameters.ContextSize = 8192;
using var api = AsposeLLMApi.Create(preset);
Use this pattern when you want to keep the model-family defaults but adjust runtime tag, context window, batching, or acceleration preferences for a specific deployment.
Common Use Cases
- Local AI assistants and chatbots for .NET applications.
- Document automation, classification, and question answering workflows.
- Code generation and code analysis scenarios.
- Multimodal vision Q&A with text and images.
- Offline or controlled-deployment AI integrations where data should stay local.
Before First Run
- Apply a temporary or commercial license before starting a chat session.
- Expect an automatic native runtime download on the first launch for the selected backend.
- Plan local disk space for runtime assets, model weights, and chat-session state if you persist sessions.
- Keep your first validation scenario small, then move to larger presets or larger context windows.
Important Notes
- First use downloads the matching native
llama.cppruntime for your platform and acceleration backend. AsposeLLMApiallows only one active instance per process at a time.- Presets are the recommended entry point for model selection, sampler defaults, context size, and acceleration behavior.
- Vision support uses the same API surface as text chat and adds media input through the
mediaparameter.
Resources
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.1.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 2.1.1)
- Microsoft.Extensions.Logging.Abstractions (>= 2.1.1)
- System.Text.Json (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aspose.LLM:
| Package | Downloads |
|---|---|
|
Aspose.Total
Aspose.Total for .NET is the most complete package of all .NET file format APIs offered by Aspose. It empowers developers to create, edit, render, print and convert between a wide range of popular document formats within any .NET, C#, ASP.NET and VB.NET applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated the llama.cpp runtime to b10988 and added .NET 10 support.