Skip to main content
.NETFramework4.6.2net8.0net9.0.NETStandard2.0

Utilities for working with generative AI components.

Published
Feb 16, 2025
1y ago
Total Downloads
38.8M
38,796,061

Install

dotnet add package Microsoft.Extensions.AI --version 9.3.0-preview.1.25114.11
ProductVersions
.NET
net8.0net9.0
.NET Standard
netstandard2.0
Other
.NETFramework4.6.2

README

Microsoft.Extensions.AI

Provides utilities for working with generative AI components.

Install the package

From the command-line:

dotnet add package Microsoft.Extensions.AI

Or directly in the C# project file:

<ItemGroup>
  <PackageReference Include="Microsoft.Extensions.AI" Version="[CURRENTVERSION]" />
</ItemGroup>

Usage Examples

Please refer to the README for the Microsoft.Extensions.AI.Abstractions package.

Feedback & Contributing

We welcome feedback and contributions in our GitHub repo.

Running the integration tests

If you're working on this repo and want to run the integration tests, e.g., those in Microsoft.Extensions.AI.OpenAI.Tests, you must first set endpoints and keys. You can either set these as environment variables or - better - using .NET's user secrets feature as shown below.

Configuring OpenAI tests (OpenAI)

Run commands like the following. The settings will be saved in your user profile.

cd test/Libraries/Microsoft.Extensions.AI.Integration.Tests
dotnet user-secrets set OpenAI:Mode OpenAI
dotnet user-secrets set OpenAI:Key abcdefghijkl

Optionally also run the following. The values shown here are the defaults if you don't specify otherwise:

dotnet user-secrets set OpenAI:ChatModel gpt-4o-mini
dotnet user-secrets set OpenAI:EmbeddingModel text-embedding-3-small

Configuring OpenAI tests (Azure OpenAI)

Run commands like the following. The settings will be saved in your user profile.

cd test/Libraries/Microsoft.Extensions.AI.Integration.Tests
dotnet user-secrets set OpenAI:Mode AzureOpenAI
dotnet user-secrets set OpenAI:Endpoint https://YOUR_DEPLOYMENT.openai.azure.com/
dotnet user-secrets set OpenAI:Key abcdefghijkl

Optionally also run the following. The values shown here are the defaults if you don't specify otherwise:

dotnet user-secrets set OpenAI:ChatModel gpt-4o-mini
dotnet user-secrets set OpenAI:EmbeddingModel text-embedding-3-small

Your account must have models matching these names.

Configuring Azure AI Inference tests

Run commands like the following. The settings will be saved in your user profile.

cd test/Libraries/Microsoft.Extensions.AI.Integration.Tests
dotnet user-secrets set AzureAIInference:Endpoint https://YOUR_DEPLOYMENT.azure.com/
dotnet user-secrets set AzureAIInference:Key abcdefghijkl

Optionally also run the following. The values shown here are the defaults if you don't specify otherwise:

dotnet user-secrets set AzureAIInference:ChatModel gpt-4o-mini
dotnet user-secrets set AzureAIInference:EmbeddingModel text-embedding-3-small

Configuring Ollama tests

Run commands like the following. The settings will be saved in your user profile.

cd test/Libraries/Microsoft.Extensions.AI.Integration.Tests
dotnet user-secrets set Ollama:Endpoint http://localhost:11434/

Changes from Previous Version

No structural changes between v9.1.0-preview.1.25064.3 and v9.3.0-preview.1.25114.11.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 4 target frameworks; confirm the exact target used by your application.The published metadata declares 28 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.