openai_agents_rust/model/
openai_realtime.rs

1use crate::config::Config;
2use crate::error::AgentError;
3use crate::model::Model;
4use async_trait::async_trait;
5use reqwest::Client;
6
7/// Experimental real‑time OpenAI model (e.g., audio transcription).
8pub struct OpenAiRealtime {
9    _client: Client,
10    _config: Config,
11}
12
13impl OpenAiRealtime {
14    pub fn new(config: Config) -> Self {
15        let client = Client::builder()
16            .user_agent("openai-agents-rust")
17            .build()
18            .expect("Failed to build reqwest client");
19        Self {
20            _client: client,
21            _config: config,
22        }
23    }
24}
25
26#[async_trait]
27impl Model for OpenAiRealtime {
28    async fn generate(&self, prompt: &str) -> Result<String, AgentError> {
29        // In a real implementation this would call the OpenAI realtime endpoint.
30        // Here we simply echo the prompt for demonstration.
31        Ok(format!("Realtime response to: {}", prompt))
32    }
33}