Dotnet-skills dotnet-microsoft-extensions-ai
Build provider-agnostic .NET AI integrations with `Microsoft.Extensions.AI`, `IChatClient`, embeddings, middleware, structured output, vector search, and evaluation.
install
source · Clone the upstream repo
git clone https://github.com/managedcode/dotnet-skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/managedcode/dotnet-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/catalog/Libraries/Microsoft-Extensions-AI/skills/dotnet-microsoft-extensions-ai" ~/.claude/skills/managedcode-dotnet-skills-dotnet-microsoft-extensions-ai && rm -rf "$T"
manifest:
catalog/Libraries/Microsoft-Extensions-AI/skills/dotnet-microsoft-extensions-ai/SKILL.mdsource content
Microsoft.Extensions.AI
Trigger On
- building or reviewing
code that uses.NET
,Microsoft.Extensions.AI
,Microsoft.Extensions.AI.Abstractions
,IChatClient
,IEmbeddingGenerator
, orChatOptionsAIFunction - adding
, local-model chat via Ollama, AI app templates, or theIImageGenerator
quickstarts for assistants and MCP.NET AI - choosing between low-level AI abstractions, provider SDKs, vector-search composition, evaluation libraries, and a fuller agent framework
- adding streaming chat, structured output, embeddings, tool calling, telemetry, caching, or DI-based AI middleware
- wiring
,Microsoft.Extensions.VectorData
, MCP tooling, or evaluation packages around a provider-agnostic AI appMicrosoft.Extensions.DataIngestion
Workflow
- Classify the request first: plain model access, tool calling, embeddings/vector search, evaluation, image generation, local-model prototyping, MCP bootstrap, or true agent orchestration.
- Default to
for application and service code that needs provider-agnostic chat, embeddings, middleware, structured output, and testability.Microsoft.Extensions.AI - Reference
directly only when authoring provider libraries or lower-level reusable integration packages.Microsoft.Extensions.AI.Abstractions - Model
andIChatClient
composition explicitly in DI. Keep options, caching, telemetry, logging, and tool invocation inspectable in the pipeline.IEmbeddingGenerator - Treat chat state deliberately. For stateless providers, resend history. For stateful providers, propagate
rather than assuming all providers behave the same way.ConversationId - Use
andMicrosoft.Extensions.VectorData
as adjacent building blocks for RAG instead of hand-rolling store abstractions prematurely. Treat the embedding model, vector dimensions, and collection schema as one owned contract: changing any of them means reindexing rather than reusing old vector data. InMicrosoft.Extensions.DataIngestion
v10.5.0, update any named-argument usage ofdotnet/extensions
fromVectorStoreVectorAttribute
toDimensions:
; this is source-breaking only.dimensions: - Treat the
quickstarts as bootstrap paths, not finished architecture. They now cover minimal assistants, MCP client/server flows, local models, app templates, and image generation. Start there for a vertical slice, then harden the DI, telemetry, and evaluation story here..NET AI - Escalate to
when the requirement becomes agent threads, multi-agent orchestration, higher-order workflows, durable execution, or remote agent hosting.dotnet-microsoft-agent-framework - Validate with real providers, realistic prompts, and evaluation gates so the abstraction layer actually buys portability and reliability.
Architecture
flowchart LR A["Task"] --> B{"Need agent threads, multi-agent orchestration, or remote agent hosting?"} B -->|Yes| C["Use Microsoft Agent Framework on top of `Microsoft.Extensions.AI.Abstractions`"] B -->|No| D{"Need provider-agnostic chat, embeddings, tools, typed output, or evaluation?"} D -->|Yes| E["Use `Microsoft.Extensions.AI`"] E --> F["Compose `IChatClient` / `IEmbeddingGenerator` in DI"] F --> G["Add caching, telemetry, tools, vector data, and evaluation deliberately"] D -->|No| H["Use plain provider SDKs or deterministic .NET code"]
Core Knowledge
contains the core exchange contracts such asMicrosoft.Extensions.AI.Abstractions
,IChatClient
, message/content types, and tool abstractions.IEmbeddingGenerator<TInput, TEmbedding>
adds the higher-level application surface: middleware builders, automatic function invocation, caching, logging, and OpenTelemetry integration.Microsoft.Extensions.AI- Most apps and services should reference
; provider and connector libraries usually reference only the abstractions package.Microsoft.Extensions.AI
centers onIChatClient
andGetResponseAsync
. The returnedGetStreamingResponseAsync
orChatResponse
objects carry messages, tool-related content, metadata, and optional conversation identifiers.ChatResponseUpdate- Local-model quickstarts still route through the same
abstraction. Ollama-backed clients are useful for low-cost prototyping, offline dev loops, and portability testing, but you still own chat history replay, latency, and model-quality tradeoffs.IChatClient
is the normal control plane for model ID, temperature, tools,ChatOptions
, and provider-specific raw options.AdditionalProperties- Tool calling is modeled with
,AIFunction
, andAIFunctionFactory
. Ambient data can flow through closures,FunctionInvokingChatClient
,AdditionalProperties
, or DI.AIFunctionArguments.Context - Tool calling can target local .NET methods, external APIs, or MCP-backed tools. The model requests calls; your app still owns execution, validation, and side-effect boundaries.
- Tool definitions consume request tokens. Keep tool descriptions short and register only the tools relevant for the current conversation or workflow.
can handle the tool-invocation loop and parallel tool-call responses automatically when the provider/model supports that shape.FunctionInvokingChatClient
is the standard abstraction for semantic search, vector indexing, similarity, and cache-key generation. Pair it withIEmbeddingGenerator
for vector store operations, and keep the embedding model, collection dimensions, and chunking/versioning story aligned so reindexing stays explicit.Microsoft.Extensions.VectorData.Abstractions
is the experimental MEAI image surface. TreatIImageGenerator
as an intentional opt-in, keep image generation separate from chat concerns, and compose logging/caching/hosting middleware around it the same way you would forMEAI001
.IChatClient
gives you the document-side RAG pipeline:Microsoft.Extensions.DataIngestion
, document readers like MarkItDown/Markdig, document processors such asIngestionDocument
, chunkers, chunk processors,ImageAlternativeTextEnricher
, andVectorStoreWriter<T>
for end-to-end composition.IngestionPipeline<T>
is partial-success oriented. HandleIngestionPipeline<T>.ProcessAsync
deliberately instead of assuming one failed document should automatically crash the whole ingestion run.IAsyncEnumerable<IngestionResult>
gives you quality, NLP, safety, caching, and reporting layers for regression checks and CI gates.Microsoft.Extensions.AI.Evaluation.*- The official
docs now make MCP, assistants, local models, templates, and text-to-image part of the same app-level story. Use.NET AI
when the protocol itself becomes the design problem; stay here when you still mostly need app composition arounddotnet-mcp
and friends.IChatClient
builds on these abstractions. Use it when you need autonomous orchestration, threads, workflows, hosting, or multi-agent collaboration instead of just model composition.Microsoft Agent Framework
Decision Cheatsheet
| If you need | Default choice | Why |
|---|---|---|
| App-level provider abstraction with middleware | | Highest leverage for apps and services |
| A reusable provider or connector library | | Keeps your package at the contract layer |
| Typed chat or UI streaming | with / | Common request/response shape across providers |
| Tool calling from .NET methods | + | Native function metadata and invocation pipeline |
| Typed structured output | extensions | Keeps schema intent in code instead of prompt parsing |
| Vector search or RAG | + | Standardizes embeddings and store access |
| Local model prototyping | with an Ollama-backed implementation | Keeps the app on the MEAI abstractions while you validate prompts or UX locally |
| Text-to-image or image-generation middleware | | Use the dedicated image abstraction instead of overloading chat APIs |
| Evaluation and regression gates | | Relevance, safety, task adherence, caching, reports |
| Agent threads or multi-step autonomous orchestration | | This is beyond plain provider abstraction |
Common Failure Modes
- Referencing only
in an app and then rebuilding middleware, telemetry, or function invocation by hand.Microsoft.Extensions.AI.Abstractions - Treating
as if it already gives you durable agent threads, orchestration, or hosted-agent semantics.IChatClient - Mixing provider-specific assistants APIs with
as if they were the same runtime contract.IChatClient - Forgetting to distinguish stateless history replay from stateful
flows.ConversationId - Hiding important chat behavior in singleton service fields instead of explicit message history, options, or persistent storage.
- Adding tool calling without validating parameter binding, invalid input behavior, side effects, or DI-scoped dependencies.
- Building RAG without stable chunking, embedding-model/version tracking, or vector dimension discipline.
- Shipping AI features without evaluation baselines, safety checks, or telemetry for prompt/model drift.
Deliver
- a justified package and abstraction choice:
only vs fullAbstractionsMicrosoft.Extensions.AI - a concrete
/IChatClient
composition strategyIEmbeddingGenerator - explicit tool-calling, options, state, caching, logging, and telemetry decisions
- vector-search, evaluation, or MCP integration guidance when the scenario needs it
- a clear escalation path to Agent Framework when the problem exceeds provider abstraction
Validate
- the abstraction layer solves a real portability, testability, or composition problem
- provider registration and middleware order stay explicit in DI
- chat state management matches whether the provider is stateless or stateful
- structured output, tool invocation, and embedding flows are typed and observable
- vector store, embedding model, and chunking strategy are consistent
- evaluation or safety gates exist for important prompts and agent-like behaviors
- agentic requirements are not being under-modeled as a simple
integrationIChatClient
When exact wording, edge-case API behavior, or less-common examples matter, check the local official docs snapshot before relying on summaries.
References
- official-docs-index.md - Slim local snapshot map with direct links to every mirrored
docs page plus API-reference pointers.NET AI - patterns.md - Package choice,
, embeddings, DI pipelines, tool-calling, and Agent Framework escalation guidanceIChatClient - examples.md - Quickstart-to-task map covering chat, structured output, function calling, vector search, local models, MCP, and assistants
- evaluation.md - Quality, NLP, safety, caching, reporting, and CI-oriented evaluation guidance