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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//! # adk-realtime
//!
//! Real-time bidirectional audio streaming for ADK agents.
//!
//! The crate offers a low-level session API ([`RealtimeModel`], [`RealtimeSession`]), an event
//! loop with tool dispatch ([`RealtimeRunner`]), and [`RealtimeAgent`], which implements
//! `adk_core::Agent` so a voice agent runs under the standard ADK runner.
//!
//! ```text
//! ┌─────────────────────────────────────────┐
//! │ Agent trait │
//! │ (name, description, run, sub_agents) │
//! └────────────────┬────────────────────────┘
//! │
//! ┌───────────────────────┼───────────────────────┐
//! │ │ │
//! ┌────────▼────────┐ ┌─────────▼─────────┐ ┌─────────▼─────────┐
//! │ LlmAgent │ │ RealtimeAgent │ │ SequentialAgent │
//! │ (text-based) │ │ (voice-based) │ │ (workflow) │
//! └─────────────────┘ └───────────────────┘ └───────────────────┘
//! ```
//!
//! ## Providers
//!
//! | Feature | Provider |
//! |---------|----------|
//! | `openai` | OpenAI Realtime API over WebSocket |
//! | `openai-webrtc` | OpenAI Realtime API over WebRTC with Opus |
//! | `telephony` | Provider-neutral phone-call control and governed call tools (the `telephony` module) |
//! | `openai-sip` | OpenAI Realtime SIP: incoming-call webhooks, accept, reject, transfer, hang up |
//! | `gemini` | Gemini Live API |
//! | `vertex-live` | Vertex AI Live API with Application Default Credentials |
//! | `livekit` | LiveKit WebRTC bridge |
//! | `heygen-avatar`, `did-avatar` | Video avatar providers |
//! | `integration` | `IntegratedRealtimeRunner` with sessions, memory, and plugins |
//!
//! | Feature | Enables |
//! |---------|---------|
//! | `livekit-sip` | LiveKit SIP over the server API (`telephony::livekit`): trunks, dispatch rules, verified webhooks, outbound calls, transfer, hang up; implies `telephony` |
//! | `video-avatar` | Avatar configuration and the `AvatarProvider` trait (`avatar`); `heygen-avatar` and `did-avatar` imply it |
//! | `guardrails` | `output_guardrails(GuardrailSet)` on `RealtimeAgentBuilder` and `IntegratedRealtimeRunnerBuilder`: the model's text and transcripts screened by `adk-guardrail` |
//! | `scripted` | `ScriptedRealtimeModel`, a provider-free test double that answers each client action from a script |
//! | `record-payloads` | Bounded raw provider frames in diagnostics; without it they are redacted |
//! | `full` | `openai`, `gemini`, `vertex-live` and `livekit` |
//! | `full-webrtc` | `full` and `openai-webrtc`; needs cmake |
//!
//! No provider is enabled by default. Every tool call goes through
//! `adk_core::authorize_tool_call`: the kill switch, the `ToolPolicy`, and confirmation.
//!
//! ## Example: low-level session
//!
//! ```rust,no_run
//! # #[cfg(feature = "openai")]
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use adk_realtime::openai::OpenAIRealtimeModel;
//! use adk_realtime::{RealtimeConfig, RealtimeModel, ServerEvent};
//!
//! let model = OpenAIRealtimeModel::new(std::env::var("OPENAI_API_KEY")?, "gpt-realtime-2.1");
//! let config = RealtimeConfig::default()
//! .with_instruction("Answer in one sentence.")
//! .with_modalities(vec!["text".to_string()]);
//!
//! let session = model.connect(config).await?;
//! session.send_text("Name one planet.").await?;
//! session.create_response().await?;
//! while let Some(event) = session.next_event().await {
//! match event? {
//! ServerEvent::TextDelta { delta, .. } => print!("{delta}"),
//! ServerEvent::ResponseDone { .. } => break,
//! _ => {}
//! }
//! }
//! # Ok(())
//! # }
//! # #[cfg(not(feature = "openai"))]
//! # fn main() {}
//! ```
//!
//! ## Example: RealtimeAgent
//!
//! ```rust,no_run
//! # #[cfg(feature = "openai")]
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use adk_realtime::RealtimeAgent;
//! use adk_realtime::openai::OpenAIRealtimeModel;
//! use std::sync::Arc;
//!
//! let model = Arc::new(OpenAIRealtimeModel::new("sk-...", "gpt-realtime-2.1"));
//! let agent = RealtimeAgent::builder("voice_assistant")
//! .model(model)
//! .instruction("You are a helpful voice assistant.")
//! .voice("alloy")
//! .server_vad()
//! .build()?;
//! # let _ = agent;
//! # Ok(())
//! # }
//! # #[cfg(not(feature = "openai"))]
//! # fn main() {}
//! ```
// Provider implementations
pub use ;
pub use ;
pub use ;
// Re-exports
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use RealtimeRunner;
pub use ;