Building a Weather AI Agent with ADK-Rust: A Step-by-Step Tutorial
Learn how to create a simple yet powerful AI Agent in Rust using the ADK-Rust framework and wttr.in to fetch real-time weather reports.
Posted on: 2026-04-07 by AI Assistant

In this tutorial, we will build a Weather AI Agent that can fetch real-time weather reports from the internet using a custom tool. We’ll leverage the ADK-Rust framework and connect to the wttr.in service.
Prerequisites
Before we start, ensure you have the following:
- Rust Ecosystem: A working Rust environment.
- Google Gemini API Key: To power the language model.
- Dependencies: We’ll use
adk-rustas our core framework andreqwestfor HTTP requests.
Step 1: Project Setup and Dependencies
Start by adding the following dependencies to your Cargo.toml file:
[dependencies]
adk-rust = "0.4"
adk-tool = "0.4"
tokio = { version = "1", features = ["full"] }
dotenvy = "0.15"
anyhow = "1"
reqwest = { version = "0.11", features = ["json"] }
serde_json = "1"
serde = { version = "1", features = ["derive"] }
schemars = "0.8"
async-trait = "0.1"
Step 2: Defining Tool Arguments
We need to create a struct to capture the parameters that the AI Agent will pass to our tool. We’ll derive Deserialize and JsonSchema so the agent understands the data structure.
#[derive(Deserialize, JsonSchema)]
struct WeatherArgs {
/// The city to search for (e.g., bangkok, tokyo, london)
city: String,
}
Step 3: Creating the Weather Tool
Use the #[tool] macro to convert a standard async function into a tool that the Agent can invoke.
#[tool]
async fn get_weather(args: WeatherArgs) -> Result<Value> {
let url = format!("https://wttr.in/{}?format=j1", args.city);
let resp = reqwest::get(&url).await
.map_err(|e| AdkError::Tool(e.to_string()))?
.json::<serde_json::Value>().await
.map_err(|e| AdkError::Tool(e.to_string()))?;
Ok(resp)
}
Step 4: Assembling the Agent
Finally, we’ll use LlmAgentBuilder to create the agent and register our get_weather tool.
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let api_key = std::env::var("GOOGLE_API_KEY")?;
// Select the Gemini model
let model = adk_rust::model::GeminiModel::new(&api_key, "gemini-2.5-flash")?;
// Build the Agent
let agent = LlmAgentBuilder::new("agent-wttrin")
.description("Weather Reporting AI")
.instruction("You are a helpful assistant that provides accurate and friendly weather reports.")
.model(Arc::new(model))
.tool(Arc::new(GetWeather)) // Register the tool (note the PascalCase name automatically generated)
.build()?;
// Run via Launcher to interact through the terminal
Launcher::new(Arc::new(agent)).run().await?;
Ok(())
}
How to Use Your Agent
-
Configure Environment: Create a
.envfile and add your API Key:GOOGLE_API_KEY=your_api_key_here -
Run the Program:
cargo run -
Interact with the Agent:
“What’s the weather like in Bangkok?”
The Agent will automatically call the get_weather tool, passing city="bangkok", fetch the real-time data from wttr.in, and then summarize it for you in a friendly response!
Conclusion
By using ADK-Rust, we’ve successfully integrated a live data source into an AI Agent with minimal boilerplate. This pattern can be extended to any API, allowing you to build specialized agents for virtually any task. Happy coding!