Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace tryAGI.OpenAI
public partial interface IRealtimeClient
{
/// <summary>
/// Create realtime session<br/>
/// Create a Realtime session and client secret for either realtime or transcription.
/// Create client secret<br/>
/// Create a Realtime client secret with an associated session configuration.
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
Expand All @@ -16,11 +16,14 @@ public partial interface IRealtimeClient
global::System.Threading.CancellationToken cancellationToken = default);

/// <summary>
/// Create realtime session<br/>
/// Create a Realtime session and client secret for either realtime or transcription.
/// Create client secret<br/>
/// Create a Realtime client secret with an associated session configuration.
/// </summary>
/// <param name="expiresAfter">
/// Configuration for the ephemeral token expiration.
/// Configuration for the client secret expiration. Expiration refers to the time after which<br/>
/// a client secret will no longer be valid for creating sessions. The session itself may<br/>
/// continue after that time once started. A secret can be used to create multiple sessions<br/>
/// until it expires.
/// </param>
/// <param name="session">
/// Session configuration to use for the client secret. Choose either a realtime<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,55 @@ public partial interface IRealtimeClient
/// a usable ephemeral API token that can be used to authenticate browser clients<br/>
/// for the Realtime API.
/// </summary>
/// <param name="audio">
/// Configuration for input and output audio.
/// </param>
/// <param name="clientSecret">
/// Configuration options for the generated client secret.
/// Ephemeral key returned by the API.
/// </param>
/// <param name="inputAudioFormat">
/// The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
/// </param>
/// <param name="include">
/// Additional fields to include in server outputs.<br/>
/// - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
/// <param name="inputAudioTranscription">
/// Configuration for input audio transcription, defaults to off and can be<br/>
/// set to `null` to turn off once on. Input audio transcription is not native<br/>
/// to the model, since the model consumes audio directly. Transcription runs<br/>
/// asynchronously and should be treated as rough guidance<br/>
/// rather than the representation understood by the model.
/// </param>
/// <param name="instructions">
/// The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.<br/>
/// Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.
/// </param>
/// <param name="maxOutputTokens">
/// <param name="maxResponseOutputTokens">
/// Maximum number of output tokens for a single assistant response,<br/>
/// inclusive of tool calls. Provide an integer between 1 and 4096 to<br/>
/// limit output tokens, or `inf` for the maximum available tokens for a<br/>
/// given model. Defaults to `inf`.
/// </param>
/// <param name="model">
/// The Realtime model used for this session.
/// </param>
/// <param name="outputModalities">
/// <param name="modalities">
/// The set of modalities the model can respond with. To disable audio,<br/>
/// set this to ["text"].
/// </param>
/// <param name="outputAudioFormat">
/// The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
/// </param>
/// <param name="prompt">
/// Reference to a prompt template and its variables. <br/>
/// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
/// </param>
/// <param name="speed">
/// The speed of the model's spoken response. 1.0 is the default speed. 0.25 is<br/>
/// the minimum speed. 1.5 is the maximum speed. This value can only be changed<br/>
/// in between model turns, not while a response is in progress.<br/>
/// Default Value: 1
/// </param>
/// <param name="temperature">
/// Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a temperature of 0.8 is highly recommended for best performance.<br/>
/// Default Value: 0.8
/// Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
/// </param>
/// <param name="toolChoice">
/// How the model chooses tools. Provide one of the string modes or force a specific<br/>
/// function/MCP tool.<br/>
/// Default Value: auto
/// How the model chooses tools. Options are `auto`, `none`, `required`, or<br/>
/// specify a function.
/// </param>
/// <param name="tools">
/// Tools available to the model.
/// Tools (functions) available to the model.
/// </param>
/// <param name="tracing">
/// Configuration options for tracing. Set to null to disable tracing. Once<br/>
Expand All @@ -80,29 +87,35 @@ public partial interface IRealtimeClient
/// </param>
/// <param name="truncation">
/// Controls how the realtime conversation is truncated prior to model inference.<br/>
/// The default is `auto`. When set to `retention_ratio`, the server retains a<br/>
/// fraction of the conversation tokens prior to the instructions.
/// The default is `auto`.
/// </param>
/// <param name="turnDetection">
/// Configuration for turn detection. Can be set to `null` to turn off. Server<br/>
/// VAD means that the model will detect the start and end of speech based on<br/>
/// audio volume and respond at the end of user speech.
/// </param>
/// <param name="type">
/// The type of session to create. Always `realtime` for the Realtime API.
/// <param name="voice">
/// Example: ash
/// </param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.RealtimeSessionCreateResponse> CreateRealtimeSessionAsync(
global::tryAGI.OpenAI.AnyOf<string, global::tryAGI.OpenAI.RealtimeSessionCreateRequestModel?> model,
global::tryAGI.OpenAI.RealtimeSessionCreateRequestAudio? audio = default,
global::tryAGI.OpenAI.RealtimeSessionCreateRequestClientSecret? clientSecret = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.RealtimeSessionCreateRequestIncludeItem>? include = default,
global::tryAGI.OpenAI.RealtimeSessionCreateRequestClientSecret clientSecret,
string? inputAudioFormat = default,
global::tryAGI.OpenAI.RealtimeSessionCreateRequestInputAudioTranscription? inputAudioTranscription = default,
string? instructions = default,
global::tryAGI.OpenAI.AnyOf<int?, global::tryAGI.OpenAI.RealtimeSessionCreateRequestMaxOutputTokens?>? maxOutputTokens = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.RealtimeSessionCreateRequestOutputModalitie>? outputModalities = default,
global::tryAGI.OpenAI.AnyOf<int?, global::tryAGI.OpenAI.RealtimeSessionCreateRequestMaxResponseOutputTokens?>? maxResponseOutputTokens = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.RealtimeSessionCreateRequestModalitie>? modalities = default,
string? outputAudioFormat = default,
global::tryAGI.OpenAI.Prompt2? prompt = default,
double? speed = default,
double? temperature = default,
global::tryAGI.OpenAI.AnyOf<global::tryAGI.OpenAI.ToolChoiceOptions?, global::tryAGI.OpenAI.ToolChoiceFunction, global::tryAGI.OpenAI.ToolChoiceMCP>? toolChoice = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.ToolsItem4>? tools = default,
string? toolChoice = default,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.RealtimeSessionCreateRequestTool>? tools = default,
global::tryAGI.OpenAI.AnyOf<global::tryAGI.OpenAI.RealtimeSessionCreateRequestTracingEnum?, global::tryAGI.OpenAI.RealtimeSessionCreateRequestTracingEnum2>? tracing = default,
global::tryAGI.OpenAI.RealtimeTruncation? truncation = default,
global::tryAGI.OpenAI.RealtimeSessionCreateRequestType type = default,
global::tryAGI.OpenAI.RealtimeSessionCreateRequestTurnDetection? turnDetection = default,
global::tryAGI.OpenAI.VoiceIdsShared? voice = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial interface IRealtimeClient
/// </summary>
/// <param name="include">
/// The set of items to include in the transcription. Current available items are:<br/>
/// - `item.input_audio_transcription.logprobs`
/// `item.input_audio_transcription.logprobs`
/// </param>
/// <param name="inputAudioFormat">
/// The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.<br/>
Expand All @@ -44,29 +44,18 @@ public partial interface IRealtimeClient
/// Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.<br/>
/// Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.
/// </param>
/// <param name="inputAudioTranscription">
/// Configuration for input audio transcription. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.
/// </param>
/// <param name="model">
/// ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source Whisper V2 model).<br/>
/// Example: gpt-4o-transcribe
/// </param>
/// <param name="inputAudioTranscription"></param>
/// <param name="turnDetection">
/// Configuration for turn detection. Can be set to `null` to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.
/// </param>
/// <param name="type">
/// The type of session to create. Always `transcription` for transcription sessions.
/// </param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateResponse> CreateRealtimeTranscriptionSessionAsync(
global::tryAGI.OpenAI.AnyOf<string, global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateRequestModel?> model,
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateRequestIncludeItem>? include = default,
global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateRequestInputAudioFormat? inputAudioFormat = default,
global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateRequestInputAudioNoiseReduction? inputAudioNoiseReduction = default,
global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateRequestInputAudioTranscription? inputAudioTranscription = default,
global::tryAGI.OpenAI.AudioTranscription? inputAudioTranscription = default,
global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateRequestTurnDetection? turnDetection = default,
global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateRequestType type = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace tryAGI.OpenAI.JsonConverters
{
/// <inheritdoc />
public sealed class AudioTranscriptionModelJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::tryAGI.OpenAI.AudioTranscriptionModel>
{
/// <inheritdoc />
public override global::tryAGI.OpenAI.AudioTranscriptionModel Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::tryAGI.OpenAI.AudioTranscriptionModelExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::tryAGI.OpenAI.AudioTranscriptionModel)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::tryAGI.OpenAI.AudioTranscriptionModel);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::tryAGI.OpenAI.AudioTranscriptionModel value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::tryAGI.OpenAI.AudioTranscriptionModelExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#nullable enable

