Cookbook

Build a sports research agent with LangChain and one REST tool

The smallest useful LangChain agent: one tool that calls the free DeepChamp slate endpoint, bound to a chat model, with a plain tool-calling loop you can read in one screen.

By DeepChamp research team · Updated

Short answer

To build a sports research agent with LangChain, define the DeepChamp daily slate endpoint as a @tool function, bind it to a chat model with bind_tools, and loop: invoke the model, run any tool calls it makes, append the results as ToolMessages, and stop when the model answers in text. The endpoint is free and needs no key.

Install and run

Terminal
pip install langchain-core langchain-anthropic httpx
ANTHROPIC_MODEL=<your model id> python langchain_slate_tool.py

The code

langchain_slate_tool.py
"""Slate research with LangChain: one REST tool, no framework magic. Set ANTHROPIC_API_KEY and ANTHROPIC_MODEL."""
import os

import httpx
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage, SystemMessage, ToolMessage
from langchain_core.tools import tool

API = "https://deepchampai.com/api/agent/v1"
SYSTEM = (
    "You write short pre-game research briefings from DeepChamp tool results. Use only what the tools return. Say when the data was current (meta.as_of). Never state odds, picks or outcomes, and never claim a result. End with: Research only, not betting advice. 21+. Help: 1-800-MY-RESET."
)


@tool
def get_daily_slate(sport: str) -> str:
    """Today's games for a sport (nba, nfl, mlb, nhl, cfb, cbb or wnba) with start times and rest and schedule context. Returns JSON with data, compliance and meta."""
    response = httpx.get(f"{API}/slate/today", params={"sport": sport}, timeout=20)
    response.raise_for_status()
    return response.text


def run(question: str) -> str:
    llm = ChatAnthropic(model=os.environ["ANTHROPIC_MODEL"]).bind_tools([get_daily_slate])
    messages = [SystemMessage(SYSTEM), HumanMessage(question)]
    for _ in range(4):
        reply = llm.invoke(messages)
        messages.append(reply)
        if not reply.tool_calls:
            if isinstance(reply.content, str):
                return reply.content
            return "".join(block.get("text", "") for block in reply.content if isinstance(block, dict))
        for call in reply.tool_calls:
            messages.append(ToolMessage(content=get_daily_slate.invoke(call["args"]), tool_call_id=call["id"]))
    return "Stopped after four tool rounds."


if __name__ == "__main__":
    print(run("What should I check first on tonight's NBA slate?"))

What to know before you extend it

  • The free tools return the daily slate and matchup context only: no odds, picks or results, and no key is needed. Paid tools appear in the tool list only when their product line is live.
  • The system prompt tells the model to cite the as-of time and to end with the safety line. Keep that: it is the difference between a briefing and a tip.
  • Relay the compliance block from every response to your own users. It carries the 21+ notice and the problem-gambling helpline.
  • Log every call and its as-of time. If you later add signals, log them with the entry price from your own feed and measure them against the closing line.
  • A manual loop is used on purpose: bind_tools, tool_calls and ToolMessage are stable across LangChain versions, while the prebuilt agent helpers have moved between releases.

What was checked, and when: on October 31, 2026, against production, the LangChain tool’s REST call returned the free envelope, and the MCP clients of the OpenAI Agents SDK (openai-agents 0.24.0) and the Vercel AI SDK (ai 7.0.105 with @ai-sdk/mcp 2.0.22) connected, listed the four free tools and called get_daily_slate. The Claude Agent SDK file was imported against claude-agent-sdk 0.2.175 and the LangChain file against langchain-core 1.7.3 and langchain-anthropic 1.7.7. The model loops themselves were not run because they need your model key; if a signature has moved in a newer SDK version, the SDK’s own documentation wins.

Common questions

How do I build an AI agent for sports betting research with LangChain?

Wrap a data source as a LangChain tool, bind it to a chat model, and run a tool-calling loop. For research rather than betting advice, restrict the model to tool results in the system prompt, surface the data’s as-of time, and keep the 21+ and problem-gambling line in every answer.

This page is published by DeepChamp AI, so read it as one vendor’s view. Examples use hypothetical numbers and are not live markets, picks or claims about performance.

21+ for U.S. sports betting. Follow the laws and age requirements where you are. DeepChamp AI provides independent sports betting research and analysis. It does not accept or place wagers, hold customer funds for betting, or operate a sportsbook. No wins or profits are guaranteed. If you or someone you know has a gambling problem, call or text 1-800-MY-RESET or visit the National Council on Problem Gambling.