Expand description
Build Gemini agents in Rust, from one crate.
[dependencies]
gemini-adk = "3"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }Each step below adds one idea to the one before.
Ask. A model from the environment (GEMINI_API_KEY, or Vertex AI via
GOOGLE_GENAI_USE_VERTEXAI and GOOGLE_CLOUD_PROJECT), an agent, a
question:
use gemini_adk::prelude::*;
let agent = AgentBuilder::new("assistant")
.instruction("Answer in one sentence.")
.build(GeminiLlm::from_env()?)?;
println!("{}", agent.ask("What is the Gemini Live API?").await?);Get a typed answer. The type is the schema. Typed answers and tool
argument types derive serde::Deserialize and schemars::JsonSchema, so
add serde = { version = "1", features = ["derive"] } and
schemars = "0.8" to use them.
#[derive(serde::Deserialize, schemars::JsonSchema)]
struct City {
name: String,
country: String,
}
let city: City = agent.ask_as("Which city hosts the Louvre?").await?;Hold a conversation, and stream it.
let mut chat = agent.chat();
chat.send("Hi, I'm Ada.").await?;
let mut reply = chat.send_stream("What's my name?");
while let Some(event) = reply.next().await {
if let RunEvent::TextDelta(text) = event? {
print!("{text}");
}
}Give it a tool. A documented async fn is a tool; the doc comment is
what the model reads:
/// Get the current temperature for a city, in Celsius.
///
/// # Arguments
///
/// * `city` - The city name, e.g. "Paris".
#[tool]
async fn temperature(city: String) -> f64 {
21.5
}
let agent = AgentBuilder::new("weather")
.tool(temperature())
.build(GeminiLlm::from_env()?)?;Test it without a model. testing::MockLlm replies from a script
and records what the agent sent.
From there: live voice sessions (live, Live::builder()), governed
conversations that enforce which tools a step admits (conversation,
flow), and model-free conversation tests (simulation).
One error type. Every SDK error converts into Error, so a function
that compiles a conversation, calls a model and reads a file can return
gemini_adk::Result and use ? throughout.
This crate re-exports gemini-adk-fluent-rs; its
features have the same names here, plus memory, which adds
gemini_adk::memory (contextual memory for Live sessions).
Modules§
- a2a
- A2A — Agent-to-Agent protocol builders.
- agents
- Agent builders, the L1
Agenttrait, and the operator/pattern combinators. - builder
- AgentBuilder — copy-on-write immutable builder for fluent agent construction.
- compose
- Composition modules – S, C, P, M, T, A, E, G.
- conversation
- The conversation compiler (Phase 1 MVP).
- flow
- Governed-conversation flow primitives:
Flow,Step,Guard,FlowMonitor. - flow_
macros - Typed graph macros — compile-time-checked names for flow authoring.
- gemini_
adk_ rs - gemini-adk-rs
- handoff
- Warm handoff — transfer the conversation to a human with its context intact.
- live
Live— Fluent builder for callback-driven Gemini Live sessions.- live_
builders - Sub-builders for the fluent
LiveAPI. - llm
- LLM abstraction: params, requests/responses, and the registry.
- memory
memory - Contextual memory for Live sessions (feature
memory). - motifs
- Conversational motifs — a standard library of high-confidence flow fragments.
- operators
- Operator algebra for agent composition.
- patterns
- Pre-built patterns — common multi-agent workflows.
- policy
- Policy aspects — reusable, cross-cutting governance attached to a whole conversation rather than scattered across stages.
- prelude
- Everything most applications import: the fluent prelude, plus the
facade’s
Error, which every SDK error converts into. - primitives
- The L2 contract — authoring
- simulation
- Model-free conversation simulation.
- spec
SessionSpec— a whole Live session as one serializable JSON document.- state
- Concurrent typed state:
State,PrefixedState,StateKey, prefix scopes. - tasks
- Skill authoring and the shared task runtime.
- telephony
- Telephony — answer the phone with a governed session
- testing
- Testing utilities — a mock model, agent harnesses, contract validation.
- text
- Text-agent runtime and combinators (carved out of the kernel
prelude). - tools
- Tool definitions, dispatch, toolsets, the confirmation flow, and frames.
- voice
- Voice I/O — a talking application in five lines
- wire
- L0 wire-protocol types for raw WebSocket access.
Macros§
- let_
clone - Clone multiple bindings for use in
moveclosures, reducing Arc/clone boilerplate. - voice_
flow - Generate a module of compile-time-checked flow name constants.
Enums§
- Error
- One error type for application code.