Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
The official .NET library for the OpenAI API
| Date | Stars |
|---|---|
| 2026-07-31 | 2658 |
| 2026-08-01 | 2658 |
| 2026-08-02 | 2659 |
| 2026-08-03 | 2658 |
| 2026-08-04 | 2658 |
| 2026-08-05 | 2659 |
| 2026-08-06 | 2659 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
15.0
growth rate 0.00%/day
# OpenAI .NET API library
[](https://www.nuget.org/packages/OpenAI)
The OpenAI .NET library provides convenient access to the OpenAI REST API from .NET applications.
It is generated from our [OpenAPI specification](https://github.com/openai/openai-openapi) in collaboration with Microsoft.
## Table of Contents
- [Getting started](#getting-started)
- [Prerequisites](#prerequisites)
- [Install the NuGet package](#install-the-nuget-package)
- [Using the client library](#using-the-client-library)
- [Namespace organization](#namespace-organization)
- [Using the async API](#using-the-async-api)
- [Using the `OpenAIClient` class](#using-the-openaiclient-class)
- [How to use dependency injection](#how-to-use-dependency-injection)
- [How to use chat completions with streaming](#how-to-use-chat-completions-with-streaming)
- [How to use chat completions with tools and function calling](#how-to-use-chat-completions-with-tools-and-function-calling)
- [How to use chat completions with structured outputs](#how-to-use-chat-completions-with-structured-outputs)
- [How to use chat completions with audio](#how-to-use-chat-completions-with-audio)
- [How to use responses with streaming and reasoning](#how-to-use-responses-with-streaming-and-reasoning)
- [How to use responses with file search](#how-to-use-responses-with-file-search)
- [How to use responses with web search](#how-to-use-responses-with-web-search)
- [How to generate text embeddings](#how-to-generate-text-embeddings)
- [How to generate images](#how-to-generate-images)
- [How to transcribe audio](#how-to-transcribe-audio)
- [How to use assistants with retrieval augmented generation (RAG)](#how-to-use-assistants-with-retrieval-augmented-generation-rag)
- [How to use assistants with streaming and vision](#how-to-use-assistants-with-streaming-and-vision)
- [How to work with Azure OpenAI](#how-to-work-with-azure-openai)
- [Advanced scenarios](#advanced-scenarios)
- [Using mutual TLS](#using-mutual-tls)
- [Using protocol methods](#using-protocol-methods)
- [Mock a client for testing](#mock-a-client-for-testing)
- [Automatically retrying errors](#automatically-retrying-errors)
- [Observability](#observability)
## Getting started
### Prerequisites
To call the OpenAI REST API, you will need an API key. To obtain one, first [create a new OpenAI account](https://platform.openai.com/signup) or [log in](https://platform.openai.com/login). Next, navigate to the [API key page](https://platform.openai.com/account/api-keys) and select "Create new secret key", optionally naming the key. Make sure to save your API key somewhere safe and do not share it with anyone.
### Install the NuGet package
Add the client library to your .NET project by installing the [NuGet](https://www.nuget.org/) package via your IDE or by running the following command in the .NET CLI:
```cli
dotnet add package OpenAI
```
Note that the code examples included below were written using [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0). The OpenAI .NET library is compatible with all .NET Standard 2.0 applications, but the syntax used in some of the code examples in this document may depend on newer language features.
## Using the client library
The public API listings for this library can be found in the [`api/`](https://github.com/openai/openai-dotnet/tree/main/api) folder (organized by target framework), and there are many [code examples](https://github.com/openai/openai-dotnet/tree/main/examples) to help. For instance, the following snippet illustrates the basic use of the chat completions API:
```C# Snippet:ReadMe_ChatCompletion_Basic
ChatClient client = new(model: "gpt-5.1", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
ChatCompletion completion = client.CompleteChat("Say 'this is a test.'");
Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
```
While you can pass your API key directly asExcerpt of 55,309 characters
Read on GitHubJose Arriaga Maldonado · @Microsoft
140
64
48
29
28
22
22
14
13
Stephen Toub · Microsoft · Morocco
12
Rohan Santhosh Kumar · Singapore
11
Justin Yoo · Microsoft · South Korea
10
Patrick Hallisey · @microsoft
9
Wes Haggard · Microsoft
7
Scott Addie
7
6
6
3
3
3
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:e1c007f2a97ed759, llm:description: 'The official .NET library for the OpenAI API'; topics: ['csharp','dotnet','openai']
matched fp:e1c007f2a97ed759, llm:description: 'The official .NET library for the OpenAI API'; topics: ['csharp','dotnet','openai']
matched fp:e1c007f2a97ed759, llm:description: 'The official .NET library for the OpenAI API'; topics: ['csharp','dotnet','openai']