Skip to main content

AGUI.Hosting.AspNetCore

AGUI.Hosting.AspNetCore is the .NET server-side hosting layer for AG-UI. It turns any Microsoft.Extensions.AI.IChatClient into an AG-UI endpoint that accepts RunAgentInput and streams AG-UI events to a frontend UI.
dotnet add package AGUI.Hosting.AspNetCore

The core idea

You do not learn a new agent programming model. You host an IChatClient. The package adapts AG-UI request bodies into Microsoft.Extensions.AI messages and options, calls your chat client, then converts the streamed ChatResponseUpdate values back into AG-UI protocol events.

What it depends on

AGUI.Hosting.AspNetCore is intentionally small:
  • AG-UI protocol types from AGUI.Abstractions
  • Microsoft.Extensions.AI.Abstractions
  • ASP.NET Core, through Microsoft.AspNetCore.App
It does not depend on the .NET AG-UI client package. The server and client packages share protocol types, but remain independent.
The hosting package targets net10.0, net9.0, and net8.0.

What the hosting layer handles

The hosting layer handles the protocol details for you:
  • Converts RunAgentInput.Messages into ChatMessage values
  • Installs client-declared tools on ChatOptions
  • Stores the original input under ChatOptions.AdditionalProperties[AGUIConstants.RunAgentInputKey]
  • Emits RUN_STARTED and RUN_FINISHED
  • Maps text, reasoning, tool calls, tool results, state, raw events, and interrupts to AG-UI events
  • Streams the result as Server-Sent Events

Server and client together

Use AGUI.Hosting.AspNetCore when you are building an AG-UI server. Use AGUI.Client when .NET code needs to consume an AG-UI endpoint as an IChatClient.

Endpoints

Build the canonical ASP.NET Core AG-UI endpoint

Extensibility

Customize stream conversion with AGUIStreamOptions