openai_interface/realtime/
transcription_sessions.rs1use serde::{Deserialize, Serialize};
12use url::Url;
13
14use crate::{
15 errors::OapiError,
16 realtime::RealtimeSession,
17 rest::post::{Post, PostNoStream},
18};
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct CreateTranscriptionSessionRequest {
23 #[serde(skip_serializing_if = "Option::is_none")]
27 pub session: Option<serde_json::Value>,
28 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
31 pub extra_body_map: Option<serde_json::Map<String, serde_json::Value>>,
32}
33
34impl Post for CreateTranscriptionSessionRequest {
35 fn is_streaming(&self) -> bool {
36 false
37 }
38
39 fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
43 let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
44 url.path_segments_mut()
45 .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
46 .push("realtime")
47 .push("transcription_sessions");
48 Ok(url.to_string())
49 }
50}
51
52impl PostNoStream for CreateTranscriptionSessionRequest {
53 type Response = RealtimeSession;
54}