Knowledge & Research
Current conditions and 5-day forecasts.
openweathermapLooks up today's weather and the five-day forecast for any city or coordinate. Useful whenever weather might influence a decision — travel planning, event scheduling, field operations.
Calls the OpenWeatherMap API to return either current conditions or a 5-day forecast at 3-hour intervals. Accepts a city name or (lat, lon) coordinates and returns temperature, humidity, wind, and a short description. Units can be metric, imperial, or Kelvin-based 'standard'.
When a user asks:
What's the 5-day forecast for Zurich?
the agent calls the tool:
openweathermap(city="Zurich", forecast=true, units="metric")and gets back: current conditions plus a 5-day / 3-hour forecast in metric units.
Set these before calling the tool. Values marked required must be present or the tool call will fail.
OPENWEATHER_API_KEY required OpenWeatherMap API key. Read from env or the 'api_key' parameter.
swarmai.tools.openweather.api-key optional Spring property alternative to the env var.
Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.
YAML DSL
# ops-planning.yaml
name: ops-planning-crew
process: SEQUENTIAL
agents:
- id: planner
role: Operations Planner
goal: Factor weather into scheduling decisions
tools:
- openweathermap
tasks:
- id: ops-planning-task
agent: planner
description: Get the 5-day forecast for Zurich and flag any day with more than 70% chance of precipitation.Java
import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.data.OpenWeatherMapTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
@Autowired ChatClient chatClient;
@Autowired OpenWeatherMapTool openWeatherMapTool;
Agent planner = Agent.builder()
.role("Operations Planner")
.goal("Factor weather into scheduling decisions")
.chatClient(chatClient)
.tool(openWeatherMapTool)
.build();
Task plannerTask = Task.builder()
.description("Get the 5-day forecast for Zurich and flag any day with more than 70% chance of precipitation.")
.agent(planner)
.build();
SwarmOutput result = Swarm.builder()
.agent(planner)
.task(plannerTask)
.process(ProcessType.SEQUENTIAL)
.build()
.kickoff();Real scenarios where agents put this tool to work.
Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/data/OpenWeatherMapTool.java in the swarm-ai repository.