1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! # adk-realtime
//!
//! Real-time bidirectional audio/video streaming for ADK agents.
//!
//! This crate provides a unified interface for building voice-enabled AI agents
//! using real-time streaming APIs from various providers (OpenAI, Gemini, etc.).
//!
//! ## Architecture
//!
//! `adk-realtime` follows the same pattern as OpenAI's Agents SDK, providing both
//! a low-level session interface and a high-level `RealtimeAgent` that implements
//! the standard ADK `Agent` trait.
//!
//! ```text
//! ┌─────────────────────────────────────────┐
//! │ Agent Trait │
//! │ (name, description, run, sub_agents) │
//! └────────────────┬────────────────────────┘
//! │
//! ┌───────────────────────┼───────────────────────┐
//! │ │ │
//! ┌────────▼────────┐ ┌─────────▼─────────┐ ┌─────────▼─────────┐
//! │ LlmAgent │ │ RealtimeAgent │ │ SequentialAgent │
//! │ (text-based) │ │ (voice-based) │ │ (workflow) │
//! └─────────────────┘ └───────────────────┘ └───────────────────┘
//! ```
//!
//! ## Features
//!
//! - **RealtimeAgent**: Implements `adk_core::Agent` with callbacks, tools, instructions
//! - **Multiple Providers**: OpenAI Realtime API and Gemini Live API support
//! - **Audio Streaming**: Bidirectional audio with various formats (PCM16, G711)
//! - **Voice Activity Detection**: Server-side VAD for natural conversations
//! - **Tool Calling**: Real-time function execution during voice sessions
//!
//! ## Example - Using RealtimeAgent (Recommended)
//!
//! ```rust,ignore
//! use adk_realtime::{RealtimeAgent, openai::OpenAIRealtimeModel};
//! use adk_runner::Runner;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let model = OpenAIRealtimeModel::new(api_key, "gpt-4o-realtime-preview-2024-12-17");
//!
//! let agent = RealtimeAgent::builder("voice_assistant")
//! .model(Arc::new(model))
//! .instruction("You are a helpful voice assistant.")
//! .voice("alloy")
//! .server_vad()
//! .tool(Arc::new(weather_tool))
//! .build()?;
//!
//! // Use with standard ADK runner
//! let runner = Runner::new(Arc::new(agent));
//! runner.run(session, content).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Example - Using Low-Level Session API
//!
//! ```rust,ignore
//! use adk_realtime::{RealtimeModel, RealtimeConfig, ServerEvent};
//! use adk_realtime::openai::OpenAIRealtimeModel;
//!
//! let model = OpenAIRealtimeModel::new(api_key, "gpt-4o-realtime-preview-2024-12-17");
//! let session = model.connect(config).await?;
//!
//! while let Some(event) = session.next_event().await {
//! match event? {
//! ServerEvent::AudioDelta { delta, .. } => { /* play audio */ }
//! ServerEvent::TextDelta { delta, .. } => println!("{}", delta),
//! _ => {}
//! }
//! }
//! ```
// Provider implementations
// Re-exports
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use RealtimeRunner;
pub use ;