The OpenAI .NET library is generated, and the generator is TypeScript
The official .NET library for the OpenAI API
At a glance
- What is it?
- openai/openai-dotnet ships a NuGet client called OpenAI, generated from OpenAI's OpenAPI specification with Microsoft. The repository carries the .NET output, a separate OpenAI.Responses project, a TypeScript code generator workspace, and a sample environment file that puts the test suite in Playback mode.
- Who is it for?
- This library fits a .NET team that wants typed clients generated from the vendor's own specification instead of hand-written wrappers, and who can live with an API surface that moves monthly and marks new designs as experimental. It does not fit a team that needs a stable semantic version contract across several months, because releases are minor bumps every three to four weeks and the client's newest areas are still experimental enough to require suppressing a diagnostic.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 3 days ago.
- What is it written in?
- Mainly C#, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- openai/openai-dotnet2,719 ★ · +27
| Repository | 2026-09-15 | 2026-11-15 |
|---|---|---|
| openai/openai-dotnet | 2.7k | 2.7k |
27 Stars in the last 61 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The client is generated, and codegen/ is a TypeScript workspace
The library is not hand-written. It is generated from OpenAI's OpenAPI specification in collaboration with Microsoft, and the repository keeps the inputs and the generator next to the output: schema/, specification/ and codegen/ all sit at the root beside the C# project.
The clearest evidence is the root package.json, which is not a JavaScript package for consumers at all. It is named openai-tsp, marked private, and its single workspace is codegen, wired to a local plugin package:
{
"name": "openai-tsp",
"workspaces": [
"codegen"
],
"version": "0.1.0",
"type": "module",
"dependencies": {
"@open-ai/plugin": "file:codegen"
},
"private": true
}So the pipeline is a TypeScript generator with a local plugin, reading a schema, emitting the client that .NET developers consume from NuGet. Contributors who change the public surface are working against generated output, not against hand-maintained classes.
Two project folders, one solution file and a minor bump every month
The tree holds two C# project folders at the root, OpenAI/ and OpenAI.Responses/, joined by OpenAI.slnx. Responses is separated out rather than folded in, so an application that only calls chat completions is not automatically referencing the responses surface.
Around them sit the standard central-build files for a large repo: Directory.Build.props, Directory.Build.targets, Directory.Packages.props, global.json, nuget.config and .editorconfig, plus .config/ and .devcontainer/ for tooling configuration and a dev container.
The release record moves on a monthly minor cadence. OpenAI_2.12.0 was published on 1 July 2026, OpenAI_2.13.0 on 10 August, and OpenAI_2.14.0 on 15 September, with the default branch last pushed on 2 October 2026. No patch releases appear among the three most recent ones, which is what a monthly minor line looks like: the package version is where new API surface arrives, not only bug fixes, so a pin does not freeze your surface.
The sample environment file points the tests at recorded playback
The repository ships a .env.sample with two lines, and the second one is the interesting one:
# Application environment variables sample file
# Copy this file to .env and fill in the desired values
OPENAI_API_KEY=<< YOUR API KEY >>
CLIENTMODEL_TEST_MODE=PlaybackThe key placeholder uses angle brackets rather than an empty value, and the test mode defaults to Playback. The natural reading is that the test suite replays recorded responses rather than sending live requests, which is the arrangement you want for a metered API, since a suite that calls the real endpoint costs money on every run and needs a key in CI.
What the page does not do is define the mode. Playback appears here with no list of the other values, no statement of where recordings live and no note on how to record new ones. Confirm the available modes in the tests directory before you rely on this default.
Two constructor shapes sit a screen apart in the walkthrough
The basic snippet passes the model and the key positionally by name:
```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}");
The next section, on custom base URLs, uses a different shape entirely, wrapping the key in an ApiKeyCredential and passing an options object with an Endpoint:
C# Snippet:ReadMe_CustomUrl ChatClient client = new( model: "MODEL_NAME", credential: new ApiKeyCredential(Environment.GetEnvironmentVariable("OPENAI_API_KEY")), options: new OpenAIClientOptions() { Endpoint = new Uri("https://YOUR_BASE_URL") }); ```
The first form reads a string key; the second takes a credential object and an options object. Both appear in the same document a page apart, which means the choice is not obvious from reading the top of the file. The stated use for the second form is an alternative API endpoint such as a proxy or a self-hosted OpenAI-compatible LLM, with the placeholders MODEL_NAME and YOUR_BASE_URL left for you to fill in.
Experimental APIs are a compiler error until you suppress the diagnostic
Some client APIs carry an [Experimental] attribute while their .NET design is still evolving, and touching one produces a compiler error rather than a warning. You have to suppress the specific diagnostic ID explicitly, which is a heavier step than opting into an experimental namespace.
Two documents back that policy: docs/FeatureLifecycle.md for how OpenAI .NET APIs are introduced and promoted to stable, and Microsoft's own guidance on preview APIs. The message is that the surface has a promotion path and that you are expected to notice when you are standing on the wrong side of it.
The framework target is stated next to it. The library is compatible with all .NET Standard 2.0 applications, while the examples in the document were written using .NET 10, so some syntax in the samples depends on newer language features than the library itself requires. Copying a sample into a .NET Standard 2.0 project is where that gap shows up.
Fourteen namespaces, and one client class that breaks the pattern
The library is organised into namespaces by feature area of the REST API, and each namespace holds a corresponding client class. The page's table lists fourteen of them: OpenAI.Assistants with AssistantClient, Audio with AudioClient, Batch with BatchClient, Chat with ChatClient, Embeddings with EmbeddingClient, Evals with EvaluationClient, FineTuning with FineTuningClient, Files with OpenAIFileClient, Images with ImageClient, Models with OpenAIModelClient, Moderations with ModerationClient, Realtime with RealtimeClient, Responses with ResponsesClient and VectorStores with VectorStoreClient.
The naming is predictable with two exceptions worth knowing before you write the using statements. The files client is OpenAIFileClient rather than FileClient, breaking the pattern every other row follows, and the models client is singular, OpenAIModelClient, where the namespace is plural.
Public API listings live in an api/ folder organised by target framework, so the surface you can call is documented per framework rather than in one place. The page points at examples/ as well, which holds one directory per feature area plus standalone example files.
The table of contents promises more sections than the page walks through
The contents list at the top of the document runs to about two dozen entries: streaming chat completions, tools and function calling, structured outputs, audio, responses with reasoning, file search, web search, embeddings, images, transcription, assistants with retrieval augmented generation, assistants with streaming and vision, Azure OpenAI, mutual TLS, protocol methods, a mock client for testing, automatic retrying of errors and observability.
The visible walkthrough stops earlier than that. It covers getting started, the namespace table, the async API and the custom endpoint, and the async example ends inside its own string literal, partway through Say 'this, with no closing fence of any kind on the page. Everything from streaming onward is a promise in the contents list rather than prose you can read here, so treat the contents list as an index into the examples directory and the docs directory rather than as documentation of the library itself.
That split is a normal shape for a generated client. It also means the README is a starting point, and the api/ folder and the docs are where behaviour is actually specified.
Editorial conclusion
This library fits a .NET team that wants typed clients generated from the vendor's own specification instead of hand-written wrappers, and who can live with an API surface that moves monthly and marks new designs as experimental. It does not fit a team that needs a stable semantic version contract across several months, because releases are minor bumps every three to four weeks and the client's newest areas are still experimental enough to require suppressing a diagnostic. Before adopting, check which namespaces you actually call against the fourteen client classes listed here, decide whether a custom Endpoint is something you want in the codebase at all, confirm your CI can run the recorded Playback mode rather than spending tokens per test, and read the feature lifecycle document before pinning to anything experimental.
Frequently asked questions
How do you install the OpenAI .NET library?
Through NuGet, either from the IDE or with the .NET CLI command dotnet add package OpenAI. The package page linked at the top of the document is the nuget.org listing for OpenAI.
Which .NET versions does the OpenAI library support?
The library is compatible with all .NET Standard 2.0 applications. The code examples in the document were written using .NET 10, so some of their syntax depends on newer language features than the library itself requires.
How should the OpenAI .NET client read the API key?
You can pass it as a string, but the page recommends keeping it in a secure location and reading it from an environment variable or configuration file, as the basic snippet does with Environment.GetEnvironmentVariable. The custom endpoint form wraps it in an ApiKeyCredential instead.
Can the OpenAI .NET client point at a proxy or a self-hosted endpoint?
Yes, through a custom base URL and key set with ApiKeyCredential and OpenAIClientOptions, whose Endpoint property takes a URI. The stated use is connecting to an alternative API endpoint such as a proxy or a self-hosted OpenAI-compatible LLM, and the contents list also has a section on working with Azure OpenAI.
Official sources
Where developers are discussing it
Posts on Hacker News, dev.to and Lobsters that link to this repository, found by our scan of those communities. 1 in the last 30 days; newest first.
- State of AI Instruction Quality: Coding Agent Comparisondev.to · Oct 21, 2026 · 6 points · 0 comments
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/openai-openai-dotnet)Star history chart for your README
[](https://hysenlabs.com/projects/openai-openai-dotnet)Was this useful?