This example shows how to build a small Avalonia desktop application that embeds DotNetBrowser and runs a local browser-based AI feature with Transformers.js.
- .NET 8 SDK
- A DotNetBrowser license key
MainWindow.axamldeclares the app layout and theBrowserViewcontrol that displays the browser content.MainWindow.axaml.cscreates the Chromium engine and loads the local app URL.LocalAppSchemeHandler.csserves bundled files from theweb/directory.web/index.htmlcontains the web app UI.web/app.jsloads the local model and handles user actions.web/styles.cssstyles the web app UI.
Open MainWindow.axaml.cs and set your license key:
engine = EngineFactory.Create(new EngineOptions.Builder
{
LicenseKey = "<your_license_key>",
...
}.Build());From this directory:
dotnet runOr open LocalAiAssistant.sln in your IDE and run the LocalAiAssistant project.
When the window opens, wait for the model to load. Then type some text into the input field and click one of the actions. The app runs the model locally and shows the generated result in the same window.