- Added the
OpenAIChatModelFactoryin theOpenAI.Chatnamespace (a static class that can be used to instantiate OpenAI models for mocking in non-live test scenarios). (79014ab)
- Updated fine-tuning pagination methods
GetJobs,GetEvents, andGetJobCheckpointsto returnIEnumerable<ClientResult>instead ofClientResult. (5773292) - Updated the batching pagination method
GetBatchesto returnIEnumerable<ClientResult>instead ofClientResult. (5773292) - Changed
GeneratedSpeechVoicefrom an enum to an "extensible enum". (79014ab) - Changed
GeneratedSpeechFormatfrom an enum to an "extensible enum". (cc9169a) - Renamed
SpeechGenerationOptions'sSpeedproperty toSpeedRatio. (cc9169a)
- Corrected an internal deserialization issue that caused recent updates to Assistants
file_searchto fail when streaming a run. Strongly typed support forranking_optionsis not included but will arrive soon. (cc9169a) - Mitigated a .NET runtime issue that prevented
ChatResponseFormatfrom serializing correct on targets including Unity. (cc9169a)
- Reverted the removal of the version path parameter "v1" from the default endpoint URL. (583e9f6)
- Added the
Experimentalattribute to the following APIs:
- Renamed
AudioClient'sGenerateSpeechFromTextmethods to simplyGenerateSpeech. (d84bf54) - Changed the type of
OpenAIFileInfo'sSizeInBytesproperty fromlong?toint?. (d84bf54)
- Fixed a newly introduced bug (#185) where providing
OpenAIClientOptionsto a top-levelOpenAIClientdid not carry over to scenario clients (e.g.ChatClient) created via that top-level client (d84bf54)
- Removed the version path parameter "v1" from the default endpoint URL. (d84bf54)
- Added support for the new structured outputs response format feature, which enables chat completions, assistants, and tools on each of those clients to provide a specific JSON Schema that generated content should adhere to. (3467b53)
- To enable top-level structured outputs for response content, use
ChatResponseFormat.CreateJsonSchemaFormat()andAssistantResponseFormat.CreateJsonSchemaFormat()as theResponseFormatin method options likeChatCompletionOptions - To enable structured outputs for function tools, set
StrictParameterSchemaEnabledtotrueon the tool definition - For more information, please see the new section in readme.md
- To enable top-level structured outputs for response content, use
- Chat completions: the request message types of
AssistantChatMessage,SystemChatMessage, andToolChatMessagenow support array-based content part collections in addition to simple string input. (3467b53) - Added the following model factories (static classes that can be used to instantiate OpenAI models for mocking in non-live test scenarios):
OpenAIAudioModelFactoryin theOpenAI.Audionamespace (3284295)OpenAIEmbeddingsModelFactoryin theOpenAI.Embeddingsnamespace (3284295)OpenAIFilesModelFactoryin theOpenAI.Filesnamespace (b1ce397)OpenAIImagesModelFactoryin theOpenAI.Imagesnamespace (3284295)OpenAIModelsModelFactoryin theOpenAI.Modelsnamespace (b1ce397)OpenAIModerationsModelFactoryin theOpenAI.Moderationsnamespace (b1ce397)
- Removed client constructors that do not explicitly take an API key parameter or an endpoint via an
OpenAIClientOptionsparameter, making it clearer how to appropriately instantiate a client. (13a9c68) - Removed the endpoint parameter from all client constructors, making it clearer that an alternative endpoint must be specified via the
OpenAIClientOptionsparameter. (13a9c68) - Removed
OpenAIClient'sEndpointprotectedproperty. (13a9c68) - Made
OpenAIClient's constructor that takes aClientPipelineparameterprotected internalinstead of justprotected. (13a9c68) - Renamed the
Userproperty in applicable Options classes toEndUserId, making its purpose clearer. (13a9c68)
- The
AssistantsnamespaceVectorStoreCreationHelpertype now properly includes aChunkingStrategyproperty. (3467b53)
ChatCompletion.ToString()will no longer throw an exception when no content is present, as is the case for tool calls. Additionally, if a tool call is present with no content,ToString()will return the serialized form of the first available tool call. (3467b53)
- Changed name of return types from methods returning streaming collections from
ResultCollectiontoCollectionResult. (7bdecfd) - Changed return types from methods returning paginated collections from
PageableCollectiontoPageCollection. (7bdecfd) - Users must now call
GetAllValueson the collection of pages to enumerate collection items directly. Corresponding protocol methods returnIEnumerable<ClientResult>where each collection item represents a single service response holding a page of values. (7bdecfd) - Updated
VectorStoreFileCountsandVectorStoreFileAssociationErrortypes fromreadonly structtoclass. (58f93c8)
- (#49) Fixed a bug with extensible enums implementing case-insensitive equality but case-sensitive hash codes. (0c12500)
- (#57) Fixed a bug with requests URIs with query string parameter potentially containing a malformed double question mark (
??) on .NET Framework (net481). (0c12500) - Added optional
CancellationTokenparameters to methods forAssistantClientandVectorStoreclient, consistent with past changes in 19a65a0. (d77539c) - Fixed Assistants
FileSearchToolDefinition'sMaxResultsparameter to appropriately serialize and deserialize the value (d77539c) - Added missing
[EditorBrowsable(EditorBrowsableState.Never)]attributes toAssistantClientprotocol methods, which should improve discoverability of the strongly typed methods. (d77539c)
- Removed the usage of
initand updated properties to useset. (58f93c8)
- (#84) Fixed a
NullReferenceExceptionthrown when adding the custom headers policy whileOpenAIClientOptionsis null (0b97311)
OrganizationIdandProjectIdare now present onOpenAIClientOptions. When instantiating a client, providing an instance ofOpenAIClientOptionswith these properties set will cause the client to add the appropriate request headers for org/project, eliminating the need to manually configure the headers. (9ee7dff)
- (#72) Fixed
filenamerequest encoding in operations usingmultipart/form-data, includingfilesandaudio(2ba8e69) - (#79) Fixed hard-coded
userrole for caller-created Assistants API messages on threads (d665b61) - Fixed non-streaming Assistants API run step details not reporting code interpreter logs when present (d665b61)
Assistants (beta):
AssistantClient.CreateMessage()and the explicit constructor forThreadInitializationMessagenow require aMessageRoleparameter. This properly enables the ability to create an Assistant message representing conversation history on a new thread. (d665b61)
- API updates, current to openai/openai-openapi@dd73070b (1af6569)
- This includes
MaxResultsfor AssistantsFileSearchToolDefinition,ParallelToolCallsEnabledfor function tools in Assistants and Chat, andFileChunkingStrategyfor Assistants VectorStores
- This includes
- Optional
CancellationTokenparameters are now directly present on most methods, eliminating the need to use protocol methods (19a65a0)
- (#30) Mitigated a .NET runtime issue that prevented chat message content and several other types from serializing correct on targets including mono and wasm (896b9e0)
- Assistants: Fixed an issue that threw an exception when receiving code interpreter run step logs when streaming a run (207d597)
- Fixed a concurrency condition that could cause
multipart/form-datarequests to no longer generate random content part boundaries (no direct scenario impact) (7cacdee)
Assistants (beta):
InputQuoteis removed from AssistantsTextAnnotationandTextAnnotationUpdate, per openai/openai-openapi@dd73070b (1af6569)
- Added an environment-variable-based test project to the repository with baseline scenario coverage (db6328a)
- Build/analyzer warnings cleaned up throughout the project (45fc4d7, b1fa082, 22ab606)
- Proactively aligned library's implementation of server-sent event (SSE) handling with the source of the incoming
System.Net.ServerSentEventsnamespace (674e0f7)
- Added new, built-in helpers to simplify the use of text-only message content (1c40de6)
- Optimized embedding deserialization and addressed correctness on big endian systems (e28b5a7)
- Optimized b64_json message parsing via regex (efd76b5)
- Removed a vestigial package reference (5874f53)
This is the official OpenAI client library for C# / .NET. It provides convenient access to the OpenAI REST API from .NET applications and supports all the latest features. It is generated from our OpenAPI specification in collaboration with Microsoft.
If you are a user migrating from version 1.11.0 or earlier, we will soon share a migration guide to help you get started.
- Addendum: the migration guide is now available.