Agriculture & AgTech Research Agent

Superhighway guides

Agriculture is a data-rich business where crop condition reports, commodity prices, and weather patterns reset the picture daily — and where a planting decision, a hedge, or an AgTech investment turns on USDA yield estimates, drought-monitor data, and the trajectory of precision-ag adoption. This guide builds a Python agent for commodity traders, precision-agriculture startups, farm managers, agricultural investors, food supply chain analysts, and climate-smart farming researchers. It chains all four Superhighway endpoints — /research for the market and agronomic landscape, /search against authoritative ag-data and AgTech sources, /scrape for a specific USDA crop report or investment summary, and /news for recent price moves and funding rounds — then uses an LLM to emit a structured agriculture brief as JSON.

Data note: Commodity prices and crop condition data change daily. For the most current USDA figures, see USDA NASS and USDA ERS directly. AgTech market data from AgFunder and Pitchbook may lag 3-6 months.

Overview

The agent takes a crop, commodity, technology, or market segment — "corn production Midwest drought impact 2024", "vertical farming lettuce market technology" — and produces a structured agriculture and AgTech brief:

Who it's for: commodity traders, precision-agriculture startups, farm managers, agricultural investors, food supply chain analysts, and climate-smart farming researchers.

How it works

Five endpoint calls feed one LLM synthesis:

  1. /research — deep synthesis of the market: structure, key players, technology adoption patterns, agronomic context, and policy landscape.
  2. /search (authoritative ag data) — crop yields, prices, and acreage scoped to USDA, FAO, and AgFunder.
  3. /search (AgTech market, time=year) — precision agriculture, drone/satellite, IoT sensors, and vertical-farming startups and market reports.
  4. /scrape — one relevant URL, e.g. a USDA NASS crop report summary, an AgFunder investment report, or an extension-university fact sheet.
  5. /news (time=month) — recent commodity price moves, weather impacts, USDA report releases, AgTech funding rounds, and policy changes.

Full example

pip install openai requests python-dotenv

Create a .env file with your two keys:

SUPERHIGHWAY_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
import requests, os, json
from openai import OpenAI

SUPERHIGHWAY_KEY = os.getenv("SUPERHIGHWAY_API_KEY")
BASE = "https://superhighway.walls.sh"
HEADERS = {"Authorization": f"Bearer {SUPERHIGHWAY_KEY}"}

llm = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

NOTE = (
    "Commodity prices and crop condition data change daily. For the most "
    "current USDA figures, see USDA NASS (nass.usda.gov) and USDA ERS "
    "(ers.usda.gov) directly. AgTech market data from AgFunder and Pitchbook "
    "may lag 3-6 months."
)

# 1. Deep synthesis of the agriculture & AgTech market
def research_market(query: str) -> str:
    """Market structure, key players, technology adoption, agronomic context, policy."""
    r = requests.get(
        f"{BASE}/research",
        params={"q": f"{query} agriculture farming technology market"},
        headers=HEADERS,
    )
    data = r.json()
    return data.get("summary", "")[:3000]

# 2. Authoritative ag data: USDA, FAO, AgFunder
def search_ag_data(query: str) -> list[dict]:
    """Crop yields, prices, acreage from USDA NASS/ERS, FAO, and AgFunder."""
    r = requests.get(
        f"{BASE}/search",
        params={
            "q": f"{query} crop price yield production "
                 f"site:usda.gov OR site:fao.org OR site:agfunder.com",
        },
        headers=HEADERS,
    )
    return r.json().get("results", [])

# 3. AgTech market: precision ag, drones, IoT, satellite (last year)
def search_agtech(query: str) -> list[dict]:
    """Precision agriculture, drone/satellite imagery, IoT sensors, vertical farming."""
    r = requests.get(
        f"{BASE}/search",
        params={
            "q": f"{query} precision agriculture agtech startup technology "
                 f"IoT drone satellite",
            "time": "year",
        },
        headers=HEADERS,
    )
    return r.json().get("results", [])

# 4. Scrape one relevant USDA report / AgFunder report / extension fact sheet
def scrape_page(url: str) -> dict:
    """Pull a USDA NASS crop summary, an AgFunder report, or an extension fact sheet."""
    r = requests.post(
        f"{BASE}/scrape",
        json={"url": url, "mode": "markdown"},
        headers=HEADERS,
    )
    data = r.json()
    return {
        "url": url,
        "title": data.get("title", ""),
        "content": data.get("markdown", data.get("text", ""))[:2500],
    }

# 5. Recent agriculture news: prices, weather, funding (last month)
def get_news(query: str) -> list[dict]:
    """Commodity price moves, weather impacts, USDA reports, AgTech funding, policy."""
    r = requests.get(
        f"{BASE}/news",
        params={
            "q": f"{query} agriculture farming crop commodity price",
            "time": "month",
        },
        headers=HEADERS,
    )
    return r.json().get("results", [])

