Tool

Access Weather, Climate, and Geocoding Data

LlamaIndex tool giving an agent weather, climate, air quality, and geocoding data via MeasureSpace.

Works with measurespaceopenai

77
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Integrate with the MeasureSpace API to retrieve real-time and forecasted data for space weather, climate, and air quality. This tool also provides geocoding services to convert city names to coordinates and vice-versa.

Outcomes

What it gets done

01

Get hourly and daily weather forecasts.

02

Access daily climate forecasts for up to 10 months.

03

Retrieve daily air quality forecasts.

04

Convert city names to latitude/longitude and find nearest cities.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-measurespace | bash

Overview

Measure Space Weather, Climate, Air Quality and Geocoding Tool

This tool wires MeasureSpace's weather, climate, air quality, and geocoding API into a LlamaIndex agent through six functions, from hourly weather forecasts to city-to-coordinates lookups. Use it when an agent needs forecast or location data. It requires a separate MeasureSpace API key for each service you plan to use.

What it does

This tool connects to the MeasureSpace API (via the measure-space-api Python package) to give an agent access to weather, climate, air quality, and geocoding data. It exposes six functions: hourly weather forecast (next 5 days), daily weather forecast (next 15 days), daily climate forecast (next 10 months), daily air quality forecast (next 5 days), latitude/longitude lookup from a city name, and nearest-city lookup from a latitude/longitude pair.

When to use - and when NOT to

Use it when an agent needs forecast or location data -- for example answering "How's the temperature for New York in next 3 days?" or "What's the latitude and longitude of New York?" It needs a separate MeasureSpace API key per service you use (hourly weather, daily weather, daily climate, air quality, geocoding) plus an OpenAI key if you are using OpenAI, so it is not usable without setting those up first -- though you only need keys for the specific services you plan to call.

Inputs and outputs

Install with:

pip install llama-index-tools-measurespace

Load your API keys (from an .env file, one per service) and pass them as a dict to MeasureSpaceToolSpec:

from llama_index.tools.measurespace import MeasureSpaceToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv
import os

load_dotenv()

api_keys = {
    "hourly_weather": os.getenv("HOURLY_WEATHER_API_KEY"),
    "daily_weather": os.getenv("DAILY_WEATHER_API_KEY"),
    "daily_climate": os.getenv("DAILY_CLIMATE_API_KEY"),
    "air_quality": os.getenv("AIR_QUALITY_API_KEY"),
    "geocoding": os.getenv("GEOCODING_API_KEY"),
}

tool_spec = MeasureSpaceToolSpec(api_keys)
agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("How's the temperature for New York in next 3 days?"))
print(await agent.run("What's the latitude and longitude of New York?"))

Individual tools can also be called directly, for example tool_spec.get_daily_weather_forecast("New York") or tool_spec.get_latitude_longitude_from_location("New York").

Who it's for

Developers building agents that need forecast (weather, climate, air quality) or geocoding data and are willing to set up per-service MeasureSpace API keys for just the functions they need.

Source README

Measure Space Weather, Climate, Air Quality and Geocoding Tool

pip install llama-index-tools-measurespace

This tool connects to the MeasureSpace's API, using the measure-space-api Python package. You must initialize the tool with corresponding API keys from MeasureSpace and OpenAI (if you use OpenAI).

The tool has access to the following functions:

  • hourly weather forecast (next 5 days)
  • daily weather forecast (next 15 days)
  • daily climate forecast (next 10 months)
  • daily air quality forecast (next 5 days)
  • get latitude and longitude from given city names
  • get nearest city for given latitude and longitude

Usage

Assume you have an .env file with the following content:

GEOCODING_API_KEY=<your-geocoding-api-key>
HOURLY_WEATHER_API_KEY=<your-hourly-weather-api-key>
DAILY_WEATHER_API_KEY=R<your-daily-weather-api-key>
DAILY_CLIMATE_API_KEY=<your-daily-climate-api-key>
AIR_QUALITY_API_KEY=<your-air-quality-api-key>
OPENAI_API_KEY=<your-openai-api-key>

Note that you only need the API keys if you need the services.

from llama_index.tools.measurespace import MeasureSpaceToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv
import os

load_dotenv()

api_keys = {
    "hourly_weather": os.getenv("HOURLY_WEATHER_API_KEY"),
    "daily_weather": os.getenv("DAILY_WEATHER_API_KEY"),
    "daily_climate": os.getenv("DAILY_CLIMATE_API_KEY"),
    "air_quality": os.getenv("AIR_QUALITY_API_KEY"),
    "geocoding": os.getenv("GEOCODING_API_KEY"),
}

tool_spec = MeasureSpaceToolSpec(api_keys)
agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("How's the temperature for New York in next 3 days?"))
print(await agent.run("What's the latitude and longitude of New York?"))

### get a list of tools
for tool in tool_spec.to_tool_list():
    print(tool.metadata.name)

### Use a specific tool
tool_spec.get_daily_weather_forecast("New York")
tool_spec.get_latitude_longitude_from_location("New York")

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.