Hello, world!

This page walks through the smallest possible Aspose.LLM for .NET program. It applies a license, creates an API instance from a preset, sends one message, and prints the response.

Prerequisites

  • Install the Aspose.LLM NuGet package.
  • Obtain a license (a free temporary license works for evaluation).
  • Enough RAM for the chosen model. Qwen25Preset needs roughly 8-12 GB — see System requirements.
  • Internet access on first run (see the warning below).

Code

Step 1. Apply the license

Apply the license once, before constructing the API. Aspose.LLM does not run inference in evaluation mode.

using Aspose.LLM;

var license = new Aspose.LLM.License();
license.SetLicense("Aspose.LLM.lic");

Step 2. Create the API

Create an instance from a built-in preset. Qwen25Preset is a good general-purpose starting point.

using Aspose.LLM.Abstractions.Parameters.Presets;

var preset = new Qwen25Preset();
using var api = AsposeLLMApi.Create(preset);

The using pattern disposes the API automatically when the block exits. Disposal unloads the model and releases the single-instance guard.

Step 3. Send a message

If no chat session exists yet, SendMessageAsync creates one implicitly.

string response = await api.SendMessageAsync("Say hello in one short sentence.");
Console.WriteLine(response);
// Output: Hello! Nice to meet you.

Full example

using Aspose.LLM;
using Aspose.LLM.Abstractions.Parameters.Presets;

var license = new Aspose.LLM.License();
license.SetLicense("Aspose.LLM.lic");

var preset = new Qwen25Preset();
using var api = AsposeLLMApi.Create(preset);

string response = await api.SendMessageAsync("Say hello in one short sentence.");
Console.WriteLine(response);

Save this as Program.cs in a new .NET 8 or .NET 10 project, ensure Aspose.LLM.lic is next to the executable, and run:

dotnet run

Troubleshooting

  • Not licensed for this method — the license has not been applied. Call SetLicense before AsposeLLMApi.Create. See Licensing.
  • First Create hangs for a long time — it is downloading binaries and the model. On a slow network, budget 5-15 minutes. Monitor progress via ILogger (pass one to AsposeLLMApi.Create(preset, logger)).
  • Only one AsposeLLMApi instance can be created at a time — a previous instance has not been disposed yet. Keep one instance for the process lifetime, or dispose the old one first.

What’s next