From db68eb565c4e8e1d6efea13a6267c2c5c5bc25b8 Mon Sep 17 00:00:00 2001 From: Jose Arriaga Maldonado Date: Wed, 20 Aug 2025 13:41:55 -0700 Subject: [PATCH 1/2] Add pipeline to RealtimeClient --- .../Realtime/RealtimeClient.Protocol.cs | 5 +- src/Custom/Realtime/RealtimeClient.cs | 82 +++++++++++++++---- tests/Chat/ChatStoreTests.cs | 5 +- tests/Chat/ChatTests.cs | 45 +++++----- tests/Realtime/RealtimeProtocolTests.cs | 46 +++++++++++ tests/Realtime/RealtimeTestFixtureBase.cs | 8 +- tests/Utility/TestHelpers.cs | 13 ++- 7 files changed, 157 insertions(+), 47 deletions(-) diff --git a/src/Custom/Realtime/RealtimeClient.Protocol.cs b/src/Custom/Realtime/RealtimeClient.Protocol.cs index 004042c5a..d54bddaf3 100644 --- a/src/Custom/Realtime/RealtimeClient.Protocol.cs +++ b/src/Custom/Realtime/RealtimeClient.Protocol.cs @@ -1,7 +1,6 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.ComponentModel; using System.Threading.Tasks; namespace OpenAI.Realtime; @@ -43,8 +42,8 @@ public virtual Task StartTranscriptionSessionAsync(RequestOptio /// public virtual async Task StartSessionAsync(string model, string intent, RequestOptions options) { - Uri fullEndpoint = BuildSessionEndpoint(_baseEndpoint, model, intent); - RealtimeSession provisionalSession = new(this, fullEndpoint, _credential); + Uri fullEndpoint = BuildSessionEndpoint(_webSocketEndpoint, model, intent); + RealtimeSession provisionalSession = new(this, fullEndpoint, _keyCredential); try { await provisionalSession.ConnectAsync(options).ConfigureAwait(false); diff --git a/src/Custom/Realtime/RealtimeClient.cs b/src/Custom/Realtime/RealtimeClient.cs index 89187a9f7..8dd3a3f21 100644 --- a/src/Custom/Realtime/RealtimeClient.cs +++ b/src/Custom/Realtime/RealtimeClient.cs @@ -20,34 +20,80 @@ public partial class RealtimeClient public event EventHandler OnSendingCommand; public event EventHandler OnReceivingCommand; - private readonly ApiKeyCredential _credential; - private readonly Uri _baseEndpoint; + private readonly ApiKeyCredential _keyCredential; + private readonly Uri _webSocketEndpoint; + + // CUSTOM: Added as a convenience. + /// Initializes a new instance of . + /// The API key to authenticate with the service. + /// is null. + public RealtimeClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions()) + { + } - /// - /// Creates a new instance of using an API key for authentication. - /// - /// The API key to use for authentication. + // CUSTOM: + // - Used a custom pipeline. + // - Demoted the endpoint parameter to be a property in the options class. + /// Initializes a new instance of . + /// The API key to authenticate with the service. + /// is null. public RealtimeClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { } - /// - /// Creates a new instance of using an API key for authentication. - /// - /// The API key to use for authentication. - /// Additional options for configuring the client. - public RealtimeClient(ApiKeyCredential credential, OpenAIClientOptions options) + // CUSTOM: + // - Used a custom pipeline. + // - Demoted the endpoint parameter to be a property in the options class. + /// Initializes a new instance of . + /// The API key to authenticate with the service. + /// The options to configure the client. + /// is null. + public RealtimeClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) { - Argument.AssertNotNull(credential, nameof(credential)); - Argument.AssertNotNull(options, nameof(options)); + _keyCredential = credential; + } - _credential = credential; - _baseEndpoint = GetBaseEndpoint(options); + // CUSTOM: Added as a convenience. + /// Initializes a new instance of . + /// The authentication policy used to authenticate with the service. + /// is null. + [Experimental("OPENAI001")] + public RealtimeClient(AuthenticationPolicy authenticationPolicy) : this(authenticationPolicy, new OpenAIClientOptions()) + { + } + + // CUSTOM: Added as a convenience. + /// Initializes a new instance of . + /// The authentication policy used to authenticate with the service. + /// The options to configure the client. + /// is null. + [Experimental("OPENAI001")] + public RealtimeClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options) + { + Argument.AssertNotNull(authenticationPolicy, nameof(authenticationPolicy)); + options ??= new OpenAIClientOptions(); + + Pipeline = OpenAIClient.CreatePipeline(authenticationPolicy, options); + _endpoint = OpenAIClient.GetEndpoint(options); + _webSocketEndpoint = GetWebSocketEndpoint(options); } + // CUSTOM: + // - Used a custom pipeline. + // - Demoted the endpoint parameter to be a property in the options class. + // - Made protected. + /// Initializes a new instance of . + /// The HTTP pipeline to send and receive REST requests and responses. + /// The options to configure the client. + /// is null. protected internal RealtimeClient(ClientPipeline pipeline, OpenAIClientOptions options) { - throw new NotImplementedException("Pipeline-based initialization of WS-based client not available"); + Argument.AssertNotNull(pipeline, nameof(pipeline)); + options ??= new OpenAIClientOptions(); + + Pipeline = pipeline; + _endpoint = OpenAIClient.GetEndpoint(options); + _webSocketEndpoint = GetWebSocketEndpoint(options); } /// @@ -123,7 +169,7 @@ public RealtimeSession StartTranscriptionSession(CancellationToken cancellationT return StartTranscriptionSessionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); } - private static Uri GetBaseEndpoint(OpenAIClientOptions options) + private static Uri GetWebSocketEndpoint(OpenAIClientOptions options) { UriBuilder uriBuilder = new(options?.Endpoint ?? new("https://api.openai.com/v1")); uriBuilder.Scheme = uriBuilder.Scheme.ToLowerInvariant() switch diff --git a/tests/Chat/ChatStoreTests.cs b/tests/Chat/ChatStoreTests.cs index bbc54bd8c..185d4e9bc 100644 --- a/tests/Chat/ChatStoreTests.cs +++ b/tests/Chat/ChatStoreTests.cs @@ -981,5 +981,8 @@ await RetryWithExponentialBackoffAsync(async () => catch { /* Ignore cleanup errors */ } } - private static ChatClient GetTestClient(string overrideModel = null) => GetTestClient(TestScenario.Chat, overrideModel); + private static ChatClient GetTestClient(string overrideModel = null) + => GetTestClient( + scenario: TestScenario.Chat, + overrideModel: overrideModel); } diff --git a/tests/Chat/ChatTests.cs b/tests/Chat/ChatTests.cs index fac14c00d..4f610b819 100644 --- a/tests/Chat/ChatTests.cs +++ b/tests/Chat/ChatTests.cs @@ -34,7 +34,7 @@ public ChatTests(bool isAsync) : base(isAsync) [Test] public async Task HelloWorldChat() { - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [new UserChatMessage("Hello, world!")]; ClientResult result = IsAsync ? await client.CompleteChatAsync(messages) @@ -59,7 +59,7 @@ public async Task HelloWorldWithTopLevelClient() [Test] public async Task MultiMessageChat() { - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [ new SystemChatMessage("You are a helpful assistant. You always talk like a pirate."), new UserChatMessage("Hello, assistant! Can you help me train my parrot?"), @@ -75,7 +75,7 @@ public void StreamingChat() { AssertSyncOnly(); - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [new UserChatMessage("What are the best pizza toppings? Give me a breakdown on the reasons.")]; int updateCount = 0; @@ -110,7 +110,7 @@ public async Task StreamingChatAsync() { AssertAsyncOnly(); - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [new UserChatMessage("What are the best pizza toppings? Give me a breakdown on the reasons.")]; int updateCount = 0; @@ -325,7 +325,7 @@ public async Task CompleteChatStreamingClosesNetworkStreamAsync() [Test] public async Task TwoTurnChat() { - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); List messages = [ @@ -352,7 +352,7 @@ public async Task ChatWithVision() using Stream stream = File.OpenRead(filePath); BinaryData imageData = BinaryData.FromStream(stream); - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [ new UserChatMessage( ChatMessageContentPart.CreateTextPart("Describe this image for me."), @@ -370,7 +370,7 @@ public async Task ChatWithVision() [Test] public async Task ChatWithBasicAudioOutput() { - ChatClient client = GetTestClient(TestScenario.Chat, "gpt-4o-audio-preview"); + ChatClient client = GetTestClient(overrideModel: "gpt-4o-audio-preview"); List messages = ["Say the exact word 'hello' and nothing else."]; ChatCompletionOptions options = new() { @@ -420,7 +420,7 @@ in client.CompleteChatStreamingAsync(messages, options)) [Test] public async Task ChatWithAudio() { - ChatClient client = GetTestClient(TestScenario.Chat, "gpt-4o-audio-preview"); + ChatClient client = GetTestClient(overrideModel: "gpt-4o-audio-preview"); string helloWorldAudioPath = Path.Join("Assets", "audio_hello_world.mp3"); BinaryData helloWorldAudioBytes = BinaryData.FromBytes(File.ReadAllBytes(helloWorldAudioPath)); @@ -536,7 +536,7 @@ public async Task AuthFailure() public async Task TokenLogProbabilities(bool includeLogProbabilities) { const int topLogProbabilityCount = 3; - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IList messages = [new UserChatMessage("What are the best pizza toppings? Give me a breakdown on the reasons.")]; ChatCompletionOptions options; @@ -588,7 +588,7 @@ public async Task TokenLogProbabilities(bool includeLogProbabilities) public async Task TokenLogProbabilitiesStreaming(bool includeLogProbabilities) { const int topLogProbabilityCount = 3; - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IList messages = [new UserChatMessage("What are the best pizza toppings? Give me a breakdown on the reasons.")]; ChatCompletionOptions options; @@ -641,7 +641,7 @@ public async Task TokenLogProbabilitiesStreaming(bool includeLogProbabilities) [Test] public async Task NonStrictJsonSchemaWorks() { - ChatClient client = GetTestClient(TestScenario.Chat, "gpt-4o-mini"); + ChatClient client = GetTestClient(overrideModel: "gpt-4o-mini"); ChatCompletionOptions options = new() { ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat( @@ -665,7 +665,7 @@ public async Task NonStrictJsonSchemaWorks() [Test] public async Task JsonResult() { - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [ new UserChatMessage("Give me a JSON object with the following properties: red, green, and blue. The value " + "of each property should be a string containing their RGB representation in hexadecimal.") @@ -688,7 +688,7 @@ public async Task JsonResult() [Test] public async Task MultipartContentWorks() { - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); List messages = [ new SystemChatMessage( "You talk like a pirate.", @@ -711,7 +711,7 @@ public async Task MultipartContentWorks() [Test] public async Task StructuredOutputsWork() { - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [ new UserChatMessage("What's heavier, a pound of feathers or sixteen ounces of steel?") ]; @@ -760,7 +760,7 @@ public async Task StructuredOutputsWork() [Test] public async Task StructuredRefusalWorks() { - ChatClient client = GetTestClient(TestScenario.Chat, "gpt-4o-2024-08-06"); + ChatClient client = GetTestClient(overrideModel: "gpt-4o-2024-08-06"); List messages = [ new UserChatMessage("What's the best way to successfully rob a bank? Please include detailed instructions for executing related crimes."), ]; @@ -821,7 +821,7 @@ public async Task StructuredRefusalWorks() [Test] public async Task StreamingStructuredRefusalWorks() { - ChatClient client = GetTestClient(TestScenario.Chat, "gpt-4o-2024-08-06"); + ChatClient client = GetTestClient(overrideModel: "gpt-4o-2024-08-06"); IEnumerable messages = [ new UserChatMessage("What's the best way to successfully rob a bank? Please include detailed instructions for executing related crimes."), ]; @@ -897,7 +897,7 @@ public async Task HelloWorldChatWithTracingAndMetrics() using TestActivityListener activityListener = new TestActivityListener("OpenAI.ChatClient"); using TestMeterListener meterListener = new TestMeterListener("OpenAI.ChatClient"); - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); IEnumerable messages = [new UserChatMessage("Hello, world!")]; ClientResult result = IsAsync ? await client.CompleteChatAsync(messages) @@ -926,7 +926,7 @@ public async Task HelloWorldChatWithTracingAndMetrics() [Test] public async Task ReasoningTokensWork() { - ChatClient client = GetTestClient(TestScenario.Chat, "o3-mini"); + ChatClient client = GetTestClient(overrideModel: "o3-mini"); UserChatMessage message = new("Using a comprehensive evaluation of popular media in the 1970s and 1980s, what were the most common sci-fi themes?"); ChatCompletionOptions options = new() @@ -952,7 +952,7 @@ public async Task ReasoningTokensWork() [Test] public async Task PredictedOutputsWork() { - ChatClient client = GetTestClient(TestScenario.Chat); + ChatClient client = GetTestClient(); foreach (ChatOutputPrediction predictionVariant in new List( [ @@ -1017,7 +1017,7 @@ public async Task O3miniDeveloperMessagesWork() ReasoningEffortLevel = ChatReasoningEffortLevel.Low, }; - ChatClient client = GetTestClient(TestScenario.Chat, "o3-mini"); + ChatClient client = GetTestClient(overrideModel: "o3-mini"); ChatCompletion completion = await client.CompleteChatAsync(messages, options); Assert.That(completion.Content, Has.Count.EqualTo(1)); @@ -1188,5 +1188,8 @@ public void TearDown() } } - private static ChatClient GetTestClient(string overrideModel = null) => GetTestClient(TestScenario.Chat, overrideModel); + private static ChatClient GetTestClient(string overrideModel = null) + => GetTestClient( + scenario: TestScenario.Chat, + overrideModel: overrideModel); } diff --git a/tests/Realtime/RealtimeProtocolTests.cs b/tests/Realtime/RealtimeProtocolTests.cs index a04f829c3..d11d960ec 100644 --- a/tests/Realtime/RealtimeProtocolTests.cs +++ b/tests/Realtime/RealtimeProtocolTests.cs @@ -96,4 +96,50 @@ public async Task ProtocolCanConfigureSession() Assert.That(NodesOfType("response.content_part.done"), Has.Count.EqualTo(1)); Assert.That(NodesOfType("response.output_item.done"), Has.Count.EqualTo(1)); } + + [Test] + public async Task CreateEphemeralToken() + { + RealtimeClient client = GetTestClient(excludeDumpPolicy: true); + + BinaryData input = BinaryData.FromBytes(""" + { + "model": "gpt-4o-realtime-preview", + "instructions": "You are a friendly assistant." + } + """u8.ToArray()); + + using BinaryContent content = BinaryContent.Create(input); + ClientResult result = await client.CreateEphemeralTokenAsync(content); + BinaryData output = result.GetRawResponse().Content; + + using JsonDocument outputAsJson = JsonDocument.Parse(output.ToString()); + string objectKind = outputAsJson.RootElement + .GetProperty("object"u8) + .GetString(); + + Assert.That(objectKind, Is.EqualTo("realtime.session")); + } + + [Test] + public async Task CreateEphemeralTranscriptionToken() + { + RealtimeClient client = GetTestClient(excludeDumpPolicy: true); + + BinaryData input = BinaryData.FromBytes(""" + { + } + """u8.ToArray()); + + using BinaryContent content = BinaryContent.Create(input); + ClientResult result = await client.CreateEphemeralTranscriptionTokenAsync(content); + BinaryData output = result.GetRawResponse().Content; + + using JsonDocument outputAsJson = JsonDocument.Parse(output.ToString()); + string objectKind = outputAsJson.RootElement + .GetProperty("object"u8) + .GetString(); + + Assert.That(objectKind, Is.EqualTo("realtime.transcription_session")); + } } diff --git a/tests/Realtime/RealtimeTestFixtureBase.cs b/tests/Realtime/RealtimeTestFixtureBase.cs index 22b39417c..4908a149b 100644 --- a/tests/Realtime/RealtimeTestFixtureBase.cs +++ b/tests/Realtime/RealtimeTestFixtureBase.cs @@ -32,11 +32,15 @@ public RealtimeTestFixtureBase(bool isAsync) : base(isAsync) public static string GetTestModel() => GetModelForScenario(TestScenario.Realtime); - public static RealtimeClient GetTestClient() + public static RealtimeClient GetTestClient(bool excludeDumpPolicy = false) { - RealtimeClient client = GetTestClient(TestScenario.Realtime); + RealtimeClient client = GetTestClient( + scenario: TestScenario.Realtime, + excludeDumpPolicy: excludeDumpPolicy); + client.OnSendingCommand += (_, data) => PrintMessageData(data, "> "); client.OnReceivingCommand += (_, data) => PrintMessageData(data, " < "); + return client; } diff --git a/tests/Utility/TestHelpers.cs b/tests/Utility/TestHelpers.cs index a1664c9a9..f069cd3d9 100644 --- a/tests/Utility/TestHelpers.cs +++ b/tests/Utility/TestHelpers.cs @@ -77,11 +77,20 @@ public enum TestScenario public static ApiKeyCredential GetTestApiKeyCredential() => new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); - public static T GetTestClient(TestScenario scenario, string overrideModel = null, OpenAIClientOptions options = default) + public static T GetTestClient( + TestScenario scenario, + string overrideModel = null, + bool excludeDumpPolicy = false, + OpenAIClientOptions options = default) { options ??= new(); ApiKeyCredential credential = GetTestApiKeyCredential(); - options.AddPolicy(GetDumpPolicy(), PipelinePosition.BeforeTransport); + + if (!excludeDumpPolicy) + { + options.AddPolicy(GetDumpPolicy(), PipelinePosition.BeforeTransport); + } + string model = overrideModel ?? GetModelForScenario(scenario); object clientObject = scenario switch { From d28b4bfb211399ad2a7a1a5831eeceec2e05422a Mon Sep 17 00:00:00 2001 From: Jose Arriaga Maldonado Date: Fri, 29 Aug 2025 15:07:52 -0700 Subject: [PATCH 2/2] Edit constructor doc comments --- api/OpenAI.net8.0.cs | 5 +++++ api/OpenAI.netstandard2.0.cs | 3 +++ src/Custom/Assistants/AssistantClient.cs | 4 ++-- .../Internal/InternalAssistantMessageClient.cs | 4 ++-- .../Assistants/Internal/InternalAssistantRunClient.cs | 4 ++-- .../Internal/InternalAssistantThreadClient.cs | 4 ++-- src/Custom/Audio/AudioClient.cs | 4 ++-- src/Custom/Batch/BatchClient.cs | 4 ++-- src/Custom/Chat/ChatClient.cs | 4 ++-- src/Custom/Containers/ContainerClient.cs | 4 ++-- src/Custom/Embeddings/EmbeddingClient.cs | 4 ++-- src/Custom/Evals/EvaluationClient.cs | 4 ++-- src/Custom/Files/Internal/InternalUploadsClient.cs | 11 +++++++++-- src/Custom/Files/OpenAIFileClient.cs | 4 ++-- src/Custom/FineTuning/FineTuningClient.cs | 4 ++-- src/Custom/Graders/GraderClient.cs | 4 ++-- src/Custom/Images/ImageClient.cs | 4 ++-- .../Internal/LegacyCompletionClient.cs | 4 ++-- src/Custom/Models/OpenAIModelClient.cs | 4 ++-- src/Custom/Moderations/ModerationClient.cs | 4 ++-- src/Custom/OpenAIClient.cs | 4 ++-- src/Custom/Realtime/RealtimeClient.cs | 4 ++-- src/Custom/Responses/OpenAIResponseClient.cs | 4 ++-- src/Custom/VectorStores/VectorStoreClient.cs | 4 ++-- 24 files changed, 59 insertions(+), 44 deletions(-) diff --git a/api/OpenAI.net8.0.cs b/api/OpenAI.net8.0.cs index 9365bd4ba..58f749519 100644 --- a/api/OpenAI.net8.0.cs +++ b/api/OpenAI.net8.0.cs @@ -4298,7 +4298,12 @@ public class RealtimeClient { protected RealtimeClient(); public RealtimeClient(ApiKeyCredential credential, OpenAIClientOptions options); public RealtimeClient(ApiKeyCredential credential); + [Experimental("OPENAI001")] + public RealtimeClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options); + [Experimental("OPENAI001")] + public RealtimeClient(AuthenticationPolicy authenticationPolicy); protected internal RealtimeClient(ClientPipeline pipeline, OpenAIClientOptions options); + public RealtimeClient(string apiKey); public ClientPipeline Pipeline { get; } public event EventHandler OnReceivingCommand { add; remove; } public event EventHandler OnSendingCommand { add; remove; } diff --git a/api/OpenAI.netstandard2.0.cs b/api/OpenAI.netstandard2.0.cs index d7d4e4ee3..4a470255e 100644 --- a/api/OpenAI.netstandard2.0.cs +++ b/api/OpenAI.netstandard2.0.cs @@ -3766,7 +3766,10 @@ public class RealtimeClient { protected RealtimeClient(); public RealtimeClient(ApiKeyCredential credential, OpenAIClientOptions options); public RealtimeClient(ApiKeyCredential credential); + public RealtimeClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options); + public RealtimeClient(AuthenticationPolicy authenticationPolicy); protected internal RealtimeClient(ClientPipeline pipeline, OpenAIClientOptions options); + public RealtimeClient(string apiKey); public ClientPipeline Pipeline { get; } public event EventHandler OnReceivingCommand { add; remove; } public event EventHandler OnSendingCommand { add; remove; } diff --git a/src/Custom/Assistants/AssistantClient.cs b/src/Custom/Assistants/AssistantClient.cs index c800784ef..0f956cf4e 100644 --- a/src/Custom/Assistants/AssistantClient.cs +++ b/src/Custom/Assistants/AssistantClient.cs @@ -41,7 +41,7 @@ public partial class AssistantClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public AssistantClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -51,7 +51,7 @@ public partial class AssistantClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public AssistantClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs b/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs index 328ca7005..cdae5e186 100644 --- a/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs +++ b/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs @@ -23,7 +23,7 @@ internal partial class InternalAssistantMessageClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public InternalAssistantMessageClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -33,7 +33,7 @@ internal partial class InternalAssistantMessageClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public InternalAssistantMessageClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs b/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs index d93c05f0e..6677ea687 100644 --- a/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs +++ b/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs @@ -32,7 +32,7 @@ internal partial class InternalAssistantRunClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public InternalAssistantRunClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -42,7 +42,7 @@ internal partial class InternalAssistantRunClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public InternalAssistantRunClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Assistants/Internal/InternalAssistantThreadClient.cs b/src/Custom/Assistants/Internal/InternalAssistantThreadClient.cs index 1b522dcc4..4546c0422 100644 --- a/src/Custom/Assistants/Internal/InternalAssistantThreadClient.cs +++ b/src/Custom/Assistants/Internal/InternalAssistantThreadClient.cs @@ -21,7 +21,7 @@ internal partial class InternalAssistantThreadClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public InternalAssistantThreadClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -31,7 +31,7 @@ internal partial class InternalAssistantThreadClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public InternalAssistantThreadClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Audio/AudioClient.cs b/src/Custom/Audio/AudioClient.cs index 2c5b226b4..929c6475a 100644 --- a/src/Custom/Audio/AudioClient.cs +++ b/src/Custom/Audio/AudioClient.cs @@ -37,7 +37,7 @@ public partial class AudioClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// or is null. /// is an empty string, and was expected to be non-empty. public AudioClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions()) @@ -50,7 +50,7 @@ public partial class AudioClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// or is null. /// is an empty string, and was expected to be non-empty. diff --git a/src/Custom/Batch/BatchClient.cs b/src/Custom/Batch/BatchClient.cs index 1cda1d2be..3f6934e96 100644 --- a/src/Custom/Batch/BatchClient.cs +++ b/src/Custom/Batch/BatchClient.cs @@ -40,7 +40,7 @@ public partial class BatchClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public BatchClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -49,7 +49,7 @@ public partial class BatchClient /// /// Initializes a new instance of that will use an API key when authenticating. /// - /// The API key used to authenticate with the service endpoint. + /// The to authenticate with the service. /// Additional options to customize the client. /// The provided was null. public BatchClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Chat/ChatClient.cs b/src/Custom/Chat/ChatClient.cs index a15d8f1ce..5ba4670c4 100644 --- a/src/Custom/Chat/ChatClient.cs +++ b/src/Custom/Chat/ChatClient.cs @@ -41,7 +41,7 @@ public partial class ChatClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// or is null. /// is an empty string, and was expected to be non-empty. public ChatClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions()) @@ -55,7 +55,7 @@ public partial class ChatClient // - Added telemetry support. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// or is null. /// is an empty string, and was expected to be non-empty. diff --git a/src/Custom/Containers/ContainerClient.cs b/src/Custom/Containers/ContainerClient.cs index 1a26e6d11..533f75d42 100644 --- a/src/Custom/Containers/ContainerClient.cs +++ b/src/Custom/Containers/ContainerClient.cs @@ -21,7 +21,7 @@ public partial class ContainerClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public ContainerClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -31,7 +31,7 @@ public partial class ContainerClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public ContainerClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Embeddings/EmbeddingClient.cs b/src/Custom/Embeddings/EmbeddingClient.cs index 68e104d12..8be749e34 100644 --- a/src/Custom/Embeddings/EmbeddingClient.cs +++ b/src/Custom/Embeddings/EmbeddingClient.cs @@ -40,7 +40,7 @@ public partial class EmbeddingClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// or is null. /// is an empty string, and was expected to be non-empty. public EmbeddingClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions()) @@ -53,7 +53,7 @@ public partial class EmbeddingClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// or is null. /// is an empty string, and was expected to be non-empty. diff --git a/src/Custom/Evals/EvaluationClient.cs b/src/Custom/Evals/EvaluationClient.cs index fd79b2ef9..8e5744177 100644 --- a/src/Custom/Evals/EvaluationClient.cs +++ b/src/Custom/Evals/EvaluationClient.cs @@ -43,7 +43,7 @@ public partial class EvaluationClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public EvaluationClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -52,7 +52,7 @@ public partial class EvaluationClient /// /// Initializes a new instance of that will use an API key when authenticating. /// - /// The API key used to authenticate with the service endpoint. + /// The to authenticate with the service. /// Additional options to customize the client. /// The provided was null. public EvaluationClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Files/Internal/InternalUploadsClient.cs b/src/Custom/Files/Internal/InternalUploadsClient.cs index 26181b456..d4ac297f7 100644 --- a/src/Custom/Files/Internal/InternalUploadsClient.cs +++ b/src/Custom/Files/Internal/InternalUploadsClient.cs @@ -8,12 +8,19 @@ namespace OpenAI.Files; [CodeGenSuppress("InternalUploadsClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))] internal partial class InternalUploadsClient { + // CUSTOM: Added as a convenience. + /// Initializes a new instance of . + /// The API key to authenticate with the service. + /// is null. + public InternalUploadsClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions()) + { + } // CUSTOM: // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. internal InternalUploadsClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -23,7 +30,7 @@ internal partial class InternalUploadsClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. internal InternalUploadsClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Files/OpenAIFileClient.cs b/src/Custom/Files/OpenAIFileClient.cs index c54418903..6907d3cc5 100644 --- a/src/Custom/Files/OpenAIFileClient.cs +++ b/src/Custom/Files/OpenAIFileClient.cs @@ -34,7 +34,7 @@ public partial class OpenAIFileClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public OpenAIFileClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -44,7 +44,7 @@ public partial class OpenAIFileClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public OpenAIFileClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/FineTuning/FineTuningClient.cs b/src/Custom/FineTuning/FineTuningClient.cs index 83ef77254..e7c73442e 100644 --- a/src/Custom/FineTuning/FineTuningClient.cs +++ b/src/Custom/FineTuning/FineTuningClient.cs @@ -59,7 +59,7 @@ public partial class FineTuningClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public FineTuningClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -68,7 +68,7 @@ public partial class FineTuningClient /// /// Initializes a new instance of that will use an API key when authenticating. /// - /// The API key used to authenticate with the service endpoint. + /// The to authenticate with the service. /// Additional options to customize the client. /// The provided was null. public FineTuningClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Graders/GraderClient.cs b/src/Custom/Graders/GraderClient.cs index 0afb6220a..fa5c9e04c 100644 --- a/src/Custom/Graders/GraderClient.cs +++ b/src/Custom/Graders/GraderClient.cs @@ -21,7 +21,7 @@ public partial class GraderClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public GraderClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -31,7 +31,7 @@ public partial class GraderClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public GraderClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Images/ImageClient.cs b/src/Custom/Images/ImageClient.cs index 2e49e02d8..86d3b81de 100644 --- a/src/Custom/Images/ImageClient.cs +++ b/src/Custom/Images/ImageClient.cs @@ -38,7 +38,7 @@ public partial class ImageClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// or is null. /// is an empty string, and was expected to be non-empty. public ImageClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions()) @@ -51,7 +51,7 @@ public partial class ImageClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// or is null. /// is an empty string, and was expected to be non-empty. diff --git a/src/Custom/LegacyCompletions/Internal/LegacyCompletionClient.cs b/src/Custom/LegacyCompletions/Internal/LegacyCompletionClient.cs index 8adbf13b4..20e5073e2 100644 --- a/src/Custom/LegacyCompletions/Internal/LegacyCompletionClient.cs +++ b/src/Custom/LegacyCompletions/Internal/LegacyCompletionClient.cs @@ -31,7 +31,7 @@ internal partial class LegacyCompletionClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// or is null. /// is an empty string, and was expected to be non-empty. public LegacyCompletionClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions()) @@ -44,7 +44,7 @@ internal partial class LegacyCompletionClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// or is null. /// is an empty string, and was expected to be non-empty. diff --git a/src/Custom/Models/OpenAIModelClient.cs b/src/Custom/Models/OpenAIModelClient.cs index f2faceceb..020b8649a 100644 --- a/src/Custom/Models/OpenAIModelClient.cs +++ b/src/Custom/Models/OpenAIModelClient.cs @@ -33,7 +33,7 @@ public partial class OpenAIModelClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public OpenAIModelClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -43,7 +43,7 @@ public partial class OpenAIModelClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public OpenAIModelClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Moderations/ModerationClient.cs b/src/Custom/Moderations/ModerationClient.cs index c11b02237..ebe0b3adf 100644 --- a/src/Custom/Moderations/ModerationClient.cs +++ b/src/Custom/Moderations/ModerationClient.cs @@ -40,7 +40,7 @@ public partial class ModerationClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// or is null. /// is an empty string, and was expected to be non-empty. public ModerationClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions()) @@ -53,7 +53,7 @@ public partial class ModerationClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// or is null. /// is an empty string, and was expected to be non-empty. diff --git a/src/Custom/OpenAIClient.cs b/src/Custom/OpenAIClient.cs index ec08d746c..4ec795bbb 100644 --- a/src/Custom/OpenAIClient.cs +++ b/src/Custom/OpenAIClient.cs @@ -99,7 +99,7 @@ private static class KnownHeaderNames // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public OpenAIClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -109,7 +109,7 @@ private static class KnownHeaderNames // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public OpenAIClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Realtime/RealtimeClient.cs b/src/Custom/Realtime/RealtimeClient.cs index 8dd3a3f21..9906d9c11 100644 --- a/src/Custom/Realtime/RealtimeClient.cs +++ b/src/Custom/Realtime/RealtimeClient.cs @@ -35,7 +35,7 @@ public partial class RealtimeClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public RealtimeClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -45,7 +45,7 @@ public partial class RealtimeClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// is null. public RealtimeClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) diff --git a/src/Custom/Responses/OpenAIResponseClient.cs b/src/Custom/Responses/OpenAIResponseClient.cs index 5a30bdda6..33405ffa7 100644 --- a/src/Custom/Responses/OpenAIResponseClient.cs +++ b/src/Custom/Responses/OpenAIResponseClient.cs @@ -42,7 +42,7 @@ public partial class OpenAIResponseClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// or is null. /// is an empty string, and was expected to be non-empty. public OpenAIResponseClient(string model, ApiKeyCredential credential) : this(model, credential, new OpenAIClientOptions()) @@ -55,7 +55,7 @@ public partial class OpenAIResponseClient // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The name of the model to use in requests sent to the service. To learn more about the available models, see . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// The options to configure the client. /// or is null. /// is an empty string, and was expected to be non-empty. diff --git a/src/Custom/VectorStores/VectorStoreClient.cs b/src/Custom/VectorStores/VectorStoreClient.cs index 6ea59e249..984b05243 100644 --- a/src/Custom/VectorStores/VectorStoreClient.cs +++ b/src/Custom/VectorStores/VectorStoreClient.cs @@ -50,7 +50,7 @@ public partial class VectorStoreClient // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . - /// The API key to authenticate with the service. + /// The to authenticate with the service. /// is null. public VectorStoreClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { @@ -59,7 +59,7 @@ public partial class VectorStoreClient /// /// Initializes a new instance of that will use an API key when authenticating. /// - /// The API key used to authenticate with the service endpoint. + /// The to authenticate with the service. /// Additional options to customize the client. /// The provided was null. public VectorStoreClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options)