Search Results for

    Show / Hide Table of Contents

    Class RealtimeSession

    A session refers to a single WebSocket connection between a client and the server.

    Once a client creates a session, it then sends JSON-formatted events containing text and audio chunks. The server will respond in kind with audio containing voice output, a text transcript of that voice output, and function calls (if functions are provided by the client).

    A realtime Session represents the overall client-server interaction, and contains default configuration.

    It has a set of default values which can be updated at any time (via session.update) or on a per-response level (via response.create).

    Inheritance
    object
    RealtimeSession
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Glitch9.AIDevKit.OpenAI.Realtime
    Assembly: Glitch9.AIDevKit.Provider.OpenAI.dll
    Syntax
    public class RealtimeSession

    Properties

    | Edit this page View Source

    AudioConfig

    Configuration for input and output audio.

    Declaration
    [JsonProperty("audio")]
    public AudioConfig AudioConfig { get; set; }
    Property Value
    Type Description
    AudioConfig
    | Edit this page View Source

    Id

    The unique ID of the session.

    Declaration
    [JsonProperty("id")]
    public string Id { get; set; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Include

    Optional. Additional fields to include in server outputs.

      Declaration
      [JsonProperty("include")]
      public List<string> Include { get; set; }
      Property Value
      Type Description
      List<string>
      | Edit this page View Source

      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.

      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.

      Declaration
      [JsonProperty("instructions")]
      public string Instructions { get; set; }
      Property Value
      Type Description
      string
      | Edit this page View Source

      MaxOutputTokens

      Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or inf for the maximum available tokens for a given model.

      Defaults to inf.

      Declaration
      [JsonProperty("max_output_tokens")]
      public int? MaxOutputTokens { get; set; }
      Property Value
      Type Description
      int?
      | Edit this page View Source

      Model

      The default model used for this session.

      Declaration
      [JsonProperty("model")]
      public string Model { get; set; }
      Property Value
      Type Description
      string
      | Edit this page View Source

      OutputModalities

      The set of Modality the model can respond with.

      Declaration
      [JsonConverter(typeof(FlagsToArrayConverter<Modality>))]
      [JsonProperty("output_modalities")]
      public Modality OutputModalities { get; set; }
      Property Value
      Type Description
      Modality
      | Edit this page View Source

      Prompt

      Reference to a prompt template and its variables.

      Learn more: https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts

      Declaration
      [JsonProperty("prompt")]
      public PromptTemplate Prompt { get; set; }
      Property Value
      Type Description
      PromptTemplate
      | Edit this page View Source

      ToolChoice

      Optional. How the model chooses tools. Provide one of the string modes or force a specific function/MCP tool.

      Declaration
      [JsonProperty("tool_choice")]
      public ToolChoice ToolChoice { get; set; }
      Property Value
      Type Description
      ToolChoice
      | Edit this page View Source

      Tools

      Optional. Tools available to the model.

      Declaration
      [JsonProperty("tools")]
      public Tool[] Tools { get; set; }
      Property Value
      Type Description
      Tool[]
      | Edit this page View Source

      Tracing

      Optional. Realtime API can write session traces to the Traces Dashboard. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified.

      auto will create a trace for the session with default values for the workflow name, group id, and metadata.

      Declaration
      [JsonConverter(typeof(StringOrConverter<TracingConfig>))]
      [JsonProperty("tracing")]
      public StringOr<TracingConfig> Tracing { get; set; }
      Property Value
      Type Description
      StringOr<TracingConfig>
      | Edit this page View Source

      Truncation

      Controls how the realtime conversation is truncated prior to model inference. The default is auto.

      Declaration
      [JsonProperty("truncation")]
      public TruncationStrategy Truncation { get; set; }
      Property Value
      Type Description
      TruncationStrategy
      | Edit this page View Source

      Type

      The type of session to create. Always realtime for the Realtime API.

      Declaration
      [JsonProperty("type")]
      public string Type { get; set; }
      Property Value
      Type Description
      string

      Methods

      | Edit this page View Source

      ToString()

      Declaration
      public override string ToString()
      Returns
      Type Description
      string
      Overrides
      object.ToString()

      Extension Methods

      ArrayExtensions.ToArrayOrEmpty<T>(T)
      ArrayExtensions.ToArrayOrNull<T>(T)
      EventExtensions.ToDelta<T>(T, string, int, string, bool)
      EventExtensions.ToDone<T>(T, string, int, string)
      EventExtensions.ToEvent<T>(T)
      EventExtensions.UpcastDelta<T1, T2>(T1, string, int, string, bool)
      FallbackExtensions.IsOr<TParent, TChild>(TParent, TChild)
      ResponseCastingExtensions.GetResult<T>(T)
      SystemExtensions.GetName(object)
      • Edit this page
      • View Source
      In this article
      Back to top AI DevKit Documentation