In this lesson you'll learn practical skills for building AI-enabled .NET applications. Concepts include text completions, chat conversations, streaming responses, structured output, function calling, and building middleware pipelines.
- Text completions and chat conversations
- Managing conversation history with chat roles
- Streaming responses for real-time output
- Getting structured output from AI models
- Function calling to extend AI with your code
- Building middleware pipelines with caching and telemetry
This lesson is divided into four parts:
The fundamentals of AI interaction—single prompts, conversations, and managing chat history.
Real-time responses and strongly-typed data from AI models.
Extend AI capabilities by letting models call your .NET functions.
Production-ready patterns with caching, telemetry, and custom behaviors.
All code samples for this lesson are located in the samples/CoreSamples/ directory. This includes:
- Chat & Completions:
BasicChat-01MEAI,BasicChat-02SK,BasicChat-03Ollama, etc. - Conversation History:
BasicChat-10ConversationHistory - Function Calling:
MEAIFunctions,MEAIFunctionsAzureOpenAI,MEAIFunctionsOllama
Each lesson document links directly to the relevant samples in this centralized location.
Start with the fundamentals:
Continue to Part 1: Text Completions and Chat Conversations →
Once you complete all parts of this lesson, you'll be ready to tackle more advanced patterns in Lesson 3:
- Retrieval-Augmented Generation (RAG): Ground AI responses in your own documents
- Semantic Search: Search by meaning, not just keywords
- Vision and Audio: Work with images and sound
Continue to Lesson 3: AI Patterns and Applications →
- Microsoft.Extensions.AI Documentation: The unified AI abstraction layer for .NET
- IChatClient Interface Guide: Complete reference for chat completions
- Build an AI Chat App with .NET: Step-by-step quickstart tutorial
- Request Structured Output: Getting typed responses from AI models