Developer's reference

This reference describes how to work with Aspose.LLM for .NET once you have the package installed and a license applied. It focuses on concepts, types, and method semantics.

For end-to-end scenarios, see Use cases. For compact task-oriented snippets, see Quick wins.

Typical flow

  1. Create an API instance — pick a preset and call AsposeLLMApi.Create(preset).
  2. Start a chat session — either explicitly with StartNewChatAsync, or implicitly by calling SendMessageAsync. See Chat sessions.
  3. Send messagesSendMessageAsync for the current session, or SendMessageToSessionAsync(sessionId, ...) for a specific one.
  4. Manage cache — when a session approaches the context limit, call ForceCacheCleanup(strategy) to trim the KV cache.
  5. Persist statesave and load conversations with SaveChatSession and LoadChatSession.
  6. Dispose — release native resources with Dispose or a using block.

Additional capabilities

  • Default parametersGetDefaultParametersAsync() returns a tuple of the engine’s default inference, context, chat, and sampler parameters.
  • Default presetGetDefaultPreset() returns a fresh Qwen25Preset as a sensible starting point.
  • Single instance — only one AsposeLLMApi instance per process. Disposing the current instance releases the guard.

Sections

  • AsposeLLMApi facade — the single-instance facade class: every method, lifecycle, and exception semantics.
  • Presets — preset base class, parameter bags, and override patterns.
  • Parameters — detailed reference for each of the eight parameter bags.
  • Chat sessions — starting sessions, sending messages, and ChatMessage structure.
  • Session persistence — saving and loading sessions to disk.
  • Cache management — five CacheCleanupStrategy modes and when to apply each.
  • Multimodal — vision presets, attaching images, chat templates, and debugging.
  • Acceleration — CUDA, HIP, Metal, Vulkan, CPU backends.
  • Dependency injectionAddLlamaServices for ASP.NET Core and Worker Service hosts.
  • Extensibility — replace core services via IModelLoader, IModelFileProvider, IPromptFormatter, IMediaProcessor.
  • Logging and diagnosticsILogger integration, debug logs, tagged output.
  • License — the License class API.
  • API reference — link to the full class-level API reference on reference.aspose.com.

What’s next

  • Use cases — full scenarios with runnable code.
  • Architecture — what happens behind the scenes when you call Create.