Overview
Weather tool provides current weather, forecasts, and air quality data using various weather APIs.Installation
Environment Variables
Quick Start
How It Works
Usage with Agent
Available Methods
get_weather(location)
Get current weather.get_forecast(location, days=3)
Get weather forecast.get_air_quality(location)
Get air quality index.Common Errors
| Error | Cause | Solution |
|---|---|---|
API key not configured | Missing key | Set environment variable |
City not found | Invalid location | Check city name |
Best Practices
Keep the weather API key in the environment
Keep the weather API key in the environment
Set
OPENWEATHER_API_KEY or WEATHERAPI_KEY in your shell or .env. WeatherTool() reads it automatically — never hard-code the key.Bound forecast length
Bound forecast length
get_forecast(location, days=3) defaults to 3 days. Request only the horizon the task needs to keep responses concise.Handle unknown locations
Handle unknown locations
Invalid city names return a “City not found” error. Wrap the call in
try/except so the agent can ask the user to clarify the location.Related Tools
Google Maps
Location services

