openai-dotnet  by openai

.NET SDK for OpenAI API access

created 1 year ago
2,178 stars

Top 21.1% on sourcepulse

GitHubView on GitHub
Project Summary

This .NET library provides a C# interface to the OpenAI REST API, targeting .NET developers building applications that leverage AI capabilities. It offers a structured and type-safe way to interact with OpenAI services like chat completions, image generation, audio transcription, and embeddings, simplifying integration and improving developer productivity.

How It Works

The library is generated from OpenAI's OpenAPI specification, ensuring adherence to the API's contract. It organizes functionality into namespaces corresponding to API features (e.g., OpenAI.Chat, OpenAI.Images), each with a dedicated client class. Asynchronous variants are available for all API calls, promoting non-blocking operations. The OpenAIClient class acts as a central point for managing multiple feature clients, sharing configuration like API keys.

Quick Start & Requirements

  • Install via NuGet: dotnet add package OpenAI
  • Requires an OpenAI API key, typically set as an environment variable OPENAI_API_KEY.
  • Examples are written using .NET 8 but compatible with .NET Standard 2.0.

Highlighted Details

  • Supports advanced features like chat completions with streaming, tool/function calling, structured outputs, and audio input/output.
  • Includes clients for Assistants API with RAG, vision capabilities, and file search/web search tools.
  • Offers OpenAIResponseClient for reasoning and file/web search integrations.
  • Provides protocol methods for direct REST API interaction and extensive mocking support for testing.

Maintenance & Community

  • Developed in collaboration with Microsoft.
  • Experimental support for Assistants API (v2).
  • Experimental OpenTelemetry integration for observability.

Licensing & Compatibility

  • License: MIT.
  • Compatible with .NET Standard 2.0 and later.

Limitations & Caveats

  • The Assistants and Vector Stores namespaces are marked as experimental, with model factories noted as "coming soon."
  • Some code examples may use newer C# language features not available in older .NET versions.
Health Check
Last commit

1 day ago

Responsiveness

1 day

Pull Requests (30d)
46
Issues (30d)
55
Star History
211 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.