Class: OpenAI::Resources::Live::Sessions

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/live/sessions.rb,
sig/openai/resources/live/sessions.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Sessions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Sessions.

Parameters:



180
181
182
# File 'lib/openai/resources/live/sessions.rb', line 180

def initialize(client:)
  @client = client
end

Instance Method Details

#accept(session_id, session:, request_options: {}) ⇒ nil

Accept an incoming SIP call. Supply session with type live, the model, and startup configuration. Before accepting calls, follow the Live prompting guide to write frontend conversation instructions and a separate backend prompt. SIP media format is negotiated; omit audio.format.

Parameters:

  • session_id (String)

    Opaque Live session identifier from the creation response or incoming-call webhook. Preserve the returned value unchanged, including its prefix.

  • session (OpenAI::Models::Live::SessionAcceptParams::Session)

    Model and startup configuration for the Live session that answers the incoming SIP call.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/openai/resources/live/sessions.rb', line 28

def accept(session_id, params)
  parsed, options = OpenAI::Live::SessionAcceptParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["live/sessions/%1$s/accept", session_id],
    body: parsed,
    model: NilClass,
    security: {bearer_auth: true},
    options: options
  )
end

#download_recording(session_id, request_options: {}) ⇒ StringIO

Get Live session content

Parameters:

  • session_id (String)

    The ID of the stored Live session to download. Use the session ID returned when the session started with storage enabled.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (StringIO)

See Also:



53
54
55
56
57
58
59
60
61
62
# File 'lib/openai/resources/live/sessions.rb', line 53

def download_recording(session_id, params = {})
  @client.request(
    method: :get,
    path: ["live/sessions/%1$s/content", session_id],
    headers: {"accept" => "application/binary"},
    model: StringIO,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end

#fork(session_id, transport:, session: nil, request_options: {}) ⇒ OpenAI::Models::Live::SessionForkResponse

Fork a stored Live session onto a new WebRTC connection.

Parameters:

Returns:

See Also:



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/openai/resources/live/sessions.rb', line 83

def fork(session_id, params)
  parsed, options = OpenAI::Live::SessionForkParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["live/sessions/%1$s/fork", session_id],
    body: parsed,
    model: OpenAI::Models::Live::SessionForkResponse,
    security: {bearer_auth: true},
    options: options
  )
end

#hangup(session_id, request_options: {}) ⇒ nil

End a SIP call identified by session_id.

Parameters:

  • session_id (String)

    Opaque Live session identifier from the creation response or incoming-call webhook. Preserve the returned value unchanged, including its prefix.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



108
109
110
111
112
113
114
115
116
# File 'lib/openai/resources/live/sessions.rb', line 108

def hangup(session_id, params = {})
  @client.request(
    method: :post,
    path: ["live/sessions/%1$s/hangup", session_id],
    model: NilClass,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end

#refer(session_id, target_uri:, request_options: {}) ⇒ nil

Transfer a SIP call to another destination. Supply a nonblank target_uri for the SIP Refer-To header.

Parameters:

  • session_id (String)

    Opaque Live session identifier from the creation response or incoming-call webhook. Preserve the returned value unchanged, including its prefix.

  • target_uri (String)

    Nonblank URI for the SIP Refer-To header, such as tel:+14155550123 or sip:[email protected].

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/openai/resources/live/sessions.rb', line 136

def refer(session_id, params)
  parsed, options = OpenAI::Live::SessionReferParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["live/sessions/%1$s/refer", session_id],
    body: parsed,
    model: NilClass,
    security: {bearer_auth: true},
    options: options
  )
end

#reject(session_id, status_code:, request_options: {}) ⇒ nil

Reject an incoming SIP call. Send a required SIP rejection status_code between 300 and 699.

Parameters:

  • session_id (String)

    Opaque Live session identifier from the creation response or incoming-call webhook. Preserve the returned value unchanged, including its prefix.

  • status_code (Integer)

    SIP rejection status sent to the caller. This field is required.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/openai/resources/live/sessions.rb', line 165

def reject(session_id, params)
  parsed, options = OpenAI::Live::SessionRejectParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["live/sessions/%1$s/reject", session_id],
    body: parsed,
    model: NilClass,
    security: {bearer_auth: true},
    options: options
  )
end