Skip to main content

gproxy_protocol/wire/openai/realtime/
client_secrets.rs

1//! OpenAI Realtime client secrets, current API reference (2026-10-20).
2use crate::{Rest, WireRequest, WireResponse};
3use serde::{Deserialize, Serialize};
4#[derive(
5    Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
6)]
7#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
8#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
9#[serde(untagged)]
10pub enum ClientSecretSession {
11    Realtime(Box<super::RealtimeSessionCreateRequest>),
12    Transcription(Box<super::RealtimeTranscriptionSessionCreateRequest>),
13}
14
15#[derive(
16    Debug,
17    Clone,
18    PartialEq,
19    Serialize,
20    Deserialize,
21    gproxy_protocol_macros::WireBuilder,
22    gproxy_protocol_macros::DeclaredFields,
23)]
24#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
25#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
26pub struct ClientSecretExpiresAfter {
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub anchor: Option<String>,
29    #[serde(default, skip_serializing_if = "Option::is_none")]
30    pub seconds: Option<u64>,
31    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
32    pub rest: Rest,
33}
34
35#[derive(
36    Debug,
37    Clone,
38    PartialEq,
39    Serialize,
40    Deserialize,
41    gproxy_protocol_macros::WireBuilder,
42    gproxy_protocol_macros::DeclaredFields,
43)]
44#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
45#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
46pub struct CreateRealtimeClientSecretRequestBody {
47    #[serde(default, skip_serializing_if = "Option::is_none")]
48    pub expires_after: Option<ClientSecretExpiresAfter>,
49    #[serde(default, skip_serializing_if = "Option::is_none")]
50    pub session: Option<ClientSecretSession>,
51    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
52    pub rest: Rest,
53}
54
55#[derive(
56    Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
57)]
58#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
59#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
60#[serde(untagged)]
61pub enum ClientSecretResponseSession {
62    Realtime(Box<super::RealtimeSessionCreateResponse>),
63    Transcription(Box<super::RealtimeTranscriptionSessionCreateResponse>),
64}
65
66#[derive(
67    Clone,
68    PartialEq,
69    Serialize,
70    Deserialize,
71    gproxy_protocol_macros::WireBuilder,
72    gproxy_protocol_macros::DeclaredFields,
73)]
74#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
75#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
76pub struct CreateRealtimeClientSecretResponseBody {
77    pub value: String,
78    pub expires_at: u64,
79    pub session: ClientSecretResponseSession,
80    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
81    pub rest: Rest,
82}
83
84pub type CreateRealtimeClientSecretRequest = WireRequest<CreateRealtimeClientSecretRequestBody>;
85pub type CreateRealtimeClientSecretResponse = WireResponse<CreateRealtimeClientSecretResponseBody>;
86
87impl std::fmt::Debug for CreateRealtimeClientSecretResponseBody {
88    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
89        f.debug_struct("CreateRealtimeClientSecretResponseBody")
90            .field("value", &"[redacted]")
91            .field("expires_at", &self.expires_at)
92            .finish_non_exhaustive()
93    }
94}