AI Samples for .NET: Integrating AI into Your .NET Applications

AI Samples for .NET: Integrating AI into Your .NET Applications

Summary

The AI Samples for .NET repository provides a comprehensive collection of samples demonstrating how to integrate artificial intelligence into .NET applications. It features examples using Microsoft.Extensions.AI for unified API access to AI services and Microsoft.Extensions.AI.Evaluation for assessing LLM response quality. This resource is ideal for .NET developers looking to leverage AI, including large language models, in their projects.

Repository Info

Updated on October 11, 2025
View on GitHub

Tags

Click on any tag to explore related repositories

Introduction

The dotnet/ai-samples repository is the official home for .NET samples that showcase how to effectively use AI in your .NET applications. Whether you are new to AI or looking to deepen your understanding, this repository offers a structured path to learning, starting from foundational concepts and progressing to more advanced topics. It primarily focuses on Microsoft.Extensions.AI and Microsoft.Extensions.AI.Evaluation, providing practical examples for various AI scenarios.

Microsoft.Extensions.AI

Microsoft.Extensions.AI is a set of core .NET libraries developed in collaboration with the .NET ecosystem, including Semantic Kernel. These libraries offer a unified layer of C# abstractions for interacting with diverse AI services, such as small and large language models (SLMs and LLMs) and embeddings. Key benefits include a consistent API, flexibility to use any AI provider, ease of use for developers, and improved componentization.

Microsoft.Extensions.AI.Evaluation

Microsoft.Extensions.AI.Evaluation provides .NET libraries with tools to evaluate the quality and efficacy of LLM responses in intelligent applications. Built upon the core AI abstractions from Microsoft.Extensions.AI, these libraries help ensure the reliability and performance of your AI-powered features.

Getting Started

To begin exploring the AI samples, you should clone the repository to your local machine. Each sample typically includes its own README.md file with specific instructions for setup and execution.

git clone https://github.com/dotnet/ai-samples.git
cd ai-samples

Ensure you have the necessary .NET SDK installed. Individual samples may require API keys for services like OpenAI or Azure OpenAI, which you will need to configure according to their respective documentation.

Examples and Quickstarts

The repository is rich with practical examples, categorized for easy navigation. Each link points directly to the relevant README.md within the GitHub repository for detailed instructions.

Microsoft.Extensions.AI Implementations

Microsoft.Extensions.AI.Evaluation Examples

Quickstarts using OpenAI

Quickstarts using the Azure OpenAI SDK

Chat Samples

Build 2024 Tutorial

Follow along with the "Infusing your .NET Apps with AI: Practical Tools and Techniques" session from Build 2024. This tutorial covers integrating LLMs and other AI capabilities into .NET applications.

Why Use AI Samples for .NET?

This repository is an invaluable resource for .NET developers for several reasons:

  • Practical Learning: Provides hands-on examples to understand and implement AI concepts in C#.
  • Unified Abstractions: Showcases Microsoft.Extensions.AI, which offers a consistent and standard set of APIs for integrating various AI services, reducing complexity.
  • Flexibility: Demonstrates how to build AI applications that are provider-agnostic, allowing easy switching between different AI services like OpenAI, Azure OpenAI, and Ollama.
  • Evaluation Tools: Introduces Microsoft.Extensions.AI.Evaluation for robust testing and quality assurance of AI application responses.
  • Community and Best Practices: Aligns with the .NET ecosystem and promotes best practices for AI integration.

Useful Links