async_openai/types/realtime/
api.rs

1use serde::{Deserialize, Serialize};
2
3use crate::types::realtime::{RealtimeSessionConfiguration, Session};
4
5/// Request to create a Realtime call.
6#[derive(Debug, Serialize, Clone)]
7pub struct RealtimeCallCreateRequest {
8    /// WebRTC Session Description Protocol (SDP) offer generated by the caller.
9    pub sdp: String,
10    /// Optional session configuration to apply before the realtime session is created.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub session: Option<RealtimeSessionConfiguration>,
13}
14
15/// Response from creating a Realtime call.
16#[derive(Debug, Clone)]
17pub struct RealtimeCallCreateResponse {
18    /// SDP answer produced by OpenAI for the peer connection.
19    pub sdp: String,
20    /// Relative URL containing the call ID for subsequent control requests.
21    /// Location header value.
22    pub location: Option<String>,
23}
24
25/// Request to accept a Realtime call.
26#[derive(Debug, Serialize, Clone)]
27pub struct RealtimeCallAcceptRequest {
28    /// Realtime session configuration to apply before the caller is bridged to the model.
29    pub session: RealtimeSessionConfiguration,
30}
31
32/// Request to refer a Realtime call.
33#[derive(Debug, Serialize, Clone)]
34pub struct RealtimeCallReferRequest {
35    /// URI that should appear in the SIP Refer-To header.
36    /// Supports values like `tel:+14155550123` or `sip:agent@example.com`.
37    pub target_uri: String,
38}
39
40/// Request to reject a Realtime call.
41#[derive(Debug, Serialize, Clone, Default)]
42pub struct RealtimeCallRejectRequest {
43    /// SIP response code to send back to the caller.
44    /// Defaults to `603` (Decline) when omitted.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub status_code: Option<u16>,
47}
48
49/// Request to create a Realtime client secret.
50#[derive(Debug, Serialize, Clone)]
51pub struct RealtimeCreateClientSecretRequest {
52    /// Session configuration to use for the client secret.
53    /// Choose either a realtime session or a transcription session.
54    pub session: Session,
55    /// Configuration for the client secret expiration.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub expires_after: Option<ClientSecretExpiration>,
58}
59
60/// Client secret expiration configuration.
61#[derive(Debug, Serialize, Clone)]
62pub struct ClientSecretExpiration {
63    /// The anchor point for the client secret expiration.
64    /// Only `created_at` is currently supported.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub anchor: Option<String>,
67    /// The number of seconds from the anchor point to the expiration.
68    /// Select a value between `10` and `7200` (2 hours).
69    /// Defaults to 600 seconds (10 minutes) if not specified.
70    pub seconds: u32,
71}
72
73/// Response from creating a Realtime client secret.
74#[derive(Debug, Deserialize, Clone)]
75pub struct RealtimeCreateClientSecretResponse {
76    /// The generated client secret value.
77    pub value: String,
78    /// Expiration timestamp for the client secret, in seconds since epoch.
79    pub expires_at: u64,
80    /// The session configuration for either a realtime or transcription session.
81    pub session: Session,
82}