LMRuntime.com / Public page
Getting Started
Install LocalEndpoint, supply trusted GGUF identity, create an isolated session, generate locally, and dispose owned resources.
Fast path
Run Your First Model
Install UAIX.LmRuntime.LocalEndpoint, supply a trusted SHA-256 and byte count for a local GGUF artifact, load the verified model, create an isolated session, generate text locally, and dispose the session before the model.
1. Create the console app and add LocalEndpoint
dotnet new console --name LocalModelSample
cd LocalModelSample
dotnet add package UAIX.LmRuntime.LocalEndpointPublic examples omit a package version. Resolve and pin the package through the dependency policy used by your repository. The NuGet page owns current framework and dependency metadata.
2. Obtain the model SHA-256 and byte count
The runtime does not acquire or license models. The host selects the local GGUF artifact and supplies expected identity. Prefer a digest and byte count published by the artifact source or recorded during a trusted intake process.
$model = Get-Item .\models\model.gguf
(Get-FileHash $model.FullName -Algorithm SHA256).Hash.ToLowerInvariant()
$model.Lengthsha256sum ./models/model.gguf
wc -c < ./models/model.gguf3. Load, create a session, generate, and dispose
This example uses the public LocalEndpoint signatures and a closed-authority session context. Replace the model path, expected identity, and prepared prompt with values owned by the host application.
using System.Globalization;
using UAIX.LmRuntime.LocalEndpoint;
if (args.Length != 4)
{
Console.Error.WriteLine(
"Usage: LocalModelSample <model.gguf> <sha256> <byte-count> <prepared-prompt>");
return 2;
}
string modelPath = Path.GetFullPath(args[0]);
string expectedSha256 = args[1];
long expectedByteCount = long.Parse(args[2], CultureInfo.InvariantCulture);
string preparedPrompt = args[3];
string trustedModelRoot = Path.GetDirectoryName(modelPath)
?? throw new InvalidOperationException("The model path has no parent directory.");
var runtime = new LocalGgufRuntime();
var sessionContext = 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(sessionContext);
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 = sessionContext
});
LocalGgufGenerationResult result = session.GenerateGreedy(
new LocalGgufGenerationRequest
{
Prompt = preparedPrompt,
MaximumTokens = 128,
ResetSession = true,
AddSpecialTokens = false,
ParseSpecialTokens = false,
RemoveSpecialTokens = false,
UnparseSpecialTokens = true,
CleanSpaces = false
},
CancellationToken.None);
Console.WriteLine(result.GeneratedText);
return 0;Prompt boundary: LocalEndpoint accepts a prepared prompt. The host remains responsible for choosing the model-specific chat template and special-token behavior.
4. Run the application
dotnet run -- \
./models/model.gguf \
<expected-sha256> \
<expected-byte-count> \
"Write one sentence about local inference."Successful loading proves that the current file matched the supplied digest and byte count and passed the configured intake path. Successful generation proves only that the named artifact and prepared prompt worked through the executed path.
5. Keep resource and session ownership explicit
- Keep
LocalGgufModelalive while any child session is active. - Create a separate
LocalGgufSessionfor each independent conversation or worker. - Use
ResetSession = truefor a new sequence. - Use
ResetSession = falseonly when the next prepared prompt deliberately continues the same session state. - Dispose the session before the model. The
usingdeclarations above enforce that order. - Pass a cancellation token from the host for long-running work.
6. Choose the package required for lower-level work
| Required For | Package | Owned layer |
|---|---|---|
| Application integration | LocalEndpoint | Verified loading, sessions, and generation. |
| GGUF inspection and validation | Gguf | Metadata, tensor descriptors, hashing, sharding, mapped bytes. |
| Tokenizer and chat-template work | Tokenization | Encode/decode, special tokens, templates, token budgets. |
| LLaMA graph/session internals | Models.Llama | Configuration, binding, sessions, KV cache, forward execution. |
| Token selection and stop handling | Sampling | Logit transforms, deterministic state, selection, stops. |
Compare the full package family, backend boundaries, and direct dependencies →
7. Handle failures without weakening verification
.gguf extension does not establish compatibility.