Skip to main content
The GetWeatherTool provides real-time weather data using the WeatherAPI.com service.

Class Signature

Parameters

api_key
str
default:"None"
WeatherAPI.com API key. If not provided, the tool will look for the WEATHER_API_KEY environment variable.Get your API key at weatherapi.com.

Methods

get_current_weather

Retrieve current weather information for a specified location.
location
str
required
The location to get weather for. Can be:
  • City name (e.g., “London”, “Paris”)
  • Coordinates (e.g., “48.8567,2.3508”)
  • US zip code (e.g., “10001”)
  • UK postcode (e.g., “SW1”)
  • IP address (e.g., “100.0.0.1”)
Returns: A formatted string containing:
  • Location name and country
  • Temperature in Celsius and Fahrenheit
  • Weather condition description
  • Humidity percentage
  • Wind speed in km/h

Usage Example

With Agentor Agent

Environment Setup

Error Handling

The tool handles errors gracefully:
  • Missing API key: Returns an error message directing users to weatherapi.com
  • HTTP errors: Returns HTTP status code and error details
  • Network errors: Returns descriptive error message
  • Invalid location: Returns API error response

API Requirements

This tool requires a free or paid API key from WeatherAPI.com:
  1. Sign up for a free account
  2. Generate an API key from the dashboard
  3. Set the WEATHER_API_KEY environment variable or pass it to the constructor
Free tier includes:
  • 1 million calls per month
  • Current weather data
  • 3-day forecast
Source: /home/daytona/workspace/source/src/agentor/tools/weather.py:9
Last modified on May 5, 2026