namespace tryAGI.OpenAI.JsonConverters
{
/// <inheritdoc />
public sealed class AudioTranscriptionModelNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::tryAGI.OpenAI.AudioTranscriptionModel?>
{
/// <inheritdoc />
public override global::tryAGI.OpenAI.AudioTranscriptionModel? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::tryAGI.OpenAI.AudioTranscriptionModelExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::tryAGI.OpenAI.AudioTranscriptionModel)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::tryAGI.OpenAI.AudioTranscriptionModel?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::tryAGI.OpenAI.AudioTranscriptionModel? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::tryAGI.OpenAI.AudioTranscriptionModelExtensions.ToValueString(value.Value));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace tryAGI.OpenAI.JsonConverters
{
/// <inheritdoc />
public sealed class NoiseReductionTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::tryAGI.OpenAI.NoiseReductionType>
{
/// <inheritdoc />
public override global::tryAGI.OpenAI.NoiseReductionType Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::tryAGI.OpenAI.NoiseReductionTypeExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::tryAGI.OpenAI.NoiseReductionType)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::tryAGI.OpenAI.NoiseReductionType);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::tryAGI.OpenAI.NoiseReductionType value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::tryAGI.OpenAI.NoiseReductionTypeExtensions.ToValueString(value));
}
}
}
Loading
Loading