def generate_brief(
    query: str,
    market: str,
    ag_data: list[dict],
    agtech: list[dict],
    scraped: dict | None,
    news: list[dict],
) -> dict | None:
    """Generate a structured agriculture & AgTech brief as JSON."""

    ag_data_text = "\n".join(
        f"- {r.get('title', '')}: {r.get('snippet', '')} ({r.get('url', '')})"
        for r in ag_data[:6]
    )
    agtech_text = "\n".join(
        f"- {r.get('title', '')}: {r.get('snippet', '')}"
        for r in agtech[:6]
    )
    news_text = "\n".join(
        f"- {n.get('title', '')}: {n.get('snippet', '')}"
        for n in news[:6]
    )
    scraped_text = ""
    if scraped and scraped.get("content"):
        scraped_text = f"{scraped['title']}\n{scraped['content']}"

    response = llm.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {
                "role": "system",
                "content": (
                    "You are an agricultural market and AgTech analyst. Use ONLY the "
                    "provided sources. Do not invent yield figures, commodity prices, "
                    "acreage, funding amounts, or company names — if a detail is not in "
                    "the sources, say 'not found in sources.' Be precise about USDA/FAO "
                    "data, weather and climate risk, and precision-ag technology, and "
                    "flag when figures may be preliminary or estimated."
                ),
            },
            {
                "role": "user",
                "content": f"""Write an agriculture & AgTech brief for: {query}

Market Landscape (synthesis):
{market}

Authoritative Ag Data (USDA / FAO / AgFunder):
{ag_data_text}

AgTech Market (precision ag / drones / IoT / satellite):
{agtech_text}

Scraped USDA Report / AgFunder Report / Extension Fact Sheet:
{scraped_text}

Recent Agriculture News:
{news_text}

Return JSON with ALL of these fields:
- subject: crop, commodity, technology, or market segment being researched
- sector: "row-crops" | "specialty-crops" | "livestock" | "aquaculture" | "vertical-farming" | "precision-ag" | "ag-biotech" | "soil-health" | "water-management" | "supply-chain" | "mixed"
- geographic_focus: "US" | "North America" | "South America" | "Europe" | "Sub-Saharan Africa" | "South Asia" | "East Asia" | "Global"
- market_overview: current state — acreage, production volumes, market size, key growing regions
- commodity_price_environment: current price levels and trends for relevant commodities (reference USDA/CME data where available)
- weather_and_climate_risk: current season weather patterns, El Nino/La Nina impacts, drought/flood risk, longer-term climate vulnerability for this crop/region
- key_players: list of leading companies, cooperatives, input suppliers, AgTech platforms in this space
- technology_landscape: relevant precision ag tools — drones, satellite imagery (Planet, Maxar), IoT sensors, variable-rate application, ag management software (Granular, Climate FieldView, Farmers Edge)
- regulatory_environment: USDA programs (ARC/PLC, crop insurance, EQIP conservation), EPA pesticide registrations, water rights, organic/regenerative certification requirements
- investment_and_funding: recent AgTech VC activity, USDA grants (SBIR, REAP), strategic corporate investment in this space
- sustainability_and_certification: organic, fair trade, regenerative ag, carbon credit markets (Indigo Carbon, Nori, Regen Network) relevant to this subject
- data_quality: "high" | "medium" | "low" — based on how well USDA/FAO/AgFunder sources covered the query""",
            },
        ],
        response_format={"type": "json_object"},
    )

    try:
        brief = json.loads(response.choices[0].message.content)
        brief["note"] = NOTE
        return brief
    except (json.JSONDecodeError, KeyError):
        return None

def research_agriculture(query: str) -> dict | None:
    """Run the full agriculture & AgTech research pipeline."""
    print(f"Researching agriculture market: {query}")

    print("Synthesizing market landscape...")
    market = research_market(query)

    print("Searching authoritative ag data...")
    ag_data = search_ag_data(query)

    print("Searching AgTech market...")
    agtech = search_agtech(query)

    print("Scraping a relevant USDA / AgFunder / extension page...")
    scraped = None
    for result in ag_data + agtech:
        url = result.get("url")
        if url and ("usda.gov" in url or "fao.org" in url
                    or "agfunder.com" in url or ".edu" in url):
            scraped = scrape_page(url)
            if scraped.get("content"):
                break

    print("Pulling recent agriculture news...")
    news = get_news(query)

    print("Generating agriculture brief...")
    return generate_brief(query, market, ag_data, agtech, scraped, news)

def print_brief(brief: dict):
    if not brief:
        print("Could not generate brief.")
        return
    print(f"\n{'='*60}")
    print(f"Agriculture & AgTech Brief")
    print(f"{'='*60}")
    print(f"\nSubject: {brief.get('subject', '')}")
    print(f"Sector: {brief.get('sector', '')}")
    print(f"Geographic Focus: {brief.get('geographic_focus', '')}")
    print(f"\nMarket Overview:\n{brief.get('market_overview', '')}")
    print(f"\nCommodity Price Environment:\n{brief.get('commodity_price_environment', '')}")
    print(f"\nWeather & Climate Risk:\n{brief.get('weather_and_climate_risk', '')}")
    print(f"\nKey Players: {', '.join(brief.get('key_players', []))}")
    print(f"\nTechnology Landscape:\n{brief.get('technology_landscape', '')}")
    print(f"\nRegulatory Environment:\n{brief.get('regulatory_environment', '')}")
    print(f"\nInvestment & Funding:\n{brief.get('investment_and_funding', '')}")
    print(f"\nSustainability & Certification:\n{brief.get('sustainability_and_certification', '')}")
    print(f"\nData Quality: {brief.get('data_quality', '?')}")
    print(f"\n{brief.get('note', '')}")

if __name__ == "__main__":
    import sys
    query = sys.argv[1] if len(sys.argv) > 1 else "corn production Midwest drought impact 2024"
    brief = research_agriculture(query)
    print_brief(brief)

Usage examples

Getting your API key

Grab a free Superhighway key at /pricing (1,000 calls/month, no credit card). For an agent that provisions its own access, skip the key entirely with x402: it pays $0.002 per call in USDC on Base — no signup, no key management. See the x402 pay-per-call guide for the wallet setup.

See also

The supply chain research agent applies the same four-endpoint pattern to suppliers and logistics risk along the food supply chain, and the energy research agent covers commodity, weather, and policy dynamics in the adjacent energy market.