> ## Documentation Index
> Fetch the complete documentation index at: https://agentictoolbox.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Weather

> A comprehensive weather tool for fetching real-time weather data and forecasts.

**class**: `JordanPrice\Toolbox\Tools\Weather\WeatherTool`\
**env vars**: `WEATHER_API_KEY`\
**source**: [GitHub](https://github.com/jordan-price/toolbox/blob/main/src/Tools/Weather/WeatherTool.php)

```env theme={null}
WEATHER_API_KEY=your_api_key_here
```

## Prism Integration

```php theme={null}
use JordanPrice\Toolbox\Tools\Weather\WeatherTool;
use EchoLabs\Prism\Prism;
use EchoLabs\Prism\Enums\Provider;
use EchoLabs\Prism\Enums\ToolChoice;

$weatherTool = new WeatherTool();

$prism = Prism::text()
    ->using(Provider::Anthropic, 'claude-3-5-sonnet-latest')
    ->withPrompt('What is the weather in London?')
    ->withTools([$weatherTool])  // Pass the tool instance
    ->toolChoice(ToolChoice::Any);

$response = $prism->generate();
```

## Publish

Optionally, you can publish the configuration file to make modifications:

```bash theme={null}
# Publish just this tool
php artisan toolbox:publish weather

# Or publish all tools
php artisan toolbox:publish
```

Add your Weather API key to your `.env` file:

## Methods

### \_\_invoke

Get weather data for a location.

```php theme={null}
public function __invoke(string $location): string
```

#### Parameters

* `location` (string): Location to get the weather for. Can be a city name, zipcode, IP address, or lat/lng coordinates. Example: "London"

#### Returns

* `string`: Formatted weather information
