OpenAI's official .NET SDK is OpenAPI-generated, DI-ready
The officially supported .NET client for OpenAI's API, generated from the OpenAPI spec with Microsoft and built to drop into ASP.NET Core's dependency injection container.

What it does
The library maps the entire OpenAI REST API into a namespace-per-service client model—ChatClient, AudioClient, EmbeddingClient, AssistantClient, and roughly a dozen others. Every client offers synchronous and asynchronous methods, and the whole package targets .NET Standard 2.0 so it runs across practically any modern .NET stack.
The interesting bit
It is generated directly from OpenAI’s OpenAPI specification in collaboration with Microsoft, which keeps the surface area mechanically current with API changes. Despite the codegen origins, the clients are thread-safe and explicitly designed to be registered as singletons in ASP.NET Core’s dependency injection container.
Key highlights
- Full API coverage: chat completions (streaming, tools, structured outputs, audio), embeddings, images, audio transcription/generation, assistants, batch, fine-tuning, realtime, vector stores, and more
- Native ASP.NET Core integration: clients are thread-safe and singleton-ready for efficient HTTP connection reuse
- Supports custom endpoints and API keys, so it works with proxies, self-hosted OpenAI-compatible LLMs, and Azure OpenAI
- Generated from the official OpenAPI spec, which reduces the manual toil of keeping bindings up to date
- Advanced scenarios supported: protocol methods, automatic retries, observability hooks, and mockable clients for unit testing
Verdict
Grab it if you want an officially maintained, mechanically current .NET client that drops into existing ASP.NET Core infrastructure without fuss. Skip it if you prefer hand-rolled minimal HTTP wrappers or are working outside the .NET ecosystem.
Frequently asked
- What is openai/openai-dotnet?
- The officially supported .NET client for OpenAI's API, generated from the OpenAPI spec with Microsoft and built to drop into ASP.NET Core's dependency injection container.
- Is openai-dotnet open source?
- Yes — openai/openai-dotnet is open source, released under the MIT license.
- What language is openai-dotnet written in?
- openai/openai-dotnet is primarily written in C#.
- How popular is openai-dotnet?
- openai/openai-dotnet has 2.7k stars on GitHub.
- Where can I find openai-dotnet?
- openai/openai-dotnet is on GitHub at https://github.com/openai/openai-dotnet.