diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioApiGroupCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioApiGroupCommand.g.cs index f2b2c1d58..fc699d0d9 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioApiGroupCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioApiGroupCommand.g.cs @@ -10,6 +10,7 @@ public static Command Create() { var command = new Command(@"audio", @"Audio endpoint commands."); command.Subcommands.Add(AudioCreateSpeechCommandApiCommand.Create()); + command.Subcommands.Add(AudioCreateSpeechAsStreamCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateTranscriptionCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateTranscriptionAsStreamCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateTranslationCommandApiCommand.Create()); diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateSpeechAsStreamCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateSpeechAsStreamCommandApiCommand.g.cs new file mode 100644 index 000000000..21ce4314b --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateSpeechAsStreamCommandApiCommand.g.cs @@ -0,0 +1,109 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal static partial class AudioCreateSpeechAsStreamCommandApiCommand +{ + private static Option> Model { get; } = new( + name: @"--model") + { + Description = @"One of the available [TTS models](/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`. +", + Required = true, + }; + + private static Option Voice { get; } = new( + name: @"--voice") + { + Description = @"The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ ""id"": ""voice_1234"" }`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options).", + Required = true, + }; + private static readonly CreateSpeechRequestOptionSet CreateSpeechRequestOptionSetOptions = CreateSpeechRequestOptionSet.Create(); + private static Option RequestInput { get; } = new(@"--request-input") + { + Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.", + }; + + private static Option RequestJson { get; } = new(@"--request-json") + { + Description = "Request body as JSON.", + Hidden = true, + }; + + private static Option RequestFile { get; } = new(@"--request-file") + { + Description = "Path to a JSON request file, or '-' for stdin.", + Hidden = true, + }; + + public static Command Create() + { + var command = new Command(@"create-speech-as-stream", @"Generates audio from the input text. + +Returns the audio file content, or a stream of audio events. +"); + command.Options.Add(Model); + command.Options.Add(Voice); command.Options.Add(CreateSpeechRequestOptionSetOptions.InputOption); + command.Options.Add(CreateSpeechRequestOptionSetOptions.Instructions); + command.Options.Add(CreateSpeechRequestOptionSetOptions.ResponseFormat); + command.Options.Add(CreateSpeechRequestOptionSetOptions.Speed); + command.Options.Add(CreateSpeechRequestOptionSetOptions.StreamFormat); + command.Options.Add(RequestInput); + command.Options.Add(RequestJson); + command.Options.Add(RequestFile); + command.Validators.Add(result => + { + var hasInput = result.GetResult(RequestInput) is not null; + var hasRequestJson = result.GetResult(RequestJson) is not null; + var hasRequestFile = result.GetResult(RequestFile) is not null; + var specifiedCount = (hasInput ? 1 : 0) + (hasRequestJson ? 1 : 0) + (hasRequestFile ? 1 : 0); + if (specifiedCount > 1) + { + result.AddError(@"Specify at most one of --request-input, --request-json, or --request-file."); + } + }); + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync( + parseResult, + RequestInput, + RequestJson, + RequestFile, + global::tryAGI.OpenAI.SourceGenerationContext.Default, + cancellationToken).ConfigureAwait(false); + var model = parseResult.GetRequiredValue(Model); + var voice = parseResult.GetRequiredValue(Voice); var input = parseResult.GetRequiredValue(CreateSpeechRequestOptionSetOptions.InputOption); + var instructions = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.Instructions) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.Instructions) : (__requestBase is { } __InstructionsBaseValue ? __InstructionsBaseValue.Instructions : default); + var responseFormat = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.ResponseFormat) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default); + var speed = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.Speed) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.Speed) : (__requestBase is { } __SpeedBaseValue ? __SpeedBaseValue.Speed : default); + var streamFormat = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.StreamFormat) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.StreamFormat) : (__requestBase is { } __StreamFormatBaseValue ? __StreamFormatBaseValue.StreamFormat : default); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = client.Audio.CreateSpeechAsStreamAsync( + model: model, + voice: voice, + input: input, + instructions: instructions, + responseFormat: responseFormat, + speed: speed, + streamFormat: streamFormat, + cancellationToken: cancellationToken); + + await foreach (var item in response.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + await CliRuntime.WriteResponseLineAsync( + parseResult, + item, + global::tryAGI.OpenAI.SourceGenerationContext.Default, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + }, cancellationToken).ConfigureAwait(false)); + return command; + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateSpeechCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateSpeechCommandApiCommand.g.cs index e6812efb8..a8d6579ce 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateSpeechCommandApiCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateSpeechCommandApiCommand.g.cs @@ -15,43 +15,13 @@ internal static partial class AudioCreateSpeechCommandApiCommand Required = true, }; - private static Option InputOption { get; } = new( - name: @"--input") - { - Description = @"The text to generate audio for. The maximum length is 4096 characters.", - Required = true, - }; - - private static Option Instructions { get; } = new( - name: @"--instructions") - { - Description = @"Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.", - }; - private static Option Voice { get; } = new( name: @"--voice") { Description = @"The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ ""id"": ""voice_1234"" }`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options).", Required = true, }; - - private static Option ResponseFormat { get; } = new( - name: @"--response-format") - { - Description = @"The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.", - }; - - private static Option Speed { get; } = new( - name: @"--speed") - { - Description = @"The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.", - }; - - private static Option StreamFormat { get; } = new( - name: @"--stream-format") - { - Description = @"The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.", - }; + private static readonly CreateSpeechRequestOptionSet CreateSpeechRequestOptionSetOptions = CreateSpeechRequestOptionSet.Create(); private static Option RequestInput { get; } = new(@"--request-input") { Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.", @@ -76,12 +46,11 @@ public static Command Create() Returns the audio file content, or a stream of audio events. "); command.Options.Add(Model); - command.Options.Add(InputOption); - command.Options.Add(Instructions); - command.Options.Add(Voice); - command.Options.Add(ResponseFormat); - command.Options.Add(Speed); - command.Options.Add(StreamFormat); + command.Options.Add(Voice); command.Options.Add(CreateSpeechRequestOptionSetOptions.InputOption); + command.Options.Add(CreateSpeechRequestOptionSetOptions.Instructions); + command.Options.Add(CreateSpeechRequestOptionSetOptions.ResponseFormat); + command.Options.Add(CreateSpeechRequestOptionSetOptions.Speed); + command.Options.Add(CreateSpeechRequestOptionSetOptions.StreamFormat); command.Options.Add(RequestInput); command.Options.Add(RequestJson); command.Options.Add(RequestFile); @@ -108,33 +77,25 @@ await CliRuntime.RunAsync(async () => global::tryAGI.OpenAI.SourceGenerationContext.Default, cancellationToken).ConfigureAwait(false); var model = parseResult.GetRequiredValue(Model); - var input = parseResult.GetRequiredValue(InputOption); - var instructions = CliRuntime.WasSpecified(parseResult, Instructions) ? parseResult.GetValue(Instructions) : (__requestBase is { } __InstructionsBaseValue ? __InstructionsBaseValue.Instructions : default); - var voice = parseResult.GetRequiredValue(Voice); - var responseFormat = CliRuntime.WasSpecified(parseResult, ResponseFormat) ? parseResult.GetValue(ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default); - var speed = CliRuntime.WasSpecified(parseResult, Speed) ? parseResult.GetValue(Speed) : (__requestBase is { } __SpeedBaseValue ? __SpeedBaseValue.Speed : default); - var streamFormat = CliRuntime.WasSpecified(parseResult, StreamFormat) ? parseResult.GetValue(StreamFormat) : (__requestBase is { } __StreamFormatBaseValue ? __StreamFormatBaseValue.StreamFormat : default); + var voice = parseResult.GetRequiredValue(Voice); var input = parseResult.GetRequiredValue(CreateSpeechRequestOptionSetOptions.InputOption); + var instructions = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.Instructions) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.Instructions) : (__requestBase is { } __InstructionsBaseValue ? __InstructionsBaseValue.Instructions : default); + var responseFormat = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.ResponseFormat) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default); + var speed = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.Speed) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.Speed) : (__requestBase is { } __SpeedBaseValue ? __SpeedBaseValue.Speed : default); + var streamFormat = CliRuntime.WasSpecified(parseResult, CreateSpeechRequestOptionSetOptions.StreamFormat) ? parseResult.GetValue(CreateSpeechRequestOptionSetOptions.StreamFormat) : (__requestBase is { } __StreamFormatBaseValue ? __StreamFormatBaseValue.StreamFormat : default); using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); - var response = client.Audio.CreateSpeechAsync( + var response = await client.Audio.CreateSpeechAsync( model: model, + voice: voice, input: input, instructions: instructions, - voice: voice, responseFormat: responseFormat, speed: speed, streamFormat: streamFormat, - cancellationToken: cancellationToken); + cancellationToken: cancellationToken).ConfigureAwait(false); - await foreach (var item in response.WithCancellation(cancellationToken).ConfigureAwait(false)) - { - await CliRuntime.WriteResponseLineAsync( - parseResult, - item, - global::tryAGI.OpenAI.SourceGenerationContext.Default, - cancellationToken: cancellationToken).ConfigureAwait(false); - } + await CliRuntime.WriteBinaryAsync(parseResult, response, cancellationToken).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false)); return command; } diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/CreateSpeechRequestOptionSet.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/CreateSpeechRequestOptionSet.g.cs new file mode 100644 index 000000000..dd53123c2 --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/CreateSpeechRequestOptionSet.g.cs @@ -0,0 +1,43 @@ +#nullable enable + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal sealed record CreateSpeechRequestOptionSet( + Option InputOption, + Option Instructions, + Option ResponseFormat, + Option Speed, + Option StreamFormat) +{ + public static CreateSpeechRequestOptionSet Create(string? prefix = null) + { + var normalizedPrefix = string.IsNullOrWhiteSpace(prefix) + ? string.Empty + : prefix.Trim().Trim('-') + "-"; + return new CreateSpeechRequestOptionSet( + InputOption: new Option($"--{normalizedPrefix}input") + { + Description = @"The text to generate audio for. The maximum length is 4096 characters.", + Required = true, + }, + Instructions: new Option($"--{normalizedPrefix}instructions") + { + Description = @"Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.", + }, + ResponseFormat: new Option($"--{normalizedPrefix}response-format") + { + Description = @"The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.", + }, + Speed: new Option($"--{normalizedPrefix}speed") + { + Description = @"The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.", + }, + StreamFormat: new Option($"--{normalizedPrefix}stream-format") + { + Description = @"The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.", + } + ); + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/RealtimeCreateCallCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/RealtimeCreateCallCommandApiCommand.g.cs index 67b58573f..ab140471f 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/RealtimeCreateCallCommandApiCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/RealtimeCreateCallCommandApiCommand.g.cs @@ -31,26 +31,6 @@ internal static partial class RealtimeCreateCallCommandApiCommand Hidden = true, }; - private static string FormatResponse(ParseResult parseResult, string value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) - { - string? text = null; - CustomizeResponseText(parseResult, value, ref text); - if (!string.IsNullOrWhiteSpace(text)) - { - return text; - } - - var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) - { - }; - CustomizeResponseFormatHints(hints); - return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); - } - - static partial void CustomizeResponseText(ParseResult parseResult, string value, ref string? text); - static partial void CustomizeResponseFormatHints(Dictionary hints); - - public static Command Create() { var command = new Command(@"create-call", @"Create a new Realtime API call over WebRTC and receive the SDP answer needed @@ -113,13 +93,7 @@ await CliRuntime.RunAsync(async () => session: session, cancellationToken: cancellationToken).ConfigureAwait(false); - - await CliRuntime.WriteResponseAsync( - parseResult, - response, - global::tryAGI.OpenAI.SourceGenerationContext.Default, - FormatResponse, - cancellationToken).ConfigureAwait(false); + await CliRuntime.WriteBinaryAsync(parseResult, response, cancellationToken).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false)); return command; } diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsApiGroupCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsApiGroupCommand.g.cs index 2dc4378e6..0f5e02e67 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsApiGroupCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsApiGroupCommand.g.cs @@ -15,8 +15,10 @@ public static Command Create() command.Subcommands.Add(SkillsDeleteSkillVersionCommandApiCommand.Create()); command.Subcommands.Add(SkillsGetSkillCommandApiCommand.Create()); command.Subcommands.Add(SkillsGetSkillContentCommandApiCommand.Create()); + command.Subcommands.Add(SkillsGetSkillContentAsBytesCommandApiCommand.Create()); command.Subcommands.Add(SkillsGetSkillVersionCommandApiCommand.Create()); command.Subcommands.Add(SkillsGetSkillVersionContentCommandApiCommand.Create()); + command.Subcommands.Add(SkillsGetSkillVersionContentAsBytesCommandApiCommand.Create()); command.Subcommands.Add(SkillsListSkillVersionsCommandApiCommand.Create()); command.Subcommands.Add(SkillsListSkillsCommandApiCommand.Create()); command.Subcommands.Add(SkillsUpdateSkillDefaultVersionCommandApiCommand.Create()); diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsGetSkillContentAsBytesCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsGetSkillContentAsBytesCommandApiCommand.g.cs new file mode 100644 index 000000000..fefa1d25e --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsGetSkillContentAsBytesCommandApiCommand.g.cs @@ -0,0 +1,37 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal static partial class SkillsGetSkillContentAsBytesCommandApiCommand +{ + private static Argument SkillId { get; } = new( + name: @"skill-id") + { + Description = @"The identifier of the skill to download.", + }; + + public static Command Create() + { + var command = new Command(@"get-skill-content-as-bytes", @"Download a skill zip bundle by its ID."); + command.Arguments.Add(SkillId); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var skillId = parseResult.GetRequiredValue(SkillId); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Skills.GetSkillContentAsBytesAsync( + skillId: skillId, + cancellationToken: cancellationToken).ConfigureAwait(false); + + await CliRuntime.WriteBinaryAsync(parseResult, response, cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + return command; + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsGetSkillVersionContentAsBytesCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsGetSkillVersionContentAsBytesCommandApiCommand.g.cs new file mode 100644 index 000000000..7b8ea8171 --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/SkillsGetSkillVersionContentAsBytesCommandApiCommand.g.cs @@ -0,0 +1,46 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal static partial class SkillsGetSkillVersionContentAsBytesCommandApiCommand +{ + private static Argument SkillId { get; } = new( + name: @"skill-id") + { + Description = @"The identifier of the skill.", + }; + + private static Argument Version { get; } = new( + name: @"version") + { + Description = @"The skill version number.", + }; + + public static Command Create() + { + var command = new Command(@"get-skill-version-content-as-bytes", @"Download a skill version zip bundle."); + command.Arguments.Add(SkillId); + command.Arguments.Add(Version); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var skillId = parseResult.GetRequiredValue(SkillId); + var version = parseResult.GetRequiredValue(Version); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Skills.GetSkillVersionContentAsBytesAsync( + skillId: skillId, + version: version, + cancellationToken: cancellationToken).ConfigureAwait(false); + + await CliRuntime.WriteBinaryAsync(parseResult, response, cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + return command; + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/VideosApiGroupCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/VideosApiGroupCommand.g.cs index 0e611d9dc..1c8d2dd14 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/VideosApiGroupCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/VideosApiGroupCommand.g.cs @@ -19,6 +19,7 @@ public static Command Create() command.Subcommands.Add(VideosRemixVideoCommandApiCommand.Create()); command.Subcommands.Add(VideosRetrieveVideoCommandApiCommand.Create()); command.Subcommands.Add(VideosRetrieveVideoContentCommandApiCommand.Create()); + command.Subcommands.Add(VideosRetrieveVideoContentAsBytesCommandApiCommand.Create()); return command; } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/VideosRetrieveVideoContentAsBytesCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/VideosRetrieveVideoContentAsBytesCommandApiCommand.g.cs new file mode 100644 index 000000000..8bfe31477 --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/VideosRetrieveVideoContentAsBytesCommandApiCommand.g.cs @@ -0,0 +1,48 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal static partial class VideosRetrieveVideoContentAsBytesCommandApiCommand +{ + private static Argument VideoId { get; } = new( + name: @"video-id") + { + Description = @"The identifier of the video whose media to download.", + }; + + private static Option Variant { get; } = new( + name: @"--variant") + { + Description = @"Which downloadable asset to return. Defaults to the MP4 video.", + }; + + public static Command Create() + { + var command = new Command(@"retrieve-video-content-as-bytes", @"Download the generated video bytes or a derived preview asset. + +Streams the rendered video content for the specified video job."); + command.Arguments.Add(VideoId); + command.Options.Add(Variant); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var videoId = parseResult.GetRequiredValue(VideoId); + var variant = parseResult.GetValue(Variant); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Videos.RetrieveVideoContentAsBytesAsync( + videoId: videoId, + variant: variant, + cancellationToken: cancellationToken).ConfigureAwait(false); + + await CliRuntime.WriteBinaryAsync(parseResult, response, cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + return command; + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/autosdk.generated-examples.json b/src/libs/tryAGI.OpenAI/Generated/autosdk.generated-examples.json index 6766c76e3..808a81ce0 100644 --- a/src/libs/tryAGI.OpenAI/Generated/autosdk.generated-examples.json +++ b/src/libs/tryAGI.OpenAI/Generated/autosdk.generated-examples.json @@ -82,11 +82,11 @@ "Title": "Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (\u0060gpt-image-1.5\u0060, \u0060gpt-image-1\u0060, \u0060gpt-image-1-mini\u0060, and \u0060chatgpt-image-latest\u0060) and \u0060dall-e-2\u0060.", "Slug": "createimageedit", "Description": "You can call this endpoint with either:\n\n- \u0060multipart/form-data\u0060: use binary uploads via \u0060image\u0060 (and optional \u0060mask\u0060).\n- \u0060application/json\u0060: use \u0060images\u0060 (and optional \u0060mask\u0060) as references with either \u0060image_url\u0060 or \u0060file_id\u0060.\n\nNote that JSON requests use \u0060images\u0060 (array) instead of the multipart \u0060image\u0060 field.", - "Language": "csharp", - "Code": "using var client = new OpenAiClient(apiKey);\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::tryAGI.OpenAI.CreateImageEditRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022gpt-image-1.5\u0022\u0022,\n \u0022\u0022prompt\u0022\u0022: \u0022\u0022Replace the background with a snowy mountain scene\u0022\u0022,\n \u0022\u0022images\u0022\u0022: [\n {\n \u0022\u0022file_id\u0022\u0022: \u0022\u0022file-abc123\u0022\u0022\n }\n ],\n \u0022\u0022mask\u0022\u0022: {\n \u0022\u0022file_id\u0022\u0022: \u0022\u0022file-mask123\u0022\u0022\n },\n \u0022\u0022output_format\u0022\u0022: \u0022\u0022png\u0022\u0022,\n \u0022\u0022output_compression\u0022\u0022: 100\n}\u0022)!;\n\nvar response = await client.Images.CreateImageEditAsync(\n request: request\n);", - "Format": "sdk", + "Language": "http", + "Code": "### Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (\u0060gpt-image-1.5\u0060, \u0060gpt-image-1\u0060, \u0060gpt-image-1-mini\u0060, and \u0060chatgpt-image-latest\u0060) and \u0060dall-e-2\u0060.\n# @name createImageEdit\nPOST {{host}}/images/edits\nAuthorization: Bearer {{token}}\nContent-Type: multipart/form-data; boundary=AutoSDKBoundary\nAccept: application/json, text/event-stream\n\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022image\u0022; filename=\u0022image.bin\u0022\nContent-Type: application/octet-stream\n\n\u003C ./image.bin\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022prompt\u0022\n\nA cute baby sea otter wearing a beret\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022mask\u0022; filename=\u0022mask.bin\u0022\nContent-Type: application/octet-stream\n\n\u003C ./mask.bin\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022background\u0022\n\ntransparent\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022model\u0022\n\ngpt-image-1.5\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022n\u0022\n\n1\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022size\u0022\n\n1024x1024\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022response_format\u0022\n\nurl\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022output_format\u0022\n\npng\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022output_compression\u0022\n\n100\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022user\u0022\n\nuser-1234\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022input_fidelity\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022stream\u0022\n\nfalse\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022partial_images\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022quality\u0022\n\nhigh\n--AutoSDKBoundary--\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/json, text/event-stream", + "Format": "http", "OperationId": "createImageEdit", - "Setup": "This example assumes \u0060using tryAGI.OpenAI;\u0060 is in scope and \u0060apiKey\u0060 contains the required credential." + "Setup": null }, { "Order": 9, diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs index 5732cf691..a756f1638 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs @@ -36,6 +36,11 @@ partial void ProcessCreateSpeechResponse( global::System.Net.Http.HttpClient httpClient, global::System.Net.Http.HttpResponseMessage httpResponseMessage); + partial void ProcessCreateSpeechResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref byte[] content); + /// /// Generates audio from the input text.
/// Returns the audio file content, or a stream of audio events. @@ -44,11 +49,34 @@ partial void ProcessCreateSpeechResponse( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsync( + public async global::System.Threading.Tasks.Task CreateSpeechAsync( global::tryAGI.OpenAI.CreateSpeechRequest request, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, - [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateSpeechAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task CreateSpeechAsStreamAsync( + + global::tryAGI.OpenAI.CreateSpeechRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -97,6 +125,10 @@ partial void ProcessCreateSpeechResponse( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/octet-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || @@ -256,7 +288,7 @@ partial void ProcessCreateSpeechResponse( throw new global::System.InvalidOperationException("No response received."); } - using (__response) + try { ProcessResponse( @@ -313,8 +345,16 @@ partial void ProcessCreateSpeechResponse( try { __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.ResponseStream(__response, __content); } - catch (global::System.Net.Http.HttpRequestException __ex) + catch (global::System.Exception __ex) { string? __content = null; try @@ -340,33 +380,374 @@ partial void ProcessCreateSpeechResponse( h => h.Value)); } - using var __stream = await __response.Content.ReadAsStreamAsync( + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreateSpeechAsResponseAsync( + + global::tryAGI.OpenAI.CreateSpeechRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PrepareCreateSpeechArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateSpeechSecurityRequirements, + operationName: "CreateSpeechAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: "/audio/speech", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/octet-stream"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateSpeechRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeech", + methodName: "CreateSpeechAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeech", + methodName: "CreateSpeechAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeech", + methodName: "CreateSpeechAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateSpeechResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeech", + methodName: "CreateSpeechAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeech", + methodName: "CreateSpeechAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER - __effectiveCancellationToken + __effectiveCancellationToken #endif - ).ConfigureAwait(false); + ).ConfigureAwait(false); - await foreach (var __sseEvent in global::System.Net.ServerSentEvents.SseParser - .Create(__stream).EnumerateAsync(__effectiveCancellationToken)) + ProcessCreateSpeechResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: null, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else { - var __content = __sseEvent.Data; - if (__content == "[DONE]") + try { - yield break; + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } - var __streamedResponse = global::tryAGI.OpenAI.CreateSpeechResponseStreamEvent.FromJson(__content, JsonSerializerContext) ?? - throw global::tryAGI.OpenAI.ApiException.Create( - statusCode: __response.StatusCode, - message: $"Response deserialization failed for \"{__content}\" ", - innerException: null, - responseBody: __content, - responseHeaders: global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value)); - - yield return __streamedResponse; + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } } } @@ -407,7 +788,7 @@ partial void ProcessCreateSpeechResponse( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsync( + public async global::System.Threading.Tasks.Task CreateSpeechAsync( global::tryAGI.OpenAI.AnyOf model, string input, global::tryAGI.OpenAI.VoiceIdsOrCustomVoice voice, @@ -416,7 +797,7 @@ partial void ProcessCreateSpeechResponse( double? speed = default, global::tryAGI.OpenAI.CreateSpeechRequestStreamFormat? streamFormat = default, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, - [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::tryAGI.OpenAI.CreateSpeechRequest { @@ -429,15 +810,10 @@ partial void ProcessCreateSpeechResponse( StreamFormat = streamFormat, }; - var __enumerable = CreateSpeechAsync( + return await CreateSpeechAsync( request: __request, requestOptions: requestOptions, - cancellationToken: cancellationToken); - - await foreach (var __response in __enumerable) - { - yield return __response; - } + cancellationToken: cancellationToken).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeechAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeechAsStream.g.cs new file mode 100644 index 000000000..abce65297 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeechAsStream.g.cs @@ -0,0 +1,447 @@ + +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial class AudioClient + { + + + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement s_CreateSpeechAsStreamSecurityRequirement0 = + new global::tryAGI.OpenAI.EndPointSecurityRequirement + { + Authorizations = new global::tryAGI.OpenAI.EndPointAuthorizationRequirement[] + { new global::tryAGI.OpenAI.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "ApiKeyAuth", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement[] s_CreateSpeechAsStreamSecurityRequirements = + new global::tryAGI.OpenAI.EndPointSecurityRequirement[] + { s_CreateSpeechAsStreamSecurityRequirement0, + }; + partial void PrepareCreateSpeechAsStreamArguments( + global::System.Net.Http.HttpClient httpClient, + global::tryAGI.OpenAI.CreateSpeechRequest request); + partial void PrepareCreateSpeechAsStreamRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + global::tryAGI.OpenAI.CreateSpeechRequest request); + partial void ProcessCreateSpeechAsStreamResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsStreamAsync( + + global::tryAGI.OpenAI.CreateSpeechRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PrepareCreateSpeechAsStreamArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateSpeechAsStreamSecurityRequirements, + operationName: "CreateSpeechAsStreamAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: "/audio/speech", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateSpeechAsStreamRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeechAsStream", + methodName: "CreateSpeechAsStreamAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeechAsStream", + methodName: "CreateSpeechAsStreamAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeechAsStream", + methodName: "CreateSpeechAsStreamAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateSpeechAsStreamResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeechAsStream", + methodName: "CreateSpeechAsStreamAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSpeechAsStream", + methodName: "CreateSpeechAsStreamAsync", + pathTemplate: "\"/audio/speech\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + } + catch (global::System.Net.Http.HttpRequestException __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + using var __stream = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + await foreach (var __sseEvent in global::System.Net.ServerSentEvents.SseParser + .Create(__stream).EnumerateAsync(__effectiveCancellationToken)) + { + var __content = __sseEvent.Data; + if (__content == "[DONE]") + { + yield break; + } + + var __streamedResponse = global::tryAGI.OpenAI.CreateSpeechResponseStreamEvent.FromJson(__content, JsonSerializerContext) ?? + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: $"Response deserialization failed for \"{__content}\" ", + innerException: null, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + + yield return __streamedResponse; + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// One of the available [TTS models](/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`. + /// + /// + /// The text to generate audio for. The maximum length is 4096 characters. + /// + /// + /// Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`. + /// + /// + /// The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options). + /// + /// + /// The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
+ /// Default Value: mp3 + /// + /// + /// The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.
+ /// Default Value: 1 + /// + /// + /// The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
+ /// Default Value: audio + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsStreamAsync( + global::tryAGI.OpenAI.AnyOf model, + string input, + global::tryAGI.OpenAI.VoiceIdsOrCustomVoice voice, + string? instructions = default, + global::tryAGI.OpenAI.CreateSpeechRequestResponseFormat? responseFormat = default, + double? speed = default, + global::tryAGI.OpenAI.CreateSpeechRequestStreamFormat? streamFormat = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::tryAGI.OpenAI.CreateSpeechRequest + { + Model = model, + Input = input, + Instructions = instructions, + Voice = voice, + ResponseFormat = responseFormat, + Speed = speed, + StreamFormat = streamFormat, + }; + + var __enumerable = CreateSpeechAsStreamAsync( + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + + await foreach (var __response in __enumerable) + { + yield return __response; + } + } + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs index 405f3bba8..4239c9089 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs @@ -145,6 +145,10 @@ partial void ProcessCreateTranscriptionResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || @@ -830,6 +834,10 @@ request.Filename is null __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || @@ -1407,6 +1415,10 @@ request.Filename is null __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs index 28bda39c9..44bcd5193 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs @@ -116,6 +116,10 @@ partial void ProcessCreateTranscriptionAsStreamResponse( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || @@ -777,6 +781,10 @@ request.Filename is null __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs index 3c4a6b4b8..9ae10628f 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs @@ -147,6 +147,10 @@ partial void ProcessCreateChatCompletionResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs index e158a75ca..7970d3b49 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs @@ -107,6 +107,10 @@ partial void ProcessCreateChatCompletionAsStreamResponse( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs index 0b5fd16ca..d11207f50 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs @@ -12,7 +12,33 @@ public partial interface IAudioClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsync( + global::System.Threading.Tasks.Task CreateSpeechAsync( + + global::tryAGI.OpenAI.CreateSpeechRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreateSpeechAsStreamAsync( + + global::tryAGI.OpenAI.CreateSpeechRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateSpeechAsResponseAsync( global::tryAGI.OpenAI.CreateSpeechRequest request, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, @@ -48,7 +74,7 @@ public partial interface IAudioClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsync( + global::System.Threading.Tasks.Task CreateSpeechAsync( global::tryAGI.OpenAI.AnyOf model, string input, global::tryAGI.OpenAI.VoiceIdsOrCustomVoice voice, diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeechAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeechAsStream.g.cs new file mode 100644 index 000000000..9d71d25a2 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeechAsStream.g.cs @@ -0,0 +1,62 @@ +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial interface IAudioClient + { + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsStreamAsync( + + global::tryAGI.OpenAI.CreateSpeechRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generates audio from the input text.
+ /// Returns the audio file content, or a stream of audio events. + ///
+ /// + /// One of the available [TTS models](/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`. + /// + /// + /// The text to generate audio for. The maximum length is 4096 characters. + /// + /// + /// Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`. + /// + /// + /// The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options). + /// + /// + /// The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
+ /// Default Value: mp3 + /// + /// + /// The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.
+ /// Default Value: 1 + /// + /// + /// The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
+ /// Default Value: audio + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Collections.Generic.IAsyncEnumerable CreateSpeechAsStreamAsync( + global::tryAGI.OpenAI.AnyOf model, + string input, + global::tryAGI.OpenAI.VoiceIdsOrCustomVoice voice, + string? instructions = default, + global::tryAGI.OpenAI.CreateSpeechRequestResponseFormat? responseFormat = default, + double? speed = default, + global::tryAGI.OpenAI.CreateSpeechRequestStreamFormat? streamFormat = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IRealtimeClient.CreateCall.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IRealtimeClient.CreateCall.g.cs index e6e0e2565..26d2a6f2c 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IRealtimeClient.CreateCall.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IRealtimeClient.CreateCall.g.cs @@ -12,7 +12,7 @@ public partial interface IRealtimeClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Threading.Tasks.Task CreateCallAsync( + global::System.Threading.Tasks.Task CreateCallAsync( global::tryAGI.OpenAI.RealtimeCallCreateRequest request, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, @@ -25,7 +25,20 @@ public partial interface IRealtimeClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Threading.Tasks.Task> CreateCallAsResponseAsync( + global::System.Threading.Tasks.Task CreateCallAsStreamAsync( + + global::tryAGI.OpenAI.RealtimeCallCreateRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a new Realtime API call over WebRTC and receive the SDP answer needed
+ /// to complete the peer connection. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateCallAsResponseAsync( global::tryAGI.OpenAI.RealtimeCallCreateRequest request, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, @@ -45,7 +58,7 @@ public partial interface IRealtimeClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Threading.Tasks.Task CreateCallAsync( + global::System.Threading.Tasks.Task CreateCallAsync( string sdp, global::tryAGI.OpenAI.RealtimeSessionCreateRequestGA? session = default, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ISkillsClient.GetSkillContentAsBytes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ISkillsClient.GetSkillContentAsBytes.g.cs new file mode 100644 index 000000000..036696739 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ISkillsClient.GetSkillContentAsBytes.g.cs @@ -0,0 +1,47 @@ +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial interface ISkillsClient + { + /// + /// Download a skill zip bundle by its ID. + /// + /// + /// Example: skill_123 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task GetSkillContentAsBytesAsync( + string skillId, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download a skill zip bundle by its ID. + /// + /// + /// Example: skill_123 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task GetSkillContentAsBytesAsStreamAsync( + string skillId, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download a skill zip bundle by its ID. + /// + /// + /// Example: skill_123 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetSkillContentAsBytesAsResponseAsync( + string skillId, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ISkillsClient.GetSkillVersionContentAsBytes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ISkillsClient.GetSkillVersionContentAsBytes.g.cs new file mode 100644 index 000000000..d618b03d2 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ISkillsClient.GetSkillVersionContentAsBytes.g.cs @@ -0,0 +1,59 @@ +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial interface ISkillsClient + { + /// + /// Download a skill version zip bundle. + /// + /// + /// Example: skill_123 + /// + /// + /// The skill version number. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task GetSkillVersionContentAsBytesAsync( + string skillId, + string version, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download a skill version zip bundle. + /// + /// + /// Example: skill_123 + /// + /// + /// The skill version number. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task GetSkillVersionContentAsBytesAsStreamAsync( + string skillId, + string version, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download a skill version zip bundle. + /// + /// + /// Example: skill_123 + /// + /// + /// The skill version number. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetSkillVersionContentAsBytesAsResponseAsync( + string skillId, + string version, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IVideosClient.RetrieveVideoContentAsBytes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IVideosClient.RetrieveVideoContentAsBytes.g.cs new file mode 100644 index 000000000..42184a317 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IVideosClient.RetrieveVideoContentAsBytes.g.cs @@ -0,0 +1,56 @@ +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial interface IVideosClient + { + /// + /// Download the generated video bytes or a derived preview asset.
+ /// Streams the rendered video content for the specified video job. + ///
+ /// + /// Example: video_123 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task RetrieveVideoContentAsBytesAsync( + string videoId, + global::tryAGI.OpenAI.VideoContentVariant? variant = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download the generated video bytes or a derived preview asset.
+ /// Streams the rendered video content for the specified video job. + ///
+ /// + /// Example: video_123 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task RetrieveVideoContentAsBytesAsStreamAsync( + string videoId, + global::tryAGI.OpenAI.VideoContentVariant? variant = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download the generated video bytes or a derived preview asset.
+ /// Streams the rendered video content for the specified video job. + ///
+ /// + /// Example: video_123 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> RetrieveVideoContentAsBytesAsResponseAsync( + string videoId, + global::tryAGI.OpenAI.VideoContentVariant? variant = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImage.g.cs index eba1892ef..1fff976d7 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImage.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImage.g.cs @@ -140,6 +140,10 @@ partial void ProcessCreateImageResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageAsStream.g.cs index 3359af3d9..c31454020 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageAsStream.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageAsStream.g.cs @@ -113,6 +113,10 @@ partial void ProcessCreateImageAsStreamResponse( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEdit.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEdit.g.cs index ee10104ee..e73ece04c 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEdit.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEdit.g.cs @@ -150,6 +150,10 @@ partial void ProcessCreateImageEditResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEditAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEditAsStream.g.cs index 93197ecdc..bff40d6cf 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEditAsStream.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ImagesClient.CreateImageEditAsStream.g.cs @@ -119,6 +119,10 @@ partial void ProcessCreateImageEditAsStreamResponse( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.OpenAiClient.CreateContainerFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.OpenAiClient.CreateContainerFile.g.cs index a76faa602..fc989d08a 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.OpenAiClient.CreateContainerFile.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.OpenAiClient.CreateContainerFile.g.cs @@ -153,10 +153,6 @@ partial void ProcessCreateContainerFileResponseContent( } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(containerId ?? string.Empty), - name: "\"container_id\""); - if (request.FileId != default) { diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.RealtimeClient.CreateCall.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.RealtimeClient.CreateCall.g.cs index 07753ace2..a173c2cd5 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.RealtimeClient.CreateCall.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.RealtimeClient.CreateCall.g.cs @@ -39,7 +39,7 @@ partial void ProcessCreateCallResponse( partial void ProcessCreateCallResponseContent( global::System.Net.Http.HttpClient httpClient, global::System.Net.Http.HttpResponseMessage httpResponseMessage, - ref string content); + ref byte[] content); /// /// Create a new Realtime API call over WebRTC and receive the SDP answer needed
@@ -49,7 +49,7 @@ partial void ProcessCreateCallResponseContent( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task CreateCallAsync( + public async global::System.Threading.Tasks.Task CreateCallAsync( global::tryAGI.OpenAI.RealtimeCallCreateRequest request, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, @@ -72,7 +72,342 @@ partial void ProcessCreateCallResponseContent( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task> CreateCallAsResponseAsync( + public async global::System.Threading.Tasks.Task CreateCallAsStreamAsync( + + global::tryAGI.OpenAI.RealtimeCallCreateRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PrepareCreateCallArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateCallSecurityRequirements, + operationName: "CreateCallAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: "/realtime/calls", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Sdp ?? string.Empty), + name: "\"sdp\""); + + if (request.Session != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Session.ToJson(JsonSerializerContext)), + name: "\"session\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateCallRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateCall", + methodName: "CreateCallAsync", + pathTemplate: "\"/realtime/calls\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateCall", + methodName: "CreateCallAsync", + pathTemplate: "\"/realtime/calls\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateCall", + methodName: "CreateCallAsync", + pathTemplate: "\"/realtime/calls\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateCallResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateCall", + methodName: "CreateCallAsync", + pathTemplate: "\"/realtime/calls\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateCall", + methodName: "CreateCallAsync", + pathTemplate: "\"/realtime/calls\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.ResponseStream(__response, __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Create a new Realtime API call over WebRTC and receive the SDP answer needed
+ /// to complete the peer connection. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreateCallAsResponseAsync( global::tryAGI.OpenAI.RealtimeCallCreateRequest request, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, @@ -351,16 +686,12 @@ partial void ProcessCreateCallResponseContent( if (__effectiveReadResponseAsString) { - var __content = await __response.Content.ReadAsStringAsync( + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); ProcessCreateCallResponseContent( httpClient: HttpClient, httpResponseMessage: __response, @@ -370,7 +701,7 @@ partial void ProcessCreateCallResponseContent( { __response.EnsureSuccessStatusCode(); - return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), requestUri: __response.RequestMessage?.RequestUri, @@ -380,9 +711,9 @@ partial void ProcessCreateCallResponseContent( { throw global::tryAGI.OpenAI.ApiException.Create( statusCode: __response.StatusCode, - message: __content ?? __response.ReasonPhrase ?? string.Empty, + message: __response.ReasonPhrase ?? string.Empty, innerException: __ex, - responseBody: __content, + responseBody: null, responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, @@ -394,13 +725,13 @@ partial void ProcessCreateCallResponseContent( try { __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), requestUri: __response.RequestMessage?.RequestUri, @@ -455,7 +786,7 @@ partial void ProcessCreateCallResponseContent( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task CreateCallAsync( + public async global::System.Threading.Tasks.Task CreateCallAsync( string sdp, global::tryAGI.OpenAI.RealtimeSessionCreateRequestGA? session = default, global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponseStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponseStream.g.cs new file mode 100644 index 000000000..77e1aff82 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponseStream.g.cs @@ -0,0 +1,117 @@ + +#nullable enable + +namespace tryAGI.OpenAI +{ + internal sealed class ResponseStream : global::System.IO.Stream + { + private readonly global::System.Net.Http.HttpResponseMessage _response; + private readonly global::System.IO.Stream _stream; + private bool _disposed; + + public ResponseStream( + global::System.Net.Http.HttpResponseMessage response, + global::System.IO.Stream stream) + { + _response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + _stream = stream ?? throw new global::System.ArgumentNullException(nameof(stream)); + } + + public override bool CanRead => _stream.CanRead; + public override bool CanSeek => _stream.CanSeek; + public override bool CanWrite => _stream.CanWrite; + public override bool CanTimeout => _stream.CanTimeout; + public override long Length => _stream.Length; + + public override long Position + { + get => _stream.Position; + set => _stream.Position = value; + } + + public override int ReadTimeout + { + get => _stream.ReadTimeout; + set => _stream.ReadTimeout = value; + } + + public override int WriteTimeout + { + get => _stream.WriteTimeout; + set => _stream.WriteTimeout = value; + } + + public override void Flush() => _stream.Flush(); + + public override global::System.Threading.Tasks.Task FlushAsync( + global::System.Threading.CancellationToken cancellationToken) => + _stream.FlushAsync(cancellationToken); + + public override int Read(byte[] buffer, int offset, int count) => + _stream.Read(buffer, offset, count); + + public override global::System.Threading.Tasks.Task ReadAsync( + byte[] buffer, + int offset, + int count, + global::System.Threading.CancellationToken cancellationToken) => + _stream.ReadAsync(buffer, offset, count, cancellationToken); + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override global::System.Threading.Tasks.ValueTask ReadAsync( + global::System.Memory buffer, + global::System.Threading.CancellationToken cancellationToken = default) => + _stream.ReadAsync(buffer, cancellationToken); +#endif + + public override long Seek(long offset, global::System.IO.SeekOrigin origin) => + _stream.Seek(offset, origin); + + public override void SetLength(long value) => + _stream.SetLength(value); + + public override void Write(byte[] buffer, int offset, int count) => + _stream.Write(buffer, offset, count); + + public override global::System.Threading.Tasks.Task WriteAsync( + byte[] buffer, + int offset, + int count, + global::System.Threading.CancellationToken cancellationToken) => + _stream.WriteAsync(buffer, offset, count, cancellationToken); + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override global::System.Threading.Tasks.ValueTask WriteAsync( + global::System.ReadOnlyMemory buffer, + global::System.Threading.CancellationToken cancellationToken = default) => + _stream.WriteAsync(buffer, cancellationToken); +#endif + + protected override void Dispose(bool disposing) + { + if (!_disposed && disposing) + { + _disposed = true; + _stream.Dispose(); + _response.Dispose(); + } + + base.Dispose(disposing); + } + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override async global::System.Threading.Tasks.ValueTask DisposeAsync() + { + if (_disposed) + { + return; + } + + _disposed = true; + await _stream.DisposeAsync().ConfigureAwait(false); + _response.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); + } +#endif + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse.g.cs index defe0a771..0ec6e10c5 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse.g.cs @@ -133,6 +133,10 @@ partial void ProcessCreateAModelResponseResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2.g.cs index a179959f2..a341c617b 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2.g.cs @@ -141,6 +141,10 @@ partial void ProcessCreateAModelResponse2ResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2AsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2AsStream.g.cs index 7c1fb4052..65d8bece1 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2AsStream.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponse2AsStream.g.cs @@ -105,6 +105,10 @@ partial void ProcessCreateAModelResponse2AsStreamResponse( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponseAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponseAsStream.g.cs index 161cab1cc..6de8449f2 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponseAsStream.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ResponsesClient.CreateAModelResponseAsStream.g.cs @@ -100,6 +100,10 @@ partial void ProcessCreateAModelResponseAsStreamResponse( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "text/event-stream"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.CreateSkillVersion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.CreateSkillVersion.g.cs index 3184d0b6f..288d7e96f 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.CreateSkillVersion.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.CreateSkillVersion.g.cs @@ -153,9 +153,6 @@ partial void ProcessCreateSkillVersionResponseContent( } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(skillId ?? string.Empty), - name: "\"skill_id\""); if (request.Files.TryPickValue1(out var __valueFiles1)) { diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillContent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillContent.g.cs index 9daecb07d..84f5f7931 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillContent.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillContent.g.cs @@ -122,6 +122,10 @@ partial void ProcessGetSkillContentResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillContentAsBytes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillContentAsBytes.g.cs new file mode 100644 index 000000000..9e3e203cd --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillContentAsBytes.g.cs @@ -0,0 +1,744 @@ + +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial class SkillsClient + { + + + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement s_GetSkillContentAsBytesSecurityRequirement0 = + new global::tryAGI.OpenAI.EndPointSecurityRequirement + { + Authorizations = new global::tryAGI.OpenAI.EndPointAuthorizationRequirement[] + { new global::tryAGI.OpenAI.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "ApiKeyAuth", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement[] s_GetSkillContentAsBytesSecurityRequirements = + new global::tryAGI.OpenAI.EndPointSecurityRequirement[] + { s_GetSkillContentAsBytesSecurityRequirement0, + }; + partial void PrepareGetSkillContentAsBytesArguments( + global::System.Net.Http.HttpClient httpClient, + ref string skillId); + partial void PrepareGetSkillContentAsBytesRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string skillId); + partial void ProcessGetSkillContentAsBytesResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessGetSkillContentAsBytesResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref byte[] content); + + /// + /// Download a skill zip bundle by its ID. + /// + /// + /// Example: skill_123 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task GetSkillContentAsBytesAsync( + string skillId, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetSkillContentAsBytesAsResponseAsync( + skillId: skillId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Download a skill zip bundle by its ID. + /// + /// + /// Example: skill_123 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task GetSkillContentAsBytesAsStreamAsync( + string skillId, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetSkillContentAsBytesArguments( + httpClient: HttpClient, + skillId: ref skillId); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetSkillContentAsBytesSecurityRequirements, + operationName: "GetSkillContentAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: $"/skills/{skillId}/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/zip"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetSkillContentAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + skillId: skillId!); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetSkillContentAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.ResponseStream(__response, __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download a skill zip bundle by its ID. + /// + /// + /// Example: skill_123 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetSkillContentAsBytesAsResponseAsync( + string skillId, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetSkillContentAsBytesArguments( + httpClient: HttpClient, + skillId: ref skillId); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetSkillContentAsBytesSecurityRequirements, + operationName: "GetSkillContentAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: $"/skills/{skillId}/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/zip"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetSkillContentAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + skillId: skillId!); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetSkillContentAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillContentAsBytes", + methodName: "GetSkillContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessGetSkillContentAsBytesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: null, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillVersionContent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillVersionContent.g.cs index ec5e8eae6..df6257810 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillVersionContent.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillVersionContent.g.cs @@ -134,6 +134,10 @@ partial void ProcessGetSkillVersionContentResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillVersionContentAsBytes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillVersionContentAsBytes.g.cs new file mode 100644 index 000000000..76d95966a --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.SkillsClient.GetSkillVersionContentAsBytes.g.cs @@ -0,0 +1,763 @@ + +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial class SkillsClient + { + + + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement s_GetSkillVersionContentAsBytesSecurityRequirement0 = + new global::tryAGI.OpenAI.EndPointSecurityRequirement + { + Authorizations = new global::tryAGI.OpenAI.EndPointAuthorizationRequirement[] + { new global::tryAGI.OpenAI.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "ApiKeyAuth", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement[] s_GetSkillVersionContentAsBytesSecurityRequirements = + new global::tryAGI.OpenAI.EndPointSecurityRequirement[] + { s_GetSkillVersionContentAsBytesSecurityRequirement0, + }; + partial void PrepareGetSkillVersionContentAsBytesArguments( + global::System.Net.Http.HttpClient httpClient, + ref string skillId, + ref string version); + partial void PrepareGetSkillVersionContentAsBytesRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string skillId, + string version); + partial void ProcessGetSkillVersionContentAsBytesResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessGetSkillVersionContentAsBytesResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref byte[] content); + + /// + /// Download a skill version zip bundle. + /// + /// + /// Example: skill_123 + /// + /// + /// The skill version number. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task GetSkillVersionContentAsBytesAsync( + string skillId, + string version, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetSkillVersionContentAsBytesAsResponseAsync( + skillId: skillId, + version: version, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Download a skill version zip bundle. + /// + /// + /// Example: skill_123 + /// + /// + /// The skill version number. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task GetSkillVersionContentAsBytesAsStreamAsync( + string skillId, + string version, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetSkillVersionContentAsBytesArguments( + httpClient: HttpClient, + skillId: ref skillId, + version: ref version); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetSkillVersionContentAsBytesSecurityRequirements, + operationName: "GetSkillVersionContentAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: $"/skills/{skillId}/versions/{version}/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/zip"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetSkillVersionContentAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + skillId: skillId!, + version: version!); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetSkillVersionContentAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.ResponseStream(__response, __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download a skill version zip bundle. + /// + /// + /// Example: skill_123 + /// + /// + /// The skill version number. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetSkillVersionContentAsBytesAsResponseAsync( + string skillId, + string version, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetSkillVersionContentAsBytesArguments( + httpClient: HttpClient, + skillId: ref skillId, + version: ref version); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetSkillVersionContentAsBytesSecurityRequirements, + operationName: "GetSkillVersionContentAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: $"/skills/{skillId}/versions/{version}/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/zip"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetSkillVersionContentAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + skillId: skillId!, + version: version!); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetSkillVersionContentAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSkillVersionContentAsBytes", + methodName: "GetSkillVersionContentAsBytesAsync", + pathTemplate: "$\"/skills/{skillId}/versions/{version}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessGetSkillVersionContentAsBytesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: null, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.UploadsClient.AddUploadPart.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.UploadsClient.AddUploadPart.g.cs index fcf862dae..4dee8c22c 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.UploadsClient.AddUploadPart.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.UploadsClient.AddUploadPart.g.cs @@ -157,10 +157,6 @@ partial void ProcessAddUploadPartResponseContent( } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(uploadId ?? string.Empty), - name: "\"upload_id\""); - var __contentData = new global::System.Net.Http.ByteArrayContent(request.Data ?? global::System.Array.Empty()); __contentData.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Dataname is null @@ -620,10 +616,6 @@ request.Dataname is null } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(uploadId ?? string.Empty), - name: "\"upload_id\""); - var __contentData = new global::System.Net.Http.StreamContent(data); __contentData.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Dataname is null @@ -1038,10 +1030,6 @@ request.Dataname is null } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(uploadId ?? string.Empty), - name: "\"upload_id\""); - var __contentData = new global::System.Net.Http.StreamContent(data); __contentData.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Dataname is null diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RemixVideo.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RemixVideo.g.cs index 74a70e6a0..682cbb9a9 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RemixVideo.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RemixVideo.g.cs @@ -153,10 +153,6 @@ partial void ProcessRemixVideoResponseContent( } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(videoId ?? string.Empty), - name: "\"video_id\""); - __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RetrieveVideoContent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RetrieveVideoContent.g.cs index a1e961c9d..dd4e156f5 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RetrieveVideoContent.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RetrieveVideoContent.g.cs @@ -135,6 +135,10 @@ partial void ProcessRetrieveVideoContentResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RetrieveVideoContentAsBytes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RetrieveVideoContentAsBytes.g.cs new file mode 100644 index 000000000..5b8853a6b --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.VideosClient.RetrieveVideoContentAsBytes.g.cs @@ -0,0 +1,766 @@ + +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial class VideosClient + { + + + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement s_RetrieveVideoContentAsBytesSecurityRequirement0 = + new global::tryAGI.OpenAI.EndPointSecurityRequirement + { + Authorizations = new global::tryAGI.OpenAI.EndPointAuthorizationRequirement[] + { new global::tryAGI.OpenAI.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "ApiKeyAuth", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement[] s_RetrieveVideoContentAsBytesSecurityRequirements = + new global::tryAGI.OpenAI.EndPointSecurityRequirement[] + { s_RetrieveVideoContentAsBytesSecurityRequirement0, + }; + partial void PrepareRetrieveVideoContentAsBytesArguments( + global::System.Net.Http.HttpClient httpClient, + ref string videoId, + ref global::tryAGI.OpenAI.VideoContentVariant? variant); + partial void PrepareRetrieveVideoContentAsBytesRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string videoId, + global::tryAGI.OpenAI.VideoContentVariant? variant); + partial void ProcessRetrieveVideoContentAsBytesResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessRetrieveVideoContentAsBytesResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref byte[] content); + + /// + /// Download the generated video bytes or a derived preview asset.
+ /// Streams the rendered video content for the specified video job. + ///
+ /// + /// Example: video_123 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task RetrieveVideoContentAsBytesAsync( + string videoId, + global::tryAGI.OpenAI.VideoContentVariant? variant = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await RetrieveVideoContentAsBytesAsResponseAsync( + videoId: videoId, + variant: variant, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Download the generated video bytes or a derived preview asset.
+ /// Streams the rendered video content for the specified video job. + ///
+ /// + /// Example: video_123 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task RetrieveVideoContentAsBytesAsStreamAsync( + string videoId, + global::tryAGI.OpenAI.VideoContentVariant? variant = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareRetrieveVideoContentAsBytesArguments( + httpClient: HttpClient, + videoId: ref videoId, + variant: ref variant); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_RetrieveVideoContentAsBytesSecurityRequirements, + operationName: "RetrieveVideoContentAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: $"/videos/{videoId}/content", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("variant", variant?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "video/mp4"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveVideoContentAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + videoId: videoId!, + variant: variant); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRetrieveVideoContentAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.ResponseStream(__response, __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download the generated video bytes or a derived preview asset.
+ /// Streams the rendered video content for the specified video job. + ///
+ /// + /// Example: video_123 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> RetrieveVideoContentAsBytesAsResponseAsync( + string videoId, + global::tryAGI.OpenAI.VideoContentVariant? variant = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareRetrieveVideoContentAsBytesArguments( + httpClient: HttpClient, + videoId: ref videoId, + variant: ref variant); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_RetrieveVideoContentAsBytesSecurityRequirements, + operationName: "RetrieveVideoContentAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder( + path: $"/videos/{videoId}/content", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("variant", variant?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "video/mp4"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveVideoContentAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + videoId: videoId!, + variant: variant); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRetrieveVideoContentAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideoContentAsBytes", + methodName: "RetrieveVideoContentAsBytesAsync", + pathTemplate: "$\"/videos/{videoId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessRetrieveVideoContentAsBytesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: null, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::tryAGI.OpenAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + } +} \ No newline at end of file