www.nuget.org/packages/OpenAI/

The OpenAI .NET API library provides convenient access to the OpenAI REST API from .NET applications.

Overview

The official .NET library for the OpenAI service API.

The OpenAI .NET library provides convenient access to the OpenAI REST API from .NET applications.

It is generated from our OpenAPI specification in collaboration with Microsoft.

Note that the code examples included below were written using .NET 10 . 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.

Key Features

  • Access to the OpenAI REST API
  • Namespace-organized client classes
  • Synchronous and asynchronous client methods
  • Streaming chat completions
  • Tools and function calling
  • Structured outputs
  • Text embeddings and image generation
  • Dependency injection support

What Can You Use It For?

  • Calling the OpenAI REST API from .NET
  • Streaming chat completions to users
  • Using chat completions with tools and function calling
  • Generating text embeddings
  • Generating images
  • Transcribing audio

MCP Integration

No MCP (Model Context Protocol) server is listed for www.nuget.org/packages/OpenAI/ yet. When one is available, its URL and setup guide appear here.

Know an official MCP server for www.nuget.org/packages/OpenAI/? Tell us

Affiliate Program

No affiliate program is listed for www.nuget.org/packages/OpenAI/ yet. When one is available, its link and terms appear here.

Know an official affiliate program for www.nuget.org/packages/OpenAI/? Tell us

Frequently Asked Questions

It is a library that provides convenient access to the OpenAI REST API from .NET applications, generated from the OpenAI OpenAPI specification in collaboration with Microsoft.

You will need an API key, which you can obtain by creating a new OpenAI account or logging in and creating a new secret key.

The package targets .NET 8.0 and .NET Standard 2.0, and is compatible with those frameworks or higher.

Yes, you can specify a custom base URL and API key using ApiKeyCredential and OpenAIClientOptions, which is useful for proxies, self-hosted OpenAI-compatible LLMs, or custom deployments.

Yes, the OpenAI clients are thread-safe and can be safely registered as singletons in ASP.NET Core's Dependency Injection container.

Alternatives and Related Tools

See More

Doubleword is an open-weight inference provider for token-intensive, long-horizon agent workloads.

AINative Studio provides an OpenAI-compatible LLM API giving access to 59+ AI models through a single interface.

Fern generates documentation, SDKs, and a CLI for APIs from a single source of truth.

PlaceKit is an address autocomplete and geocoding API offering autocomplete, live patching, store locator and two-way geocoding through a single API.