This onramp starts with a host-controlled GGUF artifact and ends with a bounded, isolated local generation. It deliberately keeps acquisition, licensing, prompt preparation, transport, persistence, and user-interface policy outside the runtime facade.
1. Prerequisites
- A 64-bit .NET development environment compatible with the current package release.
- A GGUF artifact obtained through a source and license process your application is authorized to use.
- A trusted SHA-256 digest and exact byte count retained independently of the runtime.
- Enough local memory for the selected artifact and context.
2. Create a console project
dotnet new console --name LocalModelSample
cd LocalModelSample3. Add the LocalEndpoint package
dotnet add package UAIX.LmRuntime.LocalEndpointThe public command is version-free. Resolve and pin the package through the repository dependency policy and lock files used by the consuming application.
4. Obtain a trusted GGUF artifact
The runtime does not download, license, approve, or trust a model for the host. Record the artifact source, license review, file name, and intended application use before intake.
5. Record SHA-256 and byte count
$model = Get-Item .\models\model.gguf
(Get-FileHash $model.FullName -Algorithm SHA256).Hash.ToLowerInvariant()
$model.Lengthsha256sum ./models/model.gguf
wc -c < ./models/model.ggufIdentity boundary: A digest and byte count establish the identity of the bytes checked. They do not establish licensing, provenance, architecture compatibility, tokenizer compatibility, quality, or safety.
6–11. Configure, load, isolate, generate, cancel, and dispose
The following program uses public LocalEndpoint signatures reviewed against the canonical package guide. It constrains the path, rejects reparse points, limits model size and generation, uses a closed-authority UAIX context, and disposes the session before the model.
using System;
using System.Globalization;
using System.IO;
using System.Threading;
using UAIX.LmRuntime.LocalEndpoint;
namespace GgufRuntime.Examples.ConsoleQuickStart;
/// <summary>
/// Loads one verified local GGUF artifact and performs bounded deterministic generation.
/// </summary>
public static class Program
{
/// <summary>
/// Runs the verified local-model example.
/// </summary>
/// <param name="arguments">Model path, SHA-256, byte count, and host-prepared prompt.</param>
/// <returns>Zero after generation; two when required arguments are missing.</returns>
public static Int32 Main(String[] arguments)
{
if (arguments.Length != 4)
{
Console.Error.WriteLine(
"Usage: ConsoleQuickStart <model.gguf> <sha256> <byte-count> <prepared-prompt>");
return 2;
}
String modelPath = Path.GetFullPath(arguments[0]);
String expectedSha256 = arguments[1];
Int64 expectedByteCount = Int64.Parse(arguments[2], CultureInfo.InvariantCulture);
String preparedPrompt = arguments[3];
String trustedModelRoot = Path.GetDirectoryName(modelPath)
?? throw new InvalidOperationException("The model path has no parent directory.");
LocalGgufRuntime runtime = new LocalGgufRuntime();
LocalUaixRuntimeContext uaixContext = new LocalUaixRuntimeContext
{
LoadedUaixProfilePresent = true,
LoadedUaixProfileId = "profile1",
LoadedUaixProfileDisplayName = "Local model profile",
LoadedUaixLoadSessionId = "load1",
LoadedUaixUaiRelativePath = "Memories/Profiles/profile1/.uai",
LoadedUaixSessionRelativePath = "Memories/Sessions/load1.json",
LongTermMemoryRootId = "wiki1",
LongTermMemoryRootRelativePath = "Profiles/profile1",
LongTermMemoryMode = LocalUaixLongTermMemoryMode.Isolated,
RuntimeExecutionAllowed = false,
MemoryCanOverridePolicy = false,
CommandExecutionAllowed = false,
NetworkAccessAllowed = false,
ProviderApisAllowed = false,
WebsitePromptIntakeAllowed = false,
TelemetryEnabled = false,
AutoExportAllowed = false
};
_ = LocalGgufRuntime.VerifyUaixRuntimeContext(uaixContext);
using LocalGgufModel model = runtime.LoadVerifiedModel(
modelPath,
new LocalGgufFileExpectation
{
ModelSha256 = expectedSha256,
ModelByteCount = expectedByteCount
},
new LocalGgufModelLoadOptions
{
AllowedRootDirectory = trustedModelRoot,
RejectReparsePoints = true,
MaximumModelBytes = expectedByteCount,
ExecutionLimits = new LocalGgufExecutionLimits
{
MaximumPromptCharacters = 32_768,
MaximumGeneratedTokens = 256,
MaximumStopTokenCount = 32
}
});
using LocalGgufSession session = model.CreateSession(
new LocalGgufSessionContext
{
SessionId = "session1",
UaixRuntimeContext = uaixContext
});
LocalGgufGenerationResult result = session.GenerateGreedy(
new LocalGgufGenerationRequest
{
Prompt = preparedPrompt,
MaximumTokens = 128,
ResetSession = true,
AddSpecialTokens = false,
ParseSpecialTokens = false,
EmitTokenizerTrace = false,
RemoveSpecialTokens = false,
UnparseSpecialTokens = true,
CleanSpaces = false
},
CancellationToken.None);
Console.WriteLine(result.GeneratedText);
return 0;
}
}12. Interpret outcomes
| State | What it establishes | What it does not establish |
|---|---|---|
| Identity matched | The current file matched the supplied digest and byte count. | License, provenance, architecture, tokenizer, or execution compatibility. |
| Model loaded | The named artifact passed the configured intake and model-load path. | Universal GGUF or model-family compatibility. |
| Generation completed | The executed model, prompt, limits, and backend path produced a result. | Production certification, safety certification, or benchmark leadership. |
| Cancellation observed | The host cancellation signal was observed at a runtime cancellation boundary. | Instant interruption of every low-level operation. |
13. Continue to application hosts
Operational boundary
What this page covers: The first verified managed CPU path from artifact identity through disposal.
Available now: The public package family, verified local intake, isolated sessions, bounded deterministic generation, and explicit cancellation inputs are documented.
Host responsibility: Acquire and license the model, prepare the model-specific prompt, choose limits, own cancellation, present errors, retain evidence, and dispose resources.
Not claimed: Automatic model acquisition, prompt-template correctness, universal compatibility, hidden provider fallback, or a finished UI application.
Canonical sources: LocalEndpoint package guide · NuGet release metadata
Last reviewed UTC: