Following its showcase during the.NET Conf 2026 keynote earlier this month, Senior Program Manager Luis Quintanilla demonstrated on the.NET Blog how developers can go from zero to a tool-calling local AI console app in minutes—without sending a single prompt to the cloud, paying per-token API fees, or even creating a .csproj file.
What Llama on Windows Actually Does Under the Hood
Created by the Hugging Face and llama.cpp teams, Llama on Windows is a free, open-source Windows 11 companion app built natively with .NET 10 and WinUI 3—essentially a WinUI 3 port of Llama for Mac, according to the project's ggml-org/Llama-Windows repository on GitHub. Rather than reinventing an inference engine, it sits quietly in your Windows system tray and manages a llama.cpp server (llama serve) behind the scenes.
For Windows power users and developers, a few design choices make it stand out from ad-hoc local LLM setups:
- Hardware-aware catalog: Instead of guessing whether a 7B or 4B model will choke your system, the tray flyout shows hardware-fit indicators next to recommended models and lets you search thousands more on the Hugging Face Hub.
- Instant
Alt+Spaceoverlay: Beyond a browser-based chat interface, pressingAlt+Spacefrom any Windows app summons a borderless chat overlay whose window hides rather than closes, keeping your active conversation ready on the next keypress, per the GitHub repository's documentation. - Shared Hugging Face cache: Downloaded models live in
%USERPROFILE%\.cache\huggingface\hub, meaning thellamaCLI and other Hugging Face tools can reuse the exact same multi-gigabyte weights without duplicating files on your SSD. - Smarter memory eviction: According to Microsoft's walkthrough, Llama loads models on demand and unloads them after five minutes of idle time by default (configurable in Settings). The GitHub README adds that Llama actually supports memory-bounded multi-model serving, keeping models resident within a 1 GiB safety margin using least-recently-used (LRU) eviction rather than enforcing a strict one-model limit.
Equally important for enterprise IT pros and privacy-conscious builders: the GitHub project documentation states that Llama sends no telemetry—no analytics, no event tracking, and no install IDs. Outbound HTTP traffic is restricted to model downloads, release-update checks, and local loopback requests, while prompts and inference remain strictly on your machine.
Installing Llama and Pulling Your First Model
Llama on Windows targets Windows 11 and ships as a signed .msixbundle supporting both x64 and ARM64 PCs, per the Llama-Windows repository. You can grab the installer from llama.app or deploy it straight from Windows Terminal via winget:
winget install 9PPPSM6Q21Q6 --source msstore
Once installed, launch Llama from the Start menu so its icon appears in the system tray. From there, getting a model running takes just a few clicks:
- Select the Llama tray icon and pick a model family from the catalog.
- Choose a size and quantization that matches your PC's hardware-fit indicator. In the.NET Blog walkthrough, Quintanilla selects Gemma 4, E4B, Balanced (
Q4_0) (ggml-org/gemma-4-E4B-it-GGUF:Q4_0). - Click the download arrow and give it time—model weights routinely run several gigabytes.
- Once downloaded, click the model to open its details, pick a context length guided by the memory-fit estimates (which the GitHub README notes are calculated from the GGUF header and saved per model), and click Chat with model to test it in the browser.
Power users who want to fine-tune parameters like ctx-size, temp, or top-p can also store per-model overrides in %USERPROFILE%\.llama\models.user.ini. If llama.cpp rejects an unsupported flag in that file, Llama automatically falls back to defaults and surfaces a warning until you fix it.
Quick Reference: Key Paths and Commands
| Component | Location or Command | Purpose |
|---|---|---|
| App Install (Store) | winget install 9PPPSM6Q21Q6 --source msstore | Installs Llama on Windows 11 (x64 / ARM64) |
| .NET 11 SDK Install | winget install Microsoft.DotNet.SDK.11 | Required for the C# file-based sample |
| Local API Endpoint | [url]http://localhost:9931[/url] | Default llama serve REST and OpenAI-compatible base URL |
| Shared Model Cache | %USERPROFILE%\.cache\huggingface\hub | Stores downloaded GGUF weights for Llama and CLI tools |
| Settings & Logs | %LOCALAPPDATA%\Llama | Houses local application configuration and diagnostics |
| Per-Model Overrides | %USERPROFILE%\.llama\models.user.ini | Custom llama.cpp inference parameters per model ID |
Calling Local Models from a.NET 11 File-Based App
Chatting in a tray overlay is neat, but the real payoff for developers is wiring local inference directly into software. Because Llama exposes an OpenAI-compatible REST API on [url]http://localhost:9931[/url]—complete with /v1/chat/completions and /v1/models—your.NET code can use the standard OpenAI client library alongside Microsoft.Extensions.AI without writing custom HTTP plumbing.
Microsoft released .NET 11 on November 10, 2026, bringing runtime 11.0.0, SDK 11.0.100, and C# 15 as the default for net11.0 targets. If you haven't installed it yet, pull it down with winget:
winget install Microsoft.DotNet.SDK.11
Next, create a single file named llama-chat.cs. Notice there is no .csproj file anywhere in sight: starting in.NET 10 preview 4, C# file-based apps gained the #:package directive to declare NuGet dependencies inline. Both Microsoft.Extensions.AI and Microsoft.Extensions.AI.OpenAI shipped their 11.0.0 releases on NuGet on November 11, 2026 (with a 11.0.1 patch for Microsoft.Extensions.AI arriving shortly thereafter).
#!/usr/bin/env dotnet
#:package [email][email protected][/email]
#:package [email][email protected][/email]
using System.ClientModel;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text.Json;
using Microsoft.Extensions.AI;
using OpenAI;
// Llama serves an OpenAI-compatible API on localhost. Set LLAMA_ENDPOINT if you changed the port.
var endpoint = Environment.GetEnvironmentVariable("LLAMA_ENDPOINT")?? "[url]http://localhost:9931/v1[/url]";
using var http = new HttpClient();
// Ask Llama which models it can serve. This also tells us whether it's running.
List<string> models;
try
{
models = [.. (await GetLlamaModelsAsync()).Select(m => m.GetProperty("id").GetString()!)];
}
catch (HttpRequestException)
{
Console.WriteLine($"Couldn't reach Llama at {endpoint}. Open Llama from the Start menu and try again.");
return 1;
}
if (models.Count == 0)
{
Console.WriteLine("Llama doesn't have any models yet. Open Llama from the system tray and download a model.");
return 1;
}
Console.WriteLine("Models available in Llama:");
models.ForEach(m => Console.WriteLine($" {m}"));
// Use the model passed as an argument, or the first one Llama reports.
var model = args.Length > 0? args[0]: models[0];
Console.WriteLine($"\nChatting with {model}. Press Enter on an empty line to exit.");
// No API key is required by default, but the OpenAI client expects a value.
IChatClient client = new OpenAIClient(new ApiKeyCredential("no-key-required"), new OpenAIClientOptions { Endpoint = new Uri(endpoint) })
.GetChatClient(model)
.AsIChatClient()
.AsBuilder()
.UseFunctionInvocation()
.Build();
var options = new ChatOptions
{
Tools = [AIFunctionFactory.Create(GetMachineInfo), AIFunctionFactory.Create(ListModels)]
};
List<ChatMessage> history = [new(ChatRole.System, "You are a helpful assistant running locally on the user's PC. Keep answers short.")];
while (true)
{
Console.Write("\nYou: ");
var prompt = Console.ReadLine();
if (string.IsNullOrWhiteSpace(prompt))
{
break;
}
history.Add(new(ChatRole.User, prompt));
Console.Write("Llama: ");
List<ChatResponseUpdate> updates = [];
await foreach (var update in client.GetStreamingResponseAsync(history, options))
{
Console.Write(update.Text);
updates.Add(update);
}
Console.WriteLine();
history.AddMessages(updates);
}
return 0;
// Calls GET /v1/models. Llama adds details such as load status to the standard OpenAI response.
async Task<List<JsonElement>> GetLlamaModelsAsync()
{
using var json = JsonDocument.Parse(await http.GetStringAsync($"{endpoint}/models"));
return [.. json.RootElement.GetProperty("data").EnumerateArray().Select(m => m.Clone())];
}
[Description("Lists the models downloaded in Llama on this PC, whether each one is loaded in memory, and which one the user is chatting with.")]
async Task<string> ListModels()
{
var lines = (await GetLlamaModelsAsync()).Select(m =>
{
var id = m.GetProperty("id").GetString();
var status = m.TryGetProperty("status", out var s)? s.GetProperty("value").GetString(): "unknown";
return $"{id} ({status}){(id == model? ", current chat": "")}";
});
return string.Join(Environment.NewLine, lines);
}
[Description("Gets the name, operating system, processor count, and.NET version of the computer the user is chatting from.")]
static string GetMachineInfo() =>
$"{Environment.MachineName}, {RuntimeInformation.OSDescription}, {Environment.ProcessorCount} logical processors,.NET {Environment.Version}";
With Llama running in the tray, execute the script directly from PowerShell or Command Prompt:
dotnet run llama-chat.cs
Or target a specific model ID copied from the tray details pane:
dotnet run llama-chat.cs -- ggml-org/gemma-4-E4B-it-GGUF:Q4_0
You don't need to pre-load the model manually; Llama spins it up on the first incoming request, meaning only that initial response pays the cold-load penalty.
Why the IChatClient Pattern Matters
Look closely at what that 85-line script actually accomplishes:
- Preflight discovery and health checks: Calling
GET /v1/modelschecks whether Llama is alive and reads custom metadata—like each model's memory load status—that Llama adds alongside standard OpenAI fields. - Zero-key local authentication (with one caveat): The
OpenAIClientSDK insists on a non-emptyApiKeyCredential, so the sample passes"no-key-required". As the officialllama.appAPI documentation clarifies, no authentication is enforced by default, though if you manually launchllama servewith--api-key, clients must supply that key as a Bearer token. - Local tool calling without cloud leakage:
AIFunctionFactory.CreatewrapsGetMachineInfoandListModelsinto callableAIFunctiondefinitions using their[Description]attributes. When.UseFunctionInvocation()wraps theIChatClient,FunctionInvokingChatClientintercepts the model's function-call request, executes the C# method locally on your PC, and feeds the result back into the conversation history to generate the final streamed answer,. - Provider portability: As Quintanilla emphasized during.NET Conf 2026, coding against
IChatClientkeeps your chat loop intact even if you swap models or providers later.
Previously, Microsoft's own Generative AI for Beginners.NET samples often pointed local developers toward OllamaSharp and OllamaApiClient running on port 11434. Llama on Windows gives.NET developers an alternative anchored directly in llama.cpp and the Hugging Face cache, while speaking standard OpenAI endpoints—meaning you don't even need a vendor-specific SDK to switch between a local model on localhost:9931 and a cloud deployment.
Critical Caveats and Where to Go Next
Before you ship a desktop Copilot clone powered by a 4-bit model, keep a few practical realities in mind:
- Tool calling isn't universal: Small or heavily quantized models frequently ignore function schemas or hallucinate arguments. The.NET Blog explicitly advises switching to a larger model—or verifying tool-calling support on the model's Hugging Face card—if your functions aren't firing.
- Hardware indicators are estimates, not guarantees: GGUF memory-fit indicators help you avoid immediate out-of-memory crashes, but tokens-per-second throughput still depends heavily on your GPU VRAM, system RAM bandwidth, and chosen context window.
- Beyond basic chat: The sample only scratches the surface of
llama serve. According to thellama.appAPI documentation, the server also exposes/v1/embeddings(for pooling-enabled models),/v1/rerank(for reranker models), structured JSON schema outputs, multimodal image and audio inputs, an Anthropic-compatible/v1/messagesendpoint, and nativellama.cppdiagnostics. - Hybrid local-plus-cloud architectures: If a local model isn't strong enough for a tough query—or isn't loaded—Microsoft Learn documents experimental
Microsoft.Extensions.AIpatterns likeRoutingChatClientandFailoverChatClientto route requests dynamically or fall back to another client when one fails before producing output, alongside experimentalMessageCountingChatReducerandSummarizingChatReducerclasses to keep long chat histories from overflowing smaller local context windows.
For Windows developers who have been waiting for local AI to feel like a first-class citizen in Visual Studio and the.NET CLI rather than a Python side quest, Llama on Windows paired with .NET 11 hits a remarkably sweet spot: minimal setup, zero per-request cloud bills, and clean C# abstractions that scale up whenever you decide to bring cloud models into the mix.
References
- Run local models in your .NET apps with Llama on Windows .NET Blog · 2026-11-23T18:05:00+00:00
- github.com github.com
- Llama github.com