.NET AI tutorials

Build AI applications in C#. Work from a runnable sample, inspect the implementation, and verify what happens when a model, tool, or dependency behaves unexpectedly.

Live tutorials

6 guides

Start with the gateway for model access, or jump to the part of your application you’re working on. Each guide links to its companion C# project.

Model access

Provider-Agnostic Chat Gateway

Switch between Ollama, OpenAI, OpenRouter, and Azure OpenAI through configuration while keeping one chat interface in your ASP.NET Core application.

IChatClientGitHub
Observability

Observe .NET AI Apps with OpenTelemetry

Follow one request from a model call through an evidence tool to a second API. Find a slow dependency and explain how Triage can return HTTP 200 when Evidence returns 503.

Coming next

4 planned guides

These guides extend the current learning path into structured outputs, RAG data freshness, human-in-the-loop agent safety, and response caching. Each scope will be package- and API-verified before implementation.

Output contractsComing soon…

Structured LLM Output in .NET with JSON Schema and C#

Turn free-text purchase orders into strongly typed C# records with Microsoft.Extensions.AI structured output and JSON Schema. Validate required fields, enum values, totals, and business rules before accepting a model response.

RAG ingestionComing soon…

Build Incremental RAG Ingestion in .NET with Microsoft.Extensions.DataIngestion

Keep a retrieval index synchronized with changing source documents. Detect new, changed, and deleted content; reprocess only affected chunks; regenerate embeddings when required; and remove stale vectors without rebuilding the entire index.

Agent safetyComing soon…

Add Human Approval Before a .NET AI Agent Executes Tools

Pause a proposed write before execution, bind approval to the exact pending tool call, persist the decision, and safely resume or reject the action. Test rejection, duplicate approval, stale approval, and replay attempts.

Cost & isolationComing soon…

Cache LLM Responses in .NET with Microsoft.Extensions.AI and Tenant Isolation

Add distributed response caching around IChatClient. Build cache identity from tenant, model, prompt version, and other response-shaping inputs, then verify hits, expiry, invalidation, and strict cross-tenant isolation.

Developer references