async-openai 0.34.0

Rust library for OpenAI
Documentation
use serde::{Deserialize, Serialize};

use crate::types::realtime::{RealtimeSessionConfiguration, Session};

/// Request to create a Realtime call.
#[derive(Debug, Serialize, Clone)]
pub struct RealtimeCallCreateRequest {
    /// WebRTC Session Description Protocol (SDP) offer generated by the caller.
    pub sdp: String,
    /// Optional session configuration to apply before the realtime session is created.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub session: Option<RealtimeSessionConfiguration>,
}

/// Response from creating a Realtime call.
#[derive(Debug, Clone)]
pub struct RealtimeCallCreateResponse {
    /// SDP answer produced by OpenAI for the peer connection.
    pub sdp: String,
    /// Relative URL containing the call ID for subsequent control requests.
    /// Location header value.
    pub location: Option<String>,
}

/// Request to accept a Realtime call.
#[derive(Debug, Serialize, Clone)]
pub struct RealtimeCallAcceptRequest {
    /// Realtime session configuration to apply before the caller is bridged to the model.
    pub session: RealtimeSessionConfiguration,
}

/// Request to refer a Realtime call.
#[derive(Debug, Serialize, Clone)]
pub struct RealtimeCallReferRequest {
    /// URI that should appear in the SIP Refer-To header.
    /// Supports values like `tel:+14155550123` or `sip:agent@example.com`.
    pub target_uri: String,
}

/// Request to reject a Realtime call.
#[derive(Debug, Serialize, Clone, Default)]
pub struct RealtimeCallRejectRequest {
    /// SIP response code to send back to the caller.
    /// Defaults to `603` (Decline) when omitted.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status_code: Option<u16>,
}

/// Request to create a Realtime client secret.
#[derive(Debug, Serialize, Clone)]
pub struct RealtimeCreateClientSecretRequest {
    /// Session configuration to use for the client secret.
    /// Choose either a realtime session or a transcription session.
    pub session: Session,
    /// Configuration for the client secret expiration.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expires_after: Option<ClientSecretExpiration>,
}

/// Client secret expiration configuration.
#[derive(Debug, Serialize, Clone)]
pub struct ClientSecretExpiration {
    /// The anchor point for the client secret expiration.
    /// Only `created_at` is currently supported.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub anchor: Option<String>,
    /// The number of seconds from the anchor point to the expiration.
    /// Select a value between `10` and `7200` (2 hours).
    /// Defaults to 600 seconds (10 minutes) if not specified.
    pub seconds: u32,
}

/// Response from creating a Realtime client secret.
#[derive(Debug, Deserialize, Clone)]
pub struct RealtimeCreateClientSecretResponse {
    /// The generated client secret value.
    pub value: String,
    /// Expiration timestamp for the client secret, in seconds since epoch.
    pub expires_at: u64,
    /// The session configuration for either a realtime or transcription session.
    pub session: Session,
}