Run local models in your .NET apps with Llama on Windows
Llama on Windows, a free tray app from Hugging Face and llama.cpp, serves local models at localhost:9931 so .NET 11 apps can call them with no API key.
By Dillip Chowdary • Nov 28, 2026 • Source: .NET Blog

At a glance
- Product
- Llama on Windows
- Made by
- Hugging Face and llama.cpp teams
- Platform
- Windows 11 tray app, .NET 10 and WinUI 3
- Price
- Free and open source
- Local endpoint
- http://localhost:9931 (OpenAI-compatible)
- Sample needs
- .NET 11 SDK, Microsoft.Extensions.AI 11.0.0
In this post
Microsoft's .NET team has published a walkthrough for calling local AI models from .NET apps through Llama on Windows, a Windows 11 tray app from the Hugging Face and llama.cpp teams, in the .NET Blog guide to running local models with Llama on Windows. The post, by Senior Program Manager Luis Quintanilla, went up on November 23, 2026, and Llama on Windows was announced in the .NET Conf 2026 keynote.
This piece covers what Llama on Windows does, how to install it and download a model, and how a .NET 11 C# file-based app talks to it through an OpenAI-compatible local server. It is written for .NET developers who want prompts and responses to stay on their own PC, work offline after a model download, and experiment without paying per request.
01A tray app built on llama.cpp
Llama is a Windows 11 app that lives in the system tray. It is built with .NET 10 and WinUI 3, powered by llama.cpp, and comes from the Hugging Face and llama.cpp teams. It is open source, free to download at llama.app, and its source code sits in the Llama-Windows repository on GitHub.
From the tray, users can browse models recommended for their hardware and download them in one click, or search the Hugging Face Hub for thousands of other models. They can chat with a model in the browser, or press Alt+Space from any app to open a chat overlay.
Under the hood, Llama manages a llama.cpp server. Models run on the PC and are stored in the standard Hugging Face cache, so other tools such as the llama command line can use the same files.
02Installing Llama and a first model
Llama is listed in the Microsoft Store, so it installs with winget from a terminal. It can also be downloaded from llama.app, and once installed it opens from the Start menu and places its icon in the tray.
winget install 9PPPSM6Q21Q6 --source msstoreThe walkthrough's model setup follows these steps:
- Open the catalog Select the Llama icon in the system tray.
- Pick a model Choose a model family, then a size and version that fit the PC, using the hardware-fit indicator next to each version. The author used Gemma 4, E4B, Balanced (Q4_0).
- Download Select the download arrow; downloads can run to several GB depending on the model.
- Set context length Open the model's details and choose a context length guided by the memory-fit indicators.
- Chat Select Chat with model and ask a question in the browser chat.
Llama loads models when they are used and unloads them after five minutes idle, so developers do not manage memory by hand. The idle timeout can be changed in Llama's settings.
03OpenAI-compatible server on localhost:9931
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
Llama runs its llama.cpp server at http://localhost:9931, with endpoints that follow the OpenAI API format, such as /v1/chat/completions and /v1/models. That means existing OpenAI client libraries work against it. Requests go to the local machine rather than OpenAI, and no API key is needed.
In .NET, the guide pairs the OpenAI library with Microsoft.Extensions.AI and its IChatClient interface. That shared interface lets an app add chat, streaming and tool calling without tying the code to one model provider.
The sample needs Llama running with at least one downloaded model, plus the .NET 11 SDK. The SDK also installs through winget with winget install Microsoft.DotNet.SDK.11.
04A file-based C# chat app with two tools
The sample is a single file, llama-chat.cs, with no project file, using .NET 11's file-based apps. It references Microsoft.Extensions.AI and Microsoft.Extensions.AI.OpenAI, both at version 11.0.0, and reads an optional LLAMA_ENDPOINT environment variable for users who changed the port. The complete code is in the Llama on Windows .NET sample repository.
The app first calls GET /v1/models to list what Llama can serve; if that fails, it tells the user to open Llama from the Start menu. Llama adds details to the standard response, such as whether each model is loaded in memory. The app then creates an OpenAIClient pointed at the local endpoint, converts it with AsIChatClient(), and adds automatic tool calling with UseFunctionInvocation().
AIFunctionFactory.Create turns two methods, GetMachineInfo and ListModels, into tools the model can call, using each method's Description attribute. Both tools run on the PC, so machine details stay local. GetStreamingResponseAsync streams each reply, and responses are added to the history so the model keeps context.
05Running the sample and picking models
With Llama running, the app starts with dotnet run llama-chat.cs and chats with the first model Llama reports. Passing a model ID picks a different one; IDs can be copied from a model's details in the tray.
dotnet run llama-chat.cs -- ggml-org/gemma-4-E4B-it-GGUF:Q4_0Models do not need to be loaded first, since Llama loads one on the first request, which can make that first reply slower. In the author's run, the model used ListModels to report ggml-org/gemma-4-E4B-it-GGUF:Q4_0, used GetMachineInfo to report Windows 10.0.26200 with 16 logical processors and .NET 11.0.0, and answered a general question about Rayleigh scattering without a tool.
Note: Tool calling depends on the model. If a model ignores the tools, the guide suggests a larger model or one that lists tool support on its Hugging Face model card.
Because the chat loop depends only on IChatClient, Quintanilla notes it can stay the same if developers later switch models or providers. The post's next steps point to the Llama API docs for embeddings and structured output, the Microsoft.Extensions.AI docs, and combining Llama with cloud models through routing and failover.
Frequently asked questions
What is Llama on Windows?
Llama on Windows is a free, open-source Windows 11 tray app from the Hugging Face and llama.cpp teams. It finds, downloads and runs open models on the PC using a llama.cpp server it manages.
How do I install Llama on Windows?
Run winget install 9PPPSM6Q21Q6 --source msstore from a terminal, or download it from llama.app. Then open Llama from the Start menu and pick a model from the tray catalog.
How do .NET apps call models running in Llama?
Llama serves an OpenAI-compatible API at http://localhost:9931 with endpoints such as /v1/chat/completions and /v1/models. .NET apps use the OpenAI library with Microsoft.Extensions.AI and IChatClient, and no API key is required.
Does Llama on Windows keep models in memory?
Llama loads a model on first use and unloads it after five minutes of inactivity. The idle timeout can be changed in its settings.
Does tool calling work with every local model?
No. Tool calling depends on the model, and the guide recommends a larger model or one whose Hugging Face model card lists tool support.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Electric boat maker Zin Boats raises $5M and launches propulsion business beyond the water
Read →
Hex Package Manager Warns of Potential Data Breach
Read →
Most Unicorns Are Worth More Than Their Last Funding-Round Valuations, Crunchbase…
Read →
See what 6 builders are making with Gemini 4 Hydrogen
Read →
Today's Tech Pulse briefing
Full briefing →
Advertisement