Reach for a vendor’s SDK and it works — until you want to swap a model, add logging, or target a second provider. Then you’re rewriting plumbing instead of building.
.NET’s answer is four building blocks that sit above the vendors:
- Microsoft.Extensions.AI — one API across every LLM provider
- Microsoft.Extensions.VectorData — embeddings and semantic search
- Microsoft Agent Framework — agentic workflows
- Model Context Protocol (MCP) — interoperability
Most of the work lives in the first one.
Microsoft.Extensions.AI: one API, many providers
If you’ve written ASP.NET Core, this feels like home — same DI, same builder pattern. OpenAI, OllamaSharp, Azure OpenAI and more all sit behind one IChatClient. Switching providers becomes a registration detail, not a rewrite. Retries, token limits, and a middleware pipeline come for free.
Structured output, the easy way
Ask for a typed result; the library generates the schema and deserializes for you. No JSON string-wrangling.
| |
Standardised requests and responses
Per-vendor parameters get normalised through ChatOptions (temperature, max tokens), and responses carry UsageDetails for token accounting. Temperature is just a randomness dial: low = predictable, high = creative.
Middleware is where the power is
Chat clients are built, so you wrap any client in a pipeline — security, throttling, telemetry, tracing — applied uniformly across providers.
| |
Multi-modal with DataContent
Richer payloads extend AIContent: ErrorContent, UserInputRequestContent, FunctionCallContent, HostedFileContent, UriContent, and DataContent (bytes + media type). The last one lets you hand a model an image — multi-modal and typed output in one call:
| |
No vendor-specific encoding, no manual contract — pass bytes, get a typed ImageAnalysis.
The other three blocks
- VectorData — embeddings and semantic search; the base for RAG over your own data.
- Agent Framework — multi-step agentic workflows where the model plans and acts.
- MCP — a shared standard so tools and models from different vendors interoperate.
Most projects start and stay on Microsoft.Extensions.AI, reaching for the rest when they actually need retrieval, autonomy, or interop.
Final thought
These libraries don’t do anything a vendor SDK can’t. They put a stable, .NET-shaped seam between your code and a market that shifts every few months — so the next model is a registration line, not a weekend.
Adapted from Jeremy Likness’s .NET AI Essentials – The Core Building Blocks Explained on the .NET Blog.