> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenWeather

> Fetch current weather, forecasts, air pollution data, and geocoding with OpenWeatherTools and the OpenWeatherMap API.

**OpenWeatherTools** enable an Agent to access weather data from the OpenWeatherMap API.

## Prerequisites

The following example requires the `requests` and `openai` libraries and an API key which can be obtained from [OpenWeatherMap](https://openweathermap.org/api). The API key activates a few hours after sign-up.

```shell theme={null}
uv pip install -U requests openai
```

```shell theme={null}
export OPENWEATHER_API_KEY=***
```

## Example

The following agent will use OpenWeatherMap to get current weather information for Tokyo.

```python cookbook/91_tools/openweather_tools.py theme={null}
from agno.agent import Agent
from agno.tools.openweather import OpenWeatherTools

# Create an agent with OpenWeatherTools
agent = Agent(
    tools=[
        OpenWeatherTools(
            units="imperial",  # Options: 'standard', 'metric', 'imperial'
        )
    ],
    markdown=True,
)

# Get current weather for a location
agent.print_response("What's the current weather in Tokyo?", markdown=True)
```

## Toolkit Params

| Parameter | Type | Default | Description |
| - | - | - | - |
| `api_key` | `str` | `None` | OpenWeatherMap API key. If not provided, uses OPENWEATHER\_API\_KEY env var. |
| `units` | `str` | `metric` | Units of measurement. Options: 'standard', 'metric', 'imperial'. |
| `enable_current_weather` | `bool` | `True` | Enable current weather function. |
| `enable_forecast` | `bool` | `True` | Enable forecast function. |
| `enable_air_pollution` | `bool` | `True` | Enable air pollution function. |
| `enable_geocoding` | `bool` | `True` | Enable geocoding function. |
| `all` | `bool` | `False` | Enable all functions. |
| `timeout` | `int` | `30` | Per-request HTTP timeout in seconds. |

## Toolkit Functions

| Function | Description |
| - | - |
| `get_current_weather` | Gets current weather data for a location. Takes a location name (e.g., "London"). |
| `get_forecast` | Gets weather forecast for a location. Takes a location name and optional number of days (default 5). |
| `get_air_pollution` | Gets current air pollution data for a location. Takes a location name. |
| `geocode_location` | Converts a location name to geographic coordinates. Takes a location name and optional result limit. |

## Developer Resources

* [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/openweather.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.