From 2b3055214cc4bbcec1a1a5b51e941a83e37dc9c8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 27 Sep 2026 23:28:27 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../Commands/AudioApiGroupCommand.g.cs | 2 + ...ranscriptionAsStreamCommandApiCommand.g.cs | 3 +- ...eTranscriptionAsTextCommandApiCommand.g.cs | 160 + ...oCreateTranscriptionCommandApiCommand.g.cs | 3 +- ...ateTranslationAsTextCommandApiCommand.g.cs | 124 + ...dioCreateTranslationCommandApiCommand.g.cs | 50 +- .../CreateTranslationRequestOptionSet.g.cs | 42 + .../Generated/autosdk.generated-examples.json | 10 +- ...penAI.AudioClient.CreateTranscription.g.cs | 15 +- ...dioClient.CreateTranscriptionAsStream.g.cs | 9 +- ...AudioClient.CreateTranscriptionAsText.g.cs | 2760 +++++++++++++++++ ....OpenAI.AudioClient.CreateTranslation.g.cs | 12 + ...I.AudioClient.CreateTranslationAsText.g.cs | 2370 ++++++++++++++ ...enAI.IAudioClient.CreateTranscription.g.cs | 15 +- ...dioClient.CreateTranscriptionAsStream.g.cs | 9 +- ...AudioClient.CreateTranscriptionAsText.g.cs | 275 ++ ....IAudioClient.CreateTranslationAsText.g.cs | 146 + src/libs/tryAGI.OpenAI/openapi.yaml | 78 +- 18 files changed, 6018 insertions(+), 65 deletions(-) create mode 100644 src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsTextCommandApiCommand.g.cs create mode 100644 src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationAsTextCommandApiCommand.g.cs create mode 100644 src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/CreateTranslationRequestOptionSet.g.cs create mode 100644 src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsText.g.cs create mode 100644 src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslationAsText.g.cs create mode 100644 src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsText.g.cs create mode 100644 src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranslationAsText.g.cs 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 e41f063b7..e023c2d60 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioApiGroupCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioApiGroupCommand.g.cs @@ -13,7 +13,9 @@ public static Command Create() command.Subcommands.Add(AudioCreateSpeechAsEventStreamCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateTranscriptionCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateTranscriptionAsStreamCommandApiCommand.Create()); + command.Subcommands.Add(AudioCreateTranscriptionAsTextCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateTranslationCommandApiCommand.Create()); + command.Subcommands.Add(AudioCreateTranslationAsTextCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateVoiceCommandApiCommand.Create()); command.Subcommands.Add(AudioCreateVoiceConsentCommandApiCommand.Create()); command.Subcommands.Add(AudioDeleteVoiceConsentCommandApiCommand.Create()); diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsStreamCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsStreamCommandApiCommand.g.cs index b3c2f8fe6..5a029f38d 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsStreamCommandApiCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsStreamCommandApiCommand.g.cs @@ -53,7 +53,8 @@ public static Command Create() Transcribes audio into the input language. Returns a transcription object in `json`, `diarized_json`, or `verbose_json` -format, or a stream of transcript events. +format, plain text in `text`, `srt`, or `vtt` format, or a stream of +transcript events. Supported formats depend on the model. "); command.Options.Add(File); command.Options.Add(Model); diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsTextCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsTextCommandApiCommand.g.cs new file mode 100644 index 000000000..478b2454f --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionAsTextCommandApiCommand.g.cs @@ -0,0 +1,160 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal static partial class AudioCreateTranscriptionAsTextCommandApiCommand +{ + private static Option File { get; } = new( + name: @"--file") + { + Description = @"The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. +The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. +", + Required = true, + }; + + private static Option> Model { get; } = new( + name: @"--model") + { + Description = @"ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`. +", + Required = true, + }; + + private static Option?> ChunkingStrategy { get; } = new( + name: @"--chunking-strategy") + { + Description = @"", + }; + private static readonly CreateTranscriptionRequestOptionSet CreateTranscriptionRequestOptionSetOptions = CreateTranscriptionRequestOptionSet.Create(); + private static Option Input { get; } = new(@"--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, + }; + + 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-transcription-as-text", @"Create transcription +Transcribes audio into the input language. + +Returns a transcription object in `json`, `diarized_json`, or `verbose_json` +format, plain text in `text`, `srt`, or `vtt` format, or a stream of +transcript events. Supported formats depend on the model. +"); + command.Options.Add(File); + command.Options.Add(Model); + command.Options.Add(ChunkingStrategy); command.Options.Add(CreateTranscriptionRequestOptionSetOptions.Filename); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.Language); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.Languages); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.Keywords); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.Prompt); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.ResponseFormat); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.Temperature); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.Include); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.TimestampGranularities); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.KnownSpeakerNames); + command.Options.Add(CreateTranscriptionRequestOptionSetOptions.KnownSpeakerReferences); + command.Options.Add(Input); + command.Options.Add(RequestJson); + command.Options.Add(RequestFile); + command.Validators.Add(result => + { + var hasInput = result.GetResult(Input) 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 --input, --request-json, or --request-file."); + } + }); + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync( + parseResult, + Input, + RequestJson, + RequestFile, + global::tryAGI.OpenAI.SourceGenerationContext.Default, + cancellationToken).ConfigureAwait(false); + var file = parseResult.GetRequiredValue(File); + var model = parseResult.GetRequiredValue(Model); + var chunkingStrategy = CliRuntime.WasSpecified(parseResult, ChunkingStrategy) ? parseResult.GetValue(ChunkingStrategy) : (__requestBase is { } __ChunkingStrategyBaseValue ? __ChunkingStrategyBaseValue.ChunkingStrategy : default); var filename = parseResult.GetRequiredValue(CreateTranscriptionRequestOptionSetOptions.Filename); + var language = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.Language) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.Language) : (__requestBase is { } __LanguageBaseValue ? __LanguageBaseValue.Language : default); + var languages = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.Languages) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.Languages) : (__requestBase is { } __LanguagesBaseValue ? __LanguagesBaseValue.Languages : default); + var keywords = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.Keywords) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.Keywords) : (__requestBase is { } __KeywordsBaseValue ? __KeywordsBaseValue.Keywords : default); + var prompt = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.Prompt) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.Prompt) : (__requestBase is { } __PromptBaseValue ? __PromptBaseValue.Prompt : default); + var responseFormat = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.ResponseFormat) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default); + var temperature = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.Temperature) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.Temperature) : (__requestBase is { } __TemperatureBaseValue ? __TemperatureBaseValue.Temperature : default); + var include = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.Include) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.Include) : (__requestBase is { } __IncludeBaseValue ? __IncludeBaseValue.Include : default); + var timestampGranularities = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.TimestampGranularities) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.TimestampGranularities) : (__requestBase is { } __TimestampGranularitiesBaseValue ? __TimestampGranularitiesBaseValue.TimestampGranularities : default); + var knownSpeakerNames = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.KnownSpeakerNames) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.KnownSpeakerNames) : (__requestBase is { } __KnownSpeakerNamesBaseValue ? __KnownSpeakerNamesBaseValue.KnownSpeakerNames : default); + var knownSpeakerReferences = CliRuntime.WasSpecified(parseResult, CreateTranscriptionRequestOptionSetOptions.KnownSpeakerReferences) ? parseResult.GetValue(CreateTranscriptionRequestOptionSetOptions.KnownSpeakerReferences) : (__requestBase is { } __KnownSpeakerReferencesBaseValue ? __KnownSpeakerReferencesBaseValue.KnownSpeakerReferences : default); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Audio.CreateTranscriptionAsTextAsync( + file: file, + model: model, + chunkingStrategy: chunkingStrategy, + filename: filename, + language: language, + languages: languages, + keywords: keywords, + prompt: prompt, + responseFormat: responseFormat, + temperature: temperature, + include: include, + timestampGranularities: timestampGranularities, + knownSpeakerNames: knownSpeakerNames, + knownSpeakerReferences: knownSpeakerReferences, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::tryAGI.OpenAI.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + return command; + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionCommandApiCommand.g.cs index 775515811..3a06ed6f3 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionCommandApiCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranscriptionCommandApiCommand.g.cs @@ -73,7 +73,8 @@ public static Command Create() Transcribes audio into the input language. Returns a transcription object in `json`, `diarized_json`, or `verbose_json` -format, or a stream of transcript events. +format, plain text in `text`, `srt`, or `vtt` format, or a stream of +transcript events. Supported formats depend on the model. "); command.Options.Add(File); command.Options.Add(Model); diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationAsTextCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationAsTextCommandApiCommand.g.cs new file mode 100644 index 000000000..2ecfcfd34 --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationAsTextCommandApiCommand.g.cs @@ -0,0 +1,124 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal static partial class AudioCreateTranslationAsTextCommandApiCommand +{ + private static Option File { get; } = new( + name: @"--file") + { + Description = @"The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. +", + Required = true, + }; + + private static Option> Model { get; } = new( + name: @"--model") + { + Description = @"ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. +", + Required = true, + }; + private static readonly CreateTranslationRequestOptionSet CreateTranslationRequestOptionSetOptions = CreateTranslationRequestOptionSet.Create(); + private static Option Input { get; } = new(@"--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, + }; + + 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-translation-as-text", @"Create translation +Translates audio into English."); + command.Options.Add(File); + command.Options.Add(Model); command.Options.Add(CreateTranslationRequestOptionSetOptions.Filename); + command.Options.Add(CreateTranslationRequestOptionSetOptions.Prompt); + command.Options.Add(CreateTranslationRequestOptionSetOptions.ResponseFormat); + command.Options.Add(CreateTranslationRequestOptionSetOptions.Temperature); + command.Options.Add(Input); + command.Options.Add(RequestJson); + command.Options.Add(RequestFile); + command.Validators.Add(result => + { + var hasInput = result.GetResult(Input) 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 --input, --request-json, or --request-file."); + } + }); + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync( + parseResult, + Input, + RequestJson, + RequestFile, + global::tryAGI.OpenAI.SourceGenerationContext.Default, + cancellationToken).ConfigureAwait(false); + var file = parseResult.GetRequiredValue(File); + var model = parseResult.GetRequiredValue(Model); var filename = parseResult.GetRequiredValue(CreateTranslationRequestOptionSetOptions.Filename); + var prompt = CliRuntime.WasSpecified(parseResult, CreateTranslationRequestOptionSetOptions.Prompt) ? parseResult.GetValue(CreateTranslationRequestOptionSetOptions.Prompt) : (__requestBase is { } __PromptBaseValue ? __PromptBaseValue.Prompt : default); + var responseFormat = CliRuntime.WasSpecified(parseResult, CreateTranslationRequestOptionSetOptions.ResponseFormat) ? parseResult.GetValue(CreateTranslationRequestOptionSetOptions.ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default); + var temperature = CliRuntime.WasSpecified(parseResult, CreateTranslationRequestOptionSetOptions.Temperature) ? parseResult.GetValue(CreateTranslationRequestOptionSetOptions.Temperature) : (__requestBase is { } __TemperatureBaseValue ? __TemperatureBaseValue.Temperature : default); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Audio.CreateTranslationAsTextAsync( + file: file, + model: model, + filename: filename, + prompt: prompt, + responseFormat: responseFormat, + temperature: temperature, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::tryAGI.OpenAI.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + return command; + } +} \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationCommandApiCommand.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationCommandApiCommand.g.cs index 9c2a91b1b..6c539199d 100644 --- a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationCommandApiCommand.g.cs +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/AudioCreateTranslationCommandApiCommand.g.cs @@ -15,14 +15,6 @@ internal static partial class AudioCreateTranslationCommandApiCommand Required = true, }; - private static Option Filename { get; } = new( - name: @"--filename") - { - Description = @"The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. -", - Required = true, - }; - private static Option> Model { get; } = new( name: @"--model") { @@ -30,27 +22,7 @@ internal static partial class AudioCreateTranslationCommandApiCommand ", Required = true, }; - - private static Option Prompt { get; } = new( - name: @"--prompt") - { - Description = @"An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. -", - }; - - private static Option ResponseFormat { get; } = new( - name: @"--response-format") - { - Description = @"The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. -", - }; - - private static Option Temperature { get; } = new( - name: @"--temperature") - { - Description = @"The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. -", - }; + private static readonly CreateTranslationRequestOptionSet CreateTranslationRequestOptionSetOptions = CreateTranslationRequestOptionSet.Create(); private static Option Input { get; } = new(@"--input") { Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.", @@ -93,11 +65,10 @@ public static Command Create() var command = new Command(@"create-translation", @"Create translation Translates audio into English."); command.Options.Add(File); - command.Options.Add(Filename); - command.Options.Add(Model); - command.Options.Add(Prompt); - command.Options.Add(ResponseFormat); - command.Options.Add(Temperature); + command.Options.Add(Model); command.Options.Add(CreateTranslationRequestOptionSetOptions.Filename); + command.Options.Add(CreateTranslationRequestOptionSetOptions.Prompt); + command.Options.Add(CreateTranslationRequestOptionSetOptions.ResponseFormat); + command.Options.Add(CreateTranslationRequestOptionSetOptions.Temperature); command.Options.Add(Input); command.Options.Add(RequestJson); command.Options.Add(RequestFile); @@ -124,18 +95,17 @@ await CliRuntime.RunAsync(async () => global::tryAGI.OpenAI.SourceGenerationContext.Default, cancellationToken).ConfigureAwait(false); var file = parseResult.GetRequiredValue(File); - var filename = parseResult.GetRequiredValue(Filename); - var model = parseResult.GetRequiredValue(Model); - var prompt = CliRuntime.WasSpecified(parseResult, Prompt) ? parseResult.GetValue(Prompt) : (__requestBase is { } __PromptBaseValue ? __PromptBaseValue.Prompt : default); - var responseFormat = CliRuntime.WasSpecified(parseResult, ResponseFormat) ? parseResult.GetValue(ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default); - var temperature = CliRuntime.WasSpecified(parseResult, Temperature) ? parseResult.GetValue(Temperature) : (__requestBase is { } __TemperatureBaseValue ? __TemperatureBaseValue.Temperature : default); + var model = parseResult.GetRequiredValue(Model); var filename = parseResult.GetRequiredValue(CreateTranslationRequestOptionSetOptions.Filename); + var prompt = CliRuntime.WasSpecified(parseResult, CreateTranslationRequestOptionSetOptions.Prompt) ? parseResult.GetValue(CreateTranslationRequestOptionSetOptions.Prompt) : (__requestBase is { } __PromptBaseValue ? __PromptBaseValue.Prompt : default); + var responseFormat = CliRuntime.WasSpecified(parseResult, CreateTranslationRequestOptionSetOptions.ResponseFormat) ? parseResult.GetValue(CreateTranslationRequestOptionSetOptions.ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default); + var temperature = CliRuntime.WasSpecified(parseResult, CreateTranslationRequestOptionSetOptions.Temperature) ? parseResult.GetValue(CreateTranslationRequestOptionSetOptions.Temperature) : (__requestBase is { } __TemperatureBaseValue ? __TemperatureBaseValue.Temperature : default); using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); var response = await client.Audio.CreateTranslationAsync( file: file, - filename: filename, model: model, + filename: filename, prompt: prompt, responseFormat: responseFormat, temperature: temperature, diff --git a/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/CreateTranslationRequestOptionSet.g.cs b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/CreateTranslationRequestOptionSet.g.cs new file mode 100644 index 000000000..e4c9b466b --- /dev/null +++ b/src/libs/tryAGI.OpenAI.CLI/GeneratedApi/Commands/CreateTranslationRequestOptionSet.g.cs @@ -0,0 +1,42 @@ +#nullable enable + +using System.CommandLine; + +namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands; + +internal sealed record CreateTranslationRequestOptionSet( + Option Filename, + Option Prompt, + Option ResponseFormat, + Option Temperature) +{ + public static CreateTranslationRequestOptionSet Create(string? prefix = null) + { + var normalizedPrefix = string.IsNullOrWhiteSpace(prefix) + ? string.Empty + : prefix.Trim().Trim('-') + "-"; + return new CreateTranslationRequestOptionSet( + Filename: new Option($"--{normalizedPrefix}filename") + { + Description = @"The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. +", + Required = true, + }, + Prompt: new Option($"--{normalizedPrefix}prompt") + { + Description = @"An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. +", + }, + ResponseFormat: new Option($"--{normalizedPrefix}response-format") + { + Description = @"The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. +", + }, + Temperature: new Option($"--{normalizedPrefix}temperature") + { + Description = @"The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. +", + } + ); + } +} \ 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 47b0eb1a3..f43a179e4 100644 --- a/src/libs/tryAGI.OpenAI/Generated/autosdk.generated-examples.json +++ b/src/libs/tryAGI.OpenAI/Generated/autosdk.generated-examples.json @@ -39,7 +39,7 @@ "Slug": "createspeech", "Description": "Generates audio from the input text.\n\nReturns the audio file content, or a stream of audio events.", "Language": "http", - "Code": "### Create speech\n# @name createSpeech\nPOST {{host}}/audio/speech\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json, application/octet-stream, text/event-stream, text/plain\n\n{\n \u0022model\u0022: \u0022string\u0022,\n \u0022input\u0022: \u0022string\u0022,\n \u0022instructions\u0022: \u0022string\u0022,\n \u0022voice\u0022: \u0022ash\u0022,\n \u0022response_format\u0022: \u0022mp3\u0022,\n \u0022speed\u0022: 1,\n \u0022stream_format\u0022: \u0022audio\u0022\n}\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/octet-stream, text/event-stream\n# 400\n# Description: Invalid speech request, input, output format, or voice.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The voice or speech audio could not be processed.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", + "Code": "### Create speech\n# @name createSpeech\nPOST {{host}}/audio/speech\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json, application/octet-stream, audio/aac, audio/flac, audio/mpeg, audio/opus, audio/pcm, audio/wav, text/event-stream, text/plain\n\n{\n \u0022model\u0022: \u0022string\u0022,\n \u0022input\u0022: \u0022string\u0022,\n \u0022instructions\u0022: \u0022string\u0022,\n \u0022voice\u0022: \u0022ash\u0022,\n \u0022response_format\u0022: \u0022mp3\u0022,\n \u0022speed\u0022: 1,\n \u0022stream_format\u0022: \u0022audio\u0022\n}\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/octet-stream, audio/aac, audio/flac, audio/mpeg, audio/opus, audio/pcm, audio/wav, text/event-stream\n# 400\n# Description: Invalid speech request, input, output format, or voice.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The voice or speech audio could not be processed.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", "Format": "http", "OperationId": "createSpeech", "Setup": null @@ -48,9 +48,9 @@ "Order": 5, "Title": "Create transcription", "Slug": "createtranscription", - "Description": "Transcribes audio into the input language.\n\nReturns a transcription object in \u0060json\u0060, \u0060diarized_json\u0060, or \u0060verbose_json\u0060\nformat, or a stream of transcript events.", + "Description": "Transcribes audio into the input language.\n\nReturns a transcription object in \u0060json\u0060, \u0060diarized_json\u0060, or \u0060verbose_json\u0060\nformat, plain text in \u0060text\u0060, \u0060srt\u0060, or \u0060vtt\u0060 format, or a stream of\ntranscript events. Supported formats depend on the model.", "Language": "http", - "Code": "### Create transcription\n# @name createTranscription\nPOST {{host}}/audio/transcriptions\nAuthorization: Bearer {{token}}\nContent-Type: multipart/form-data; boundary=AutoSDKBoundary\nAccept: application/json, text/event-stream, text/plain\n\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022file\u0022; filename=\u0022file.bin\u0022\nContent-Type: application/octet-stream\n\n\u003C ./file.bin\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022model\u0022\n\ngpt-4o-transcribe\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022language\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022languages\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022keywords\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022prompt\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022response_format\u0022\n\njson\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022temperature\u0022\n\n0\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022include\u0022\n\n[]\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022timestamp_granularities\u0022\n\nword\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022stream\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022chunking_strategy\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022known_speaker_names\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022known_speaker_references\u0022\n\nstring\n--AutoSDKBoundary--\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/json, text/event-stream\n# 400\n# Description: Invalid audio input or request parameters.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 413\n# Description: The audio request exceeds the supported size limit.\n# Content-Type: application/json\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The audio could not be processed.\n# Content-Type: application/json\n# 502\n# Description: The upstream audio service connection failed.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", + "Code": "### Create transcription\n# @name createTranscription\nPOST {{host}}/audio/transcriptions\nAuthorization: Bearer {{token}}\nContent-Type: multipart/form-data; boundary=AutoSDKBoundary\nAccept: application/json, text/event-stream, text/plain\n\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022file\u0022; filename=\u0022file.bin\u0022\nContent-Type: application/octet-stream\n\n\u003C ./file.bin\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022model\u0022\n\ngpt-4o-transcribe\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022language\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022languages\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022keywords\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022prompt\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022response_format\u0022\n\njson\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022temperature\u0022\n\n0\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022include\u0022\n\n[]\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022timestamp_granularities\u0022\n\nword\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022stream\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022chunking_strategy\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022known_speaker_names\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022known_speaker_references\u0022\n\nstring\n--AutoSDKBoundary--\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/json, text/event-stream, text/plain\n# 400\n# Description: Invalid audio input or request parameters.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 413\n# Description: The audio request exceeds the supported size limit.\n# Content-Type: application/json\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The audio could not be processed.\n# Content-Type: application/json\n# 502\n# Description: The upstream audio service connection failed.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", "Format": "http", "OperationId": "createTranscription", "Setup": null @@ -61,7 +61,7 @@ "Slug": "createtranslation", "Description": "Translates audio into English.", "Language": "http", - "Code": "### Create translation\n# @name createTranslation\nPOST {{host}}/audio/translations\nAuthorization: Bearer {{token}}\nContent-Type: multipart/form-data; boundary=AutoSDKBoundary\nAccept: application/json, text/plain\n\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022file\u0022; filename=\u0022file.bin\u0022\nContent-Type: application/octet-stream\n\n\u003C ./file.bin\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022model\u0022\n\nwhisper-1\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022prompt\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022response_format\u0022\n\njson\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022temperature\u0022\n\n0\n--AutoSDKBoundary--\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/json\n# 400\n# Description: Invalid audio input or request parameters.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 413\n# Description: The audio request exceeds the supported size limit.\n# Content-Type: application/json\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The audio could not be processed.\n# Content-Type: application/json\n# 502\n# Description: The upstream audio service connection failed.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", + "Code": "### Create translation\n# @name createTranslation\nPOST {{host}}/audio/translations\nAuthorization: Bearer {{token}}\nContent-Type: multipart/form-data; boundary=AutoSDKBoundary\nAccept: application/json, text/plain\n\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022file\u0022; filename=\u0022file.bin\u0022\nContent-Type: application/octet-stream\n\n\u003C ./file.bin\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022model\u0022\n\nwhisper-1\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022prompt\u0022\n\nstring\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022response_format\u0022\n\njson\n--AutoSDKBoundary\nContent-Disposition: form-data; name=\u0022temperature\u0022\n\n0\n--AutoSDKBoundary--\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/json, text/plain\n# 400\n# Description: Invalid audio input or request parameters.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 413\n# Description: The audio request exceeds the supported size limit.\n# Content-Type: application/json\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The audio could not be processed.\n# Content-Type: application/json\n# 502\n# Description: The upstream audio service connection failed.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", "Format": "http", "OperationId": "createTranslation", "Setup": null @@ -72,7 +72,7 @@ "Slug": "createchatcompletion", "Description": "**Starting a new project?** We recommend trying [Responses](https://developers.openai.com/api/reference/resources/responses)\nto take advantage of the latest OpenAI platform features. Compare\n[Chat Completions with Responses](https://developers.openai.com/api/docs/guides/migrate-to-responses?api-mode=responses).\n\n---\n\nCreates a model response for the given chat conversation. Learn more in the\n[text generation](https://developers.openai.com/api/docs/guides/text), [vision](https://developers.openai.com/api/docs/guides/images-vision),\nand [audio](https://developers.openai.com/api/docs/guides/audio) guides.\n\nParameter support can differ depending on the model used to generate the\nresponse, particularly for newer reasoning models. Parameters that are only\nsupported for reasoning models are noted below. For the current state of\nunsupported parameters in reasoning models,\n[refer to the reasoning guide](https://developers.openai.com/api/docs/guides/reasoning).\n\nReturns a chat completion object, or a streamed sequence of chat completion\nchunk objects if the request is streamed.", "Language": "http", - "Code": "### Create chat completion\n# @name createChatCompletion\nPOST {{host}}/chat/completions\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json, text/event-stream, text/plain\n\n{\n \u0022messages\u0022: [\n {\n \u0022content\u0022: \u0022string\u0022,\n \u0022role\u0022: \u0022developer\u0022,\n \u0022name\u0022: \u0022string\u0022\n }\n ],\n \u0022model\u0022: \u0022gpt-6-astra\u0022,\n \u0022service_tier\u0022: \u0022auto\u0022,\n \u0022modalities\u0022: [\n \u0022text\u0022\n ],\n \u0022verbosity\u0022: \u0022medium\u0022,\n \u0022reasoning_effort\u0022: \u0022medium\u0022,\n \u0022max_completion_tokens\u0022: 0,\n \u0022frequency_penalty\u0022: 0,\n \u0022presence_penalty\u0022: 0,\n \u0022web_search_options\u0022: {\n \u0022user_location\u0022: {\n \u0022type\u0022: \u0022approximate\u0022,\n \u0022approximate\u0022: {}\n },\n \u0022search_context_size\u0022: \u0022medium\u0022\n },\n \u0022top_logprobs\u0022: 0,\n \u0022response_format\u0022: {\n \u0022type\u0022: \u0022text\u0022\n },\n \u0022audio\u0022: {\n \u0022voice\u0022: \u0022ash\u0022,\n \u0022format\u0022: \u0022wav\u0022\n },\n \u0022store\u0022: false,\n \u0022moderation\u0022: {\n \u0022model\u0022: \u0022string\u0022,\n \u0022policy\u0022: {\n \u0022input\u0022: {},\n \u0022output\u0022: {}\n }\n },\n \u0022stream\u0022: false,\n \u0022stop\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n \u0022logit_bias\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n \u0022logprobs\u0022: false,\n \u0022max_tokens\u0022: 0,\n \u0022n\u0022: 1,\n \u0022prediction\u0022: {\n \u0022type\u0022: \u0022content\u0022,\n \u0022content\u0022: \u0022string\u0022\n },\n \u0022seed\u0022: 0,\n \u0022stream_options\u0022: {\n \u0022include_usage\u0022: true,\n \u0022include_obfuscation\u0022: true\n },\n \u0022tools\u0022: [\n {\n \u0022type\u0022: \u0022function\u0022,\n \u0022function\u0022: {}\n }\n ],\n \u0022tool_choice\u0022: \u0022none\u0022,\n \u0022parallel_tool_calls\u0022: true,\n \u0022function_call\u0022: \u0022none\u0022,\n \u0022functions\u0022: [\n {\n \u0022description\u0022: \u0022string\u0022,\n \u0022name\u0022: \u0022string\u0022,\n \u0022parameters\u0022: {}\n }\n ]\n}\n\n## Responses\n# 200\n# Description: OK\n# Content-Type: application/json, text/event-stream\n# 400\n# Description: Invalid chat completion request or incompatible request parameters.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 404\n# Description: The requested model or a referenced resource was not found or is unavailable to this caller.\n# Content-Type: application/json\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The chat completion could not be processed due to an internal error.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", + "Code": "### Create chat completion\n# @name createChatCompletion\nPOST {{host}}/chat/completions\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json, text/event-stream, text/plain\n\n{\n \u0022messages\u0022: [\n {\n \u0022content\u0022: \u0022string\u0022,\n \u0022role\u0022: \u0022developer\u0022,\n \u0022name\u0022: \u0022string\u0022\n }\n ],\n \u0022model\u0022: \u0022gpt-6-astra\u0022,\n \u0022service_tier\u0022: \u0022auto\u0022,\n \u0022modalities\u0022: [\n \u0022text\u0022\n ],\n \u0022verbosity\u0022: \u0022medium\u0022,\n \u0022reasoning_effort\u0022: \u0022medium\u0022,\n \u0022max_completion_tokens\u0022: 0,\n \u0022frequency_penalty\u0022: 0,\n \u0022presence_penalty\u0022: 0,\n \u0022web_search_options\u0022: {\n \u0022user_location\u0022: {\n \u0022type\u0022: \u0022approximate\u0022,\n \u0022approximate\u0022: {}\n },\n \u0022search_context_size\u0022: \u0022medium\u0022\n },\n \u0022top_logprobs\u0022: 0,\n \u0022response_format\u0022: {\n \u0022type\u0022: \u0022text\u0022\n },\n \u0022audio\u0022: {\n \u0022voice\u0022: \u0022ash\u0022,\n \u0022format\u0022: \u0022wav\u0022\n },\n \u0022store\u0022: false,\n \u0022moderation\u0022: {\n \u0022model\u0022: \u0022string\u0022,\n \u0022policy\u0022: {\n \u0022input\u0022: {},\n \u0022output\u0022: {}\n }\n },\n \u0022stream\u0022: false,\n \u0022stop\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n \u0022logit_bias\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n \u0022logprobs\u0022: false,\n \u0022max_tokens\u0022: 0,\n \u0022n\u0022: 1,\n \u0022prediction\u0022: {\n \u0022type\u0022: \u0022content\u0022,\n \u0022content\u0022: \u0022string\u0022\n },\n \u0022seed\u0022: 0,\n \u0022stream_options\u0022: {\n \u0022include_usage\u0022: true,\n \u0022include_obfuscation\u0022: true\n },\n \u0022tools\u0022: [\n {\n \u0022type\u0022: \u0022function\u0022,\n \u0022function\u0022: {}\n }\n ],\n \u0022tool_choice\u0022: \u0022none\u0022,\n \u0022parallel_tool_calls\u0022: true,\n \u0022function_call\u0022: \u0022none\u0022,\n \u0022functions\u0022: [\n {\n \u0022description\u0022: \u0022string\u0022,\n \u0022name\u0022: \u0022string\u0022,\n \u0022parameters\u0022: {}\n }\n ]\n}\n\n## Responses\n# 200\n# Description: Returns a Chat Completion object for a non-streaming request.\n\nIf \u0060stream\u0060 is \u0060true\u0060, returns server-sent events (\u0060text/event-stream\u0060).\nSuccessful chunk frames contain a JSON Chat Completion chunk matching\n\u0060CreateChatCompletionStreamResponse\u0060. On normal completion, the final\nframe is:\n\n\u0060\u0060\u0060text\ndata: [DONE]\n\n\u0060\u0060\u0060\n\nThe final frame ends with a blank line. \u0060[DONE]\u0060 is literal text, not a\nJSON chunk, and this frame has no \u0060event: done\u0060 field.\n\nIf a failure occurs after streaming has started, a data frame may\ncontain a JSON object with an \u0060error\u0060 field instead of a completion\nchunk. The streaming schema describes successful JSON chunks, not\nerror frames or the completion marker. An interrupted stream may end\nwithout the marker.\n\n# Content-Type: application/json, text/event-stream\n# 400\n# Description: Invalid chat completion request or incompatible request parameters.\n# Content-Type: application/json\n# 401\n# Description: Authentication failed because the API key is missing or revoked, or the client IP is not authorized.\n# Content-Type: application/json, text/plain\n# 403\n# Description: Access to a personal API organization is blocked by the organization policy.\n# Content-Type: text/plain\n# 404\n# Description: The requested model or a referenced resource was not found or is unavailable to this caller.\n# Content-Type: application/json\n# 429\n# Description: The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually.\n# Content-Type: application/json\n# 500\n# Description: The chat completion could not be processed due to an internal error.\n# Content-Type: application/json\n# 503\n# Description: The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay.\n# Content-Type: application/json", "Format": "http", "OperationId": "createChatCompletion", "Setup": null 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 904862ac6..5fa497eaa 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 @@ -45,7 +45,8 @@ partial void ProcessCreateTranscriptionResponseContent( /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. @@ -70,7 +71,8 @@ partial void ProcessCreateTranscriptionResponseContent( /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. @@ -896,7 +898,8 @@ request.Filename is null /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -999,7 +1002,8 @@ request.Filename is null /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -1879,7 +1883,8 @@ request.Filename is null /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
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 b695bf28e..6800b2b87 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 @@ -40,7 +40,8 @@ partial void ProcessCreateTranscriptionAsStreamResponse( /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. @@ -541,7 +542,8 @@ request.Filename is null /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -649,7 +651,8 @@ request.Filename is null /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsText.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsText.g.cs new file mode 100644 index 000000000..e78dab7fc --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsText.g.cs @@ -0,0 +1,2760 @@ + +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial class AudioClient + { + + + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement s_CreateTranscriptionAsTextSecurityRequirement0 = + 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_CreateTranscriptionAsTextSecurityRequirements = + new global::tryAGI.OpenAI.EndPointSecurityRequirement[] + { s_CreateTranscriptionAsTextSecurityRequirement0, + }; + partial void PrepareCreateTranscriptionAsTextArguments( + global::System.Net.Http.HttpClient httpClient, + global::tryAGI.OpenAI.CreateTranscriptionRequest request); + partial void PrepareCreateTranscriptionAsTextRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + global::tryAGI.OpenAI.CreateTranscriptionRequest request); + partial void ProcessCreateTranscriptionAsTextResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessCreateTranscriptionAsTextResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// 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 CreateTranscriptionAsTextAsync( + + global::tryAGI.OpenAI.CreateTranscriptionRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateTranscriptionAsTextAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// 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> CreateTranscriptionAsTextAsResponseAsync( + + global::tryAGI.OpenAI.CreateTranscriptionRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + request = new global::tryAGI.OpenAI.CreateTranscriptionRequest + { + File = request.File, + Filename = request.Filename, + Model = request.Model, + Language = request.Language, + Languages = request.Languages, + Keywords = request.Keywords, + Prompt = request.Prompt, + ResponseFormat = request.ResponseFormat, + Temperature = request.Temperature, + Include = request.Include, + TimestampGranularities = request.TimestampGranularities, + Stream = false, + ChunkingStrategy = request.ChunkingStrategy, + KnownSpeakerNames = request.KnownSpeakerNames, + KnownSpeakerReferences = request.KnownSpeakerReferences, + }; + PrepareArguments( + client: HttpClient); + PrepareCreateTranscriptionAsTextArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateTranscriptionAsTextSecurityRequirements, + operationName: "CreateTranscriptionAsTextAsync"); + + 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: "/audio/transcriptions", + 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/plain"); + + 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(); + var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty), + name: "\"model\""); + + if (request.Language != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), + name: "\"language\""); + + } + if (request.Languages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Languages!, x => x))}]"), + name: "\"languages\""); + + } + if (request.Keywords != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Keywords!, x => x))}]"), + name: "\"keywords\""); + + } + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.ResponseFormat != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); + + } + if (request.Temperature != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"temperature\""); + + } + if (request.Include != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Include!, x => x.ToValueString()))}]"), + name: "\"include\""); + + } + if (request.TimestampGranularities != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities!, x => x.ToValueString()))}]"), + name: "\"timestamp_granularities\""); + + } + if (request.Stream != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"stream\""); + + } + if (request.ChunkingStrategy != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ChunkingStrategy.ToString() ?? string.Empty), + name: "\"chunking_strategy\""); + + } + if (request.KnownSpeakerNames != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerNames!, x => x))}]"), + name: "\"known_speaker_names\""); + + } + if (request.KnownSpeakerReferences != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerReferences!, x => x))}]"), + name: "\"known_speaker_references\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateTranscriptionAsTextRequest( + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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); + ProcessCreateTranscriptionAsTextResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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); + } + // Invalid audio input or request parameters. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Authentication failed because the API key is missing or revoked, or the client IP is not authorized. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + string? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Access to a personal API organization is blocked by the organization policy. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio request exceeds the supported size limit. + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + responseBody: __content_413, + responseObject: __value_413, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio could not be processed. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The upstream audio service connection failed. + if ((int)__response.StatusCode == 502) + { + string? __content_502 = null; + global::System.Exception? __exception_502 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_502 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + else + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_502 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_502 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_502, + responseBody: __content_502, + responseObject: __value_502, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay. + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + responseBody: __content_503, + responseObject: __value_503, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateTranscriptionAsTextResponseContent( + 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: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #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(); + } + } + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.
+ /// Example: gpt-4o-transcribe + /// + /// + /// The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. + /// + /// + /// Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe`. + /// + /// + /// Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe`. + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// + /// Additional information to include in the transcription response.
+ /// `logprobs` will return the log probabilities of the tokens in the
+ /// response to understand the model's confidence in the transcription.
+ /// `logprobs` only works with response_format set to `json` and only with
+ /// the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
+ /// This option is not available for `gpt-4o-transcribe-diarize`.
+ /// Default Value: [segment] + /// + /// + /// + /// Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported. + /// + /// + /// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`. + /// + /// 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 CreateTranscriptionAsTextAsync( + byte[] file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? language = default, + global::System.Collections.Generic.IList? languages = default, + global::System.Collections.Generic.IList? keywords = default, + string? prompt = default, + global::tryAGI.OpenAI.AudioResponseFormat? responseFormat = default, + double? temperature = default, + global::System.Collections.Generic.IList? include = default, + global::System.Collections.Generic.IList? timestampGranularities = default, + global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default, + global::System.Collections.Generic.IList? knownSpeakerNames = default, + global::System.Collections.Generic.IList? knownSpeakerReferences = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::tryAGI.OpenAI.CreateTranscriptionRequest + { + File = file, + Filename = filename, + Model = model, + Language = language, + Languages = languages, + Keywords = keywords, + Prompt = prompt, + ResponseFormat = responseFormat, + Temperature = temperature, + Include = include, + TimestampGranularities = timestampGranularities, + Stream = false, + ChunkingStrategy = chunkingStrategy, + KnownSpeakerNames = knownSpeakerNames, + KnownSpeakerReferences = knownSpeakerReferences, + }; + + return await CreateTranscriptionAsTextAsync( + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.
+ /// Example: gpt-4o-transcribe + /// + /// + /// The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. + /// + /// + /// Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe`. + /// + /// + /// Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe`. + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// + /// Additional information to include in the transcription response.
+ /// `logprobs` will return the log probabilities of the tokens in the
+ /// response to understand the model's confidence in the transcription.
+ /// `logprobs` only works with response_format set to `json` and only with
+ /// the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
+ /// This option is not available for `gpt-4o-transcribe-diarize`.
+ /// Default Value: [segment] + /// + /// + /// + /// Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported. + /// + /// + /// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`. + /// + /// 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 CreateTranscriptionAsTextAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? language = default, + global::System.Collections.Generic.IList? languages = default, + global::System.Collections.Generic.IList? keywords = default, + string? prompt = default, + global::tryAGI.OpenAI.AudioResponseFormat? responseFormat = default, + double? temperature = default, + global::System.Collections.Generic.IList? include = default, + global::System.Collections.Generic.IList? timestampGranularities = default, + global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default, + global::System.Collections.Generic.IList? knownSpeakerNames = default, + global::System.Collections.Generic.IList? knownSpeakerReferences = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::tryAGI.OpenAI.CreateTranscriptionRequest + { + File = global::System.Array.Empty(), + Filename = filename, + Model = model, + Language = language, + Languages = languages, + Keywords = keywords, + Prompt = prompt, + ResponseFormat = responseFormat, + Temperature = temperature, + Include = include, + TimestampGranularities = timestampGranularities, + Stream = false, + ChunkingStrategy = chunkingStrategy, + KnownSpeakerNames = knownSpeakerNames, + KnownSpeakerReferences = knownSpeakerReferences, + }; + PrepareArguments( + client: HttpClient); + PrepareCreateTranscriptionAsTextArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateTranscriptionAsTextSecurityRequirements, + operationName: "CreateTranscriptionAsTextAsync"); + + 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: "/audio/transcriptions", + 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/plain"); + + 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(); + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty), + name: "\"model\""); + + if (request.Language != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), + name: "\"language\""); + + } + if (request.Languages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Languages!, x => x))}]"), + name: "\"languages\""); + + } + if (request.Keywords != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Keywords!, x => x))}]"), + name: "\"keywords\""); + + } + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.ResponseFormat != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); + + } + if (request.Temperature != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"temperature\""); + + } + if (request.Include != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Include!, x => x.ToValueString()))}]"), + name: "\"include\""); + + } + if (request.TimestampGranularities != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities!, x => x.ToValueString()))}]"), + name: "\"timestamp_granularities\""); + + } + if (request.Stream != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"stream\""); + + } + if (request.ChunkingStrategy != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ChunkingStrategy.ToString() ?? string.Empty), + name: "\"chunking_strategy\""); + + } + if (request.KnownSpeakerNames != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerNames!, x => x))}]"), + name: "\"known_speaker_names\""); + + } + if (request.KnownSpeakerReferences != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerReferences!, x => x))}]"), + name: "\"known_speaker_references\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateTranscriptionAsTextRequest( + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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); + ProcessCreateTranscriptionAsTextResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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); + } + // Invalid audio input or request parameters. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Authentication failed because the API key is missing or revoked, or the client IP is not authorized. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + string? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Access to a personal API organization is blocked by the organization policy. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio request exceeds the supported size limit. + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + responseBody: __content_413, + responseObject: __value_413, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio could not be processed. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The upstream audio service connection failed. + if ((int)__response.StatusCode == 502) + { + string? __content_502 = null; + global::System.Exception? __exception_502 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_502 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + else + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_502 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_502 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_502, + responseBody: __content_502, + responseObject: __value_502, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay. + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + responseBody: __content_503, + responseObject: __value_503, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateTranscriptionAsTextResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + 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)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __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(); + } + } + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.
+ /// Example: gpt-4o-transcribe + /// + /// + /// The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. + /// + /// + /// Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe`. + /// + /// + /// Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe`. + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// + /// Additional information to include in the transcription response.
+ /// `logprobs` will return the log probabilities of the tokens in the
+ /// response to understand the model's confidence in the transcription.
+ /// `logprobs` only works with response_format set to `json` and only with
+ /// the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
+ /// This option is not available for `gpt-4o-transcribe-diarize`.
+ /// Default Value: [segment] + /// + /// + /// + /// Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported. + /// + /// + /// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`. + /// + /// 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> CreateTranscriptionAsTextAsResponseAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? language = default, + global::System.Collections.Generic.IList? languages = default, + global::System.Collections.Generic.IList? keywords = default, + string? prompt = default, + global::tryAGI.OpenAI.AudioResponseFormat? responseFormat = default, + double? temperature = default, + global::System.Collections.Generic.IList? include = default, + global::System.Collections.Generic.IList? timestampGranularities = default, + global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default, + global::System.Collections.Generic.IList? knownSpeakerNames = default, + global::System.Collections.Generic.IList? knownSpeakerReferences = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::tryAGI.OpenAI.CreateTranscriptionRequest + { + File = global::System.Array.Empty(), + Filename = filename, + Model = model, + Language = language, + Languages = languages, + Keywords = keywords, + Prompt = prompt, + ResponseFormat = responseFormat, + Temperature = temperature, + Include = include, + TimestampGranularities = timestampGranularities, + Stream = false, + ChunkingStrategy = chunkingStrategy, + KnownSpeakerNames = knownSpeakerNames, + KnownSpeakerReferences = knownSpeakerReferences, + }; + PrepareArguments( + client: HttpClient); + PrepareCreateTranscriptionAsTextArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateTranscriptionAsTextSecurityRequirements, + operationName: "CreateTranscriptionAsTextAsync"); + + 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: "/audio/transcriptions", + 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/plain"); + + 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(); + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty), + name: "\"model\""); + + if (request.Language != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), + name: "\"language\""); + + } + if (request.Languages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Languages!, x => x))}]"), + name: "\"languages\""); + + } + if (request.Keywords != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Keywords!, x => x))}]"), + name: "\"keywords\""); + + } + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.ResponseFormat != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); + + } + if (request.Temperature != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"temperature\""); + + } + if (request.Include != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Include!, x => x.ToValueString()))}]"), + name: "\"include\""); + + } + if (request.TimestampGranularities != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities!, x => x.ToValueString()))}]"), + name: "\"timestamp_granularities\""); + + } + if (request.Stream != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"stream\""); + + } + if (request.ChunkingStrategy != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ChunkingStrategy.ToString() ?? string.Empty), + name: "\"chunking_strategy\""); + + } + if (request.KnownSpeakerNames != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerNames!, x => x))}]"), + name: "\"known_speaker_names\""); + + } + if (request.KnownSpeakerReferences != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerReferences!, x => x))}]"), + name: "\"known_speaker_references\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateTranscriptionAsTextRequest( + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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); + ProcessCreateTranscriptionAsTextResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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: "CreateTranscriptionAsText", + methodName: "CreateTranscriptionAsTextAsync", + pathTemplate: "\"/audio/transcriptions\"", + 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); + } + // Invalid audio input or request parameters. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Authentication failed because the API key is missing or revoked, or the client IP is not authorized. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + string? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Access to a personal API organization is blocked by the organization policy. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio request exceeds the supported size limit. + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + responseBody: __content_413, + responseObject: __value_413, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio could not be processed. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The upstream audio service connection failed. + if ((int)__response.StatusCode == 502) + { + string? __content_502 = null; + global::System.Exception? __exception_502 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_502 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + else + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_502 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_502 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_502, + responseBody: __content_502, + responseObject: __value_502, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay. + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + responseBody: __content_503, + responseObject: __value_503, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateTranscriptionAsTextResponseContent( + 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: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #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.AudioClient.CreateTranslation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslation.g.cs index 6b32d8cf1..786a1414f 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslation.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslation.g.cs @@ -125,6 +125,10 @@ partial void ProcessCreateTranslationResponseContent( __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/json"); + foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || @@ -942,6 +946,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" || @@ -1697,6 +1705,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.CreateTranslationAsText.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslationAsText.g.cs new file mode 100644 index 000000000..cd0b5cc1b --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslationAsText.g.cs @@ -0,0 +1,2370 @@ + +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial class AudioClient + { + + + private static readonly global::tryAGI.OpenAI.EndPointSecurityRequirement s_CreateTranslationAsTextSecurityRequirement0 = + 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_CreateTranslationAsTextSecurityRequirements = + new global::tryAGI.OpenAI.EndPointSecurityRequirement[] + { s_CreateTranslationAsTextSecurityRequirement0, + }; + partial void PrepareCreateTranslationAsTextArguments( + global::System.Net.Http.HttpClient httpClient, + global::tryAGI.OpenAI.CreateTranslationRequest request); + partial void PrepareCreateTranslationAsTextRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + global::tryAGI.OpenAI.CreateTranslationRequest request); + partial void ProcessCreateTranslationAsTextResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessCreateTranslationAsTextResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// 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 CreateTranslationAsTextAsync( + + global::tryAGI.OpenAI.CreateTranslationRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateTranslationAsTextAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// 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> CreateTranslationAsTextAsResponseAsync( + + global::tryAGI.OpenAI.CreateTranslationRequest 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); + PrepareCreateTranslationAsTextArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateTranslationAsTextSecurityRequirements, + operationName: "CreateTranslationAsTextAsync"); + + 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: "/audio/translations", + 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/plain"); + + 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(); + var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty), + name: "\"model\""); + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.ResponseFormat != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); + + } + if (request.Temperature != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"temperature\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateTranslationAsTextRequest( + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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); + ProcessCreateTranslationAsTextResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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); + } + // Invalid audio input or request parameters. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Authentication failed because the API key is missing or revoked, or the client IP is not authorized. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + string? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Access to a personal API organization is blocked by the organization policy. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio request exceeds the supported size limit. + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + responseBody: __content_413, + responseObject: __value_413, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio could not be processed. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The upstream audio service connection failed. + if ((int)__response.StatusCode == 502) + { + string? __content_502 = null; + global::System.Exception? __exception_502 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_502 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + else + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_502 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_502 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_502, + responseBody: __content_502, + responseObject: __value_502, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay. + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + responseBody: __content_503, + responseObject: __value_503, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateTranslationAsTextResponseContent( + 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: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #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(); + } + } + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
+ /// Example: whisper-1 + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// 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 CreateTranslationAsTextAsync( + byte[] file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? prompt = default, + global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default, + double? temperature = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::tryAGI.OpenAI.CreateTranslationRequest + { + File = file, + Filename = filename, + Model = model, + Prompt = prompt, + ResponseFormat = responseFormat, + Temperature = temperature, + }; + + return await CreateTranslationAsTextAsync( + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
+ /// Example: whisper-1 + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// 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 CreateTranslationAsTextAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? prompt = default, + global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default, + double? temperature = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::tryAGI.OpenAI.CreateTranslationRequest + { + File = global::System.Array.Empty(), + Filename = filename, + Model = model, + Prompt = prompt, + ResponseFormat = responseFormat, + Temperature = temperature, + }; + PrepareArguments( + client: HttpClient); + PrepareCreateTranslationAsTextArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateTranslationAsTextSecurityRequirements, + operationName: "CreateTranslationAsTextAsync"); + + 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: "/audio/translations", + 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/plain"); + + 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(); + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty), + name: "\"model\""); + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.ResponseFormat != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); + + } + if (request.Temperature != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"temperature\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateTranslationAsTextRequest( + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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); + ProcessCreateTranslationAsTextResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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); + } + // Invalid audio input or request parameters. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Authentication failed because the API key is missing or revoked, or the client IP is not authorized. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + string? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Access to a personal API organization is blocked by the organization policy. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio request exceeds the supported size limit. + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + responseBody: __content_413, + responseObject: __value_413, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio could not be processed. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The upstream audio service connection failed. + if ((int)__response.StatusCode == 502) + { + string? __content_502 = null; + global::System.Exception? __exception_502 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_502 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + else + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_502 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_502 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_502, + responseBody: __content_502, + responseObject: __value_502, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay. + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + responseBody: __content_503, + responseObject: __value_503, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateTranslationAsTextResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + 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)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __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(); + } + } + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
+ /// Example: whisper-1 + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// 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> CreateTranslationAsTextAsResponseAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? prompt = default, + global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default, + double? temperature = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::tryAGI.OpenAI.CreateTranslationRequest + { + File = global::System.Array.Empty(), + Filename = filename, + Model = model, + Prompt = prompt, + ResponseFormat = responseFormat, + Temperature = temperature, + }; + PrepareArguments( + client: HttpClient); + PrepareCreateTranslationAsTextArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::tryAGI.OpenAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateTranslationAsTextSecurityRequirements, + operationName: "CreateTranslationAsTextAsync"); + + 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: "/audio/translations", + 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/plain"); + + 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(); + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty), + name: "\"model\""); + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.ResponseFormat != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); + + } + if (request.Temperature != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"temperature\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateTranslationAsTextRequest( + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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); + ProcessCreateTranslationAsTextResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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: "CreateTranslationAsText", + methodName: "CreateTranslationAsTextAsync", + pathTemplate: "\"/audio/translations\"", + 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); + } + // Invalid audio input or request parameters. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Authentication failed because the API key is missing or revoked, or the client IP is not authorized. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + string? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Access to a personal API organization is blocked by the organization policy. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio request exceeds the supported size limit. + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + responseBody: __content_413, + responseObject: __value_413, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The request was rejected because a rate limit was exceeded. A slow_down error means traffic increased too quickly; reduce your request rate, then increase it gradually. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The audio could not be processed. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The upstream audio service connection failed. + if ((int)__response.StatusCode == 502) + { + string? __content_502 = null; + global::System.Exception? __exception_502 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_502 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + else + { + __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_502 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_502, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_502 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_502 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_502, + responseBody: __content_502, + responseObject: __value_502, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // The service is temporarily unavailable. A server_is_overloaded error means the requested model is temporarily overloaded; retry after a brief delay. + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::tryAGI.OpenAI.ErrorResponse? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::tryAGI.OpenAI.ErrorResponse.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + + throw global::tryAGI.OpenAI.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + responseBody: __content_503, + responseObject: __value_503, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateTranslationAsTextResponseContent( + 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: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #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.IAudioClient.CreateTranscription.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscription.g.cs index 8ce6807df..3ad06489c 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscription.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscription.g.cs @@ -8,7 +8,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. @@ -23,7 +24,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. @@ -38,7 +40,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -116,7 +119,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -193,7 +197,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs index e1105ab7a..6824b2551 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs @@ -8,7 +8,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. @@ -23,7 +24,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -101,7 +103,8 @@ public partial interface IAudioClient /// Create transcription
/// Transcribes audio into the input language.
/// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
- /// format, or a stream of transcript events. + /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. /// /// /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsText.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsText.g.cs new file mode 100644 index 000000000..c1ebed164 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsText.g.cs @@ -0,0 +1,275 @@ +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial interface IAudioClient + { + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// 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 CreateTranscriptionAsTextAsync( + + global::tryAGI.OpenAI.CreateTranscriptionRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// 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> CreateTranscriptionAsTextAsResponseAsync( + + global::tryAGI.OpenAI.CreateTranscriptionRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.
+ /// Example: gpt-4o-transcribe + /// + /// + /// The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. + /// + /// + /// Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe`. + /// + /// + /// Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe`. + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// + /// Additional information to include in the transcription response.
+ /// `logprobs` will return the log probabilities of the tokens in the
+ /// response to understand the model's confidence in the transcription.
+ /// `logprobs` only works with response_format set to `json` and only with
+ /// the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
+ /// This option is not available for `gpt-4o-transcribe-diarize`.
+ /// Default Value: [segment] + /// + /// + /// + /// Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported. + /// + /// + /// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`. + /// + /// 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 CreateTranscriptionAsTextAsync( + byte[] file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? language = default, + global::System.Collections.Generic.IList? languages = default, + global::System.Collections.Generic.IList? keywords = default, + string? prompt = default, + global::tryAGI.OpenAI.AudioResponseFormat? responseFormat = default, + double? temperature = default, + global::System.Collections.Generic.IList? include = default, + global::System.Collections.Generic.IList? timestampGranularities = default, + global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default, + global::System.Collections.Generic.IList? knownSpeakerNames = default, + global::System.Collections.Generic.IList? knownSpeakerReferences = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.
+ /// Example: gpt-4o-transcribe + /// + /// + /// The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. + /// + /// + /// Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe`. + /// + /// + /// Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe`. + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// + /// Additional information to include in the transcription response.
+ /// `logprobs` will return the log probabilities of the tokens in the
+ /// response to understand the model's confidence in the transcription.
+ /// `logprobs` only works with response_format set to `json` and only with
+ /// the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
+ /// This option is not available for `gpt-4o-transcribe-diarize`.
+ /// Default Value: [segment] + /// + /// + /// + /// Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported. + /// + /// + /// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`. + /// + /// 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 CreateTranscriptionAsTextAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? language = default, + global::System.Collections.Generic.IList? languages = default, + global::System.Collections.Generic.IList? keywords = default, + string? prompt = default, + global::tryAGI.OpenAI.AudioResponseFormat? responseFormat = default, + double? temperature = default, + global::System.Collections.Generic.IList? include = default, + global::System.Collections.Generic.IList? timestampGranularities = default, + global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default, + global::System.Collections.Generic.IList? knownSpeakerNames = default, + global::System.Collections.Generic.IList? knownSpeakerReferences = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create transcription
+ /// Transcribes audio into the input language.
+ /// Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ /// format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ /// transcript events. Supported formats depend on the model. + ///
+ /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
+ /// The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.
+ /// Example: gpt-4o-transcribe + /// + /// + /// The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. + /// + /// + /// Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe`. + /// + /// + /// Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe`. + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// + /// Additional information to include in the transcription response.
+ /// `logprobs` will return the log probabilities of the tokens in the
+ /// response to understand the model's confidence in the transcription.
+ /// `logprobs` only works with response_format set to `json` and only with
+ /// the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`. + /// + /// + /// The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
+ /// This option is not available for `gpt-4o-transcribe-diarize`.
+ /// Default Value: [segment] + /// + /// + /// + /// Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported. + /// + /// + /// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`. + /// + /// 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> CreateTranscriptionAsTextAsResponseAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? language = default, + global::System.Collections.Generic.IList? languages = default, + global::System.Collections.Generic.IList? keywords = default, + string? prompt = default, + global::tryAGI.OpenAI.AudioResponseFormat? responseFormat = default, + double? temperature = default, + global::System.Collections.Generic.IList? include = default, + global::System.Collections.Generic.IList? timestampGranularities = default, + global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default, + global::System.Collections.Generic.IList? knownSpeakerNames = default, + global::System.Collections.Generic.IList? knownSpeakerReferences = 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.IAudioClient.CreateTranslationAsText.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranslationAsText.g.cs new file mode 100644 index 000000000..fa63acda5 --- /dev/null +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranslationAsText.g.cs @@ -0,0 +1,146 @@ +#nullable enable + +namespace tryAGI.OpenAI +{ + public partial interface IAudioClient + { + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// 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 CreateTranslationAsTextAsync( + + global::tryAGI.OpenAI.CreateTranslationRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// 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> CreateTranslationAsTextAsResponseAsync( + + global::tryAGI.OpenAI.CreateTranslationRequest request, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
+ /// Example: whisper-1 + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// 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 CreateTranslationAsTextAsync( + byte[] file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? prompt = default, + global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default, + double? temperature = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
+ /// Example: whisper-1 + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// 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 CreateTranslationAsTextAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? prompt = default, + global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default, + double? temperature = default, + global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create translation
+ /// Translates audio into English. + ///
+ /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type. + /// + /// + /// ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
+ /// Example: whisper-1 + /// + /// + /// An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English. + /// + /// + /// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
+ /// Default Value: json + /// + /// + /// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
+ /// Default Value: 0 + /// + /// 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> CreateTranslationAsTextAsResponseAsync( + global::System.IO.Stream file, + string filename, + global::tryAGI.OpenAI.AnyOf model, + string? prompt = default, + global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default, + double? temperature = 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/openapi.yaml b/src/libs/tryAGI.OpenAI/openapi.yaml index cc68672f4..c9ec668de 100644 --- a/src/libs/tryAGI.OpenAI/openapi.yaml +++ b/src/libs/tryAGI.OpenAI/openapi.yaml @@ -638,6 +638,30 @@ paths: schema: type: string format: binary + audio/mpeg: + schema: + type: string + format: binary + audio/aac: + schema: + type: string + format: binary + audio/opus: + schema: + type: string + format: binary + audio/flac: + schema: + type: string + format: binary + audio/pcm: + schema: + type: string + format: binary + audio/wav: + schema: + type: string + format: binary text/event-stream: schema: $ref: "#/components/schemas/CreateSpeechResponseStreamEvent" @@ -773,7 +797,9 @@ paths: Returns a transcription object in `json`, `diarized_json`, or `verbose_json` - format, or a stream of transcript events. + format, plain text in `text`, `srt`, or `vtt` format, or a stream of + + transcript events. Supported formats depend on the model. requestBody: required: true content: @@ -790,6 +816,9 @@ paths: - $ref: "#/components/schemas/CreateTranscriptionResponseJson" - $ref: "#/components/schemas/CreateTranscriptionResponseDiarizedJson" - $ref: "#/components/schemas/CreateTranscriptionResponseVerboseJson" + text/plain: + schema: + type: string text/event-stream: schema: $ref: "#/components/schemas/CreateTranscriptionResponseStreamEvent" @@ -1436,6 +1465,9 @@ paths: oneOf: - $ref: "#/components/schemas/CreateTranslationResponseJson" - $ref: "#/components/schemas/CreateTranslationResponseVerboseJson" + text/plain: + schema: + type: string "400": description: Invalid audio input or request parameters. content: @@ -2412,7 +2444,45 @@ paths: $ref: "#/components/schemas/CreateChatCompletionRequest" responses: "200": - description: OK + description: > + Returns a Chat Completion object for a non-streaming request. + + + If `stream` is `true`, returns server-sent events + (`text/event-stream`). + + Successful chunk frames contain a JSON Chat Completion chunk + matching + + `CreateChatCompletionStreamResponse`. On normal completion, the + final + + frame is: + + + ```text + + data: [DONE] + + + ``` + + + The final frame ends with a blank line. `[DONE]` is literal text, + not a + + JSON chunk, and this frame has no `event: done` field. + + + If a failure occurs after streaming has started, a data frame may + + contain a JSON object with an `error` field instead of a completion + + chunk. The streaming schema describes successful JSON chunks, not + + error frames or the completion marker. An interrupted stream may end + + without the marker. content: application/json: schema: @@ -34818,6 +34888,7 @@ paths: application/json: schema: $ref: "#/components/schemas/RotateVaultCredentialParams" + required: true responses: "200": description: The updated vault credential without secret values. @@ -94088,6 +94159,9 @@ components: additionalProperties: false description: Metadata, secret, expiry, and OAuth refresh scope updates for an existing vault credential. Supply at least one of `auth` or `metadata`. + minProperties: 1 + examples: + - metadata: {} DeletedVaultCredentialResource: type: object properties: