Ready made ParlayAPI sports odds tools for LangChain, LlamaIndex, and plain OpenAI or Anthropic function calling.
Start with a public moneyline sample for one sport. Three tools run without an API key. The keyed tools request odds, compare returned prices and read historical closing odds. Bookmaker coverage depends on the fixture, market, filters and account plan.
Run the tool-call notebook in Colab or read it on GitHub. Replay a priced board, an empty board and a malformed reply before you connect a model. The final cell can make one public request.
from parlayapi_tools.langchain import get_parlayapi_tools
tools = get_parlayapi_tools() # reads PARLAY_API_KEY from the environmentDid the price move, or did the book just refresh its timestamp? Install the project skill from a terminal in the project where you want to use it. This example selects Codex. For Claude Code, use --agent claude-code.
npx skills add JacobiusMakes/parlayapi-agent-tools --skill nba-quote-changes --agent codexUsing the Claude web app? Download the skill ZIP and upload it under Customize → Skills if your workspace allows custom skills. The ZIP includes the fictional example. Claude upload instructions
Try this prompt: “Use the nba-quote-changes skill with its two fictional snapshots. Which team moved at North? What can you tell me about South?” North's price on the Comets moves from −110 to +105. South appears only in the second file, so its earlier price is unknown.
The skill and two snapshots also run locally with Python 3.10 or newer. For your own comparison, save JSON from the public NBA endpoint at two times of your choice. Keep the capture order. Each response contains up to five events. To see the current sample before saving anything, open the NBA preview.
For a worked example with dated observations, compare the two Atlanta moneyline quotes. The market and the book each report their own clock.
Install the versioned Python 3.10+ wheel from GitHub Releases. The core client and the raw tool definitions use the standard library. Try this inside your project's virtual environment:
python -m pip install https://github.com/JacobiusMakes/parlayapi-agent-tools/releases/download/v0.1.1/parlayapi_agent_tools-0.1.1-py3-none-any.whl
python -c "from parlayapi_tools.openai_schemas import OPENAI_TOOLS; print([tool['function']['name'] for tool in OPENAI_TOOLS])"The second command lists the six registered tools locally. To inspect their arguments without installing Python, download the OpenAI Chat Completions tool definitions or the Anthropic tool definitions. These JSON files describe the tools. Your application handles execution and returns results to the model.
For the LangChain adapter, install the wheel with its optional dependencies:
python -m pip install "parlayapi-agent-tools[langchain] @ https://github.com/JacobiusMakes/parlayapi-agent-tools/releases/download/v0.1.1/parlayapi_agent_tools-0.1.1-py3-none-any.whl"Use [llamaindex] for the LlamaIndex adapter. For a source install, clone this repository and run python -m pip install . from the checkout.
The core client is standard library only. Framework imports are guarded, so having just one
framework installed is fine, and having none installed still gives you ParlayAPIClient and the
raw function calling schemas.
Want a running example before wiring anything yourself? parlayapi-betting-agent-starter includes a fictional offline example. Select a public demo separately to inspect an actual response.
Configure your model provider separately. For the three keyed tools, supply your ParlayAPI key through the local environment or a server-side secret store.
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from parlayapi_tools.langchain import get_parlayapi_tools
agent = create_react_agent(
ChatOpenAI(model="gpt-4o-mini"),
get_parlayapi_tools(),
)
result = agent.invoke({
"messages": [("user", "Which book has the best price on the Chiefs this week?")]
})
print(result["messages"][-1].content)from llama_index.llms.openai import OpenAI
from llama_index.core.agent.workflow import FunctionAgent
from parlayapi_tools.llamaindex import get_parlayapi_tools
agent = FunctionAgent(
tools=get_parlayapi_tools(),
llm=OpenAI(model="gpt-4o-mini"),
)
print(await agent.run("What are tonight's NHL moneylines, and where is the best price?"))from openai import OpenAI
from parlayapi_tools.openai_schemas import OPENAI_TOOLS, dispatch
client = OpenAI()
messages = [{"role": "user", "content": "What are the NFL odds this weekend?"}]
response = client.chat.completions.create(
model="gpt-4o-mini", messages=messages, tools=OPENAI_TOOLS
)
for call in response.choices[0].message.tool_calls or []:
import json
result = dispatch(call.function.name, json.loads(call.function.arguments))
# append the result as a tool message and call the model againimport anthropic
from parlayapi_tools.openai_schemas import ANTHROPIC_TOOLS, dispatch
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-5",
max_tokens=4096,
tools=ANTHROPIC_TOOLS,
messages=[{"role": "user", "content": "Best moneyline price on the Yankees tonight?"}],
)
for block in response.content:
if block.type == "tool_use":
result = dispatch(block.name, block.input)dispatch() returns plain JSON serialisable dicts, including for failures, so a tool error never
takes the agent loop down with it.
Run one tool directly to see what the agent receives. This example needs neither a model-provider credential nor a ParlayAPI key.
from parlayapi_tools.openai_schemas import dispatch
result = dispatch("parlayapi_demo_odds", {"sport_key": "basketball_nba"})
if result["ok"]:
print(result["events_returned"], "events returned")
print(result["summary"])
else:
print(result)A successful empty board reports zero events. A failed response returns an error. For a priced market, read the bookmaker and selection together with its reported market update time. The event start and the time you ran the tool describe different things.
The keyless demo is capped by the API at moneyline only, the first 5 games, and 60 requests per
hour per IP, across these six sports: americanfootball_nfl, baseball_mlb, basketball_nba,
icehockey_nhl, soccer_epl, mma_mixed_martial_arts.
| Tool | Key needed | Credits | Endpoint |
|---|---|---|---|
parlayapi_list_sports |
no | free | GET /v1/sports |
parlayapi_get_odds |
yes | markets x regions | GET /v1/sports/{sport_key}/odds |
parlayapi_get_best_line |
yes | 5 | GET /v1/sports/{sport_key}/best-line |
parlayapi_get_historical_closing_odds |
yes | 10 | GET /v1/historical/sports/{sport_key}/closing-odds |
parlayapi_demo_odds |
no | free | GET /v1/try/{sport_key}/odds |
parlayapi_demo_positive_ev |
no | free | GET /v1/try/{sport_key}/ev |
Every path, query parameter and credit cost above was read from
parlay-api.com/openapi.json and
/v1/meta/credit-costs on 2026-09-01. A trimmed copy of that document ships in
tests/fixtures/openapi_subset.json, and the test suite fails if this client ever sends a
parameter it does not list.
When the sample matches your use case, create a free account for keyed requests. The free plan includes 1,000 credits per month and requires no card. Check current route costs before starting a loop.
Set it as PARLAY_API_KEY, or pass api_key= to get_parlayapi_tools() or ParlayAPIClient().
It travels in the X-API-Key header and is never put in a query string.
Tier allowances and prices: parlay-api.com/pricing.
If your agent speaks Model Context Protocol, you may not need this package at all. ParlayAPI has a hosted MCP endpoint, so there is nothing to install:
POST https://parlay-api.com/mcp/http
Details and client configuration: parlay-api.com/mcp. There is also a
parlayapi-mcp package on PyPI for a local stdio server.
Use this package instead when you want the tools inside your own agent framework, want to select or rename the tool belt, or want to post process results before they reach the model.
Not every endpoint is wrapped. The API has around 200 paths: arbitrage, middles, player props,
injuries, live SSE feeds, parlay pricing, CLV and more. This package deliberately wraps six, the
ones that answer the majority of "what are the odds" questions without bloating an agent's tool
belt. Anything not wrapped is one ParlayAPIClient._request call away, or use the MCP route.
Historical depth depends on your tier. The historical window on the free tier is 48 hours. Paid
tiers widen it substantially. A tool call outside your window comes back as an error with an
upgrade_url, not as an empty result, and the tool surfaces that field rather than swallowing it.
Response shapes. The demo endpoints and GET /v1/sports are modelled as typed dataclasses, and
those models are tested against real captured responses. best_line and
historical_closing_odds return the decoded JSON exactly as the API sends it, because their
response bodies could not be verified against a live authenticated call while this package was
written. Anything the API sends that is not modelled is preserved on .raw, so nothing is dropped.
Untested paths. The keyless endpoints are covered by a live end to end smoke test. The three
key requiring endpoints have their request construction tested against the OpenAPI document and
their error handling tested against real captured error bodies, but no live authenticated call was
made. See tests/ for exactly what runs.
Rate limits. The keyless demo is 60 requests per hour per IP. If your agent may loop, keep the demo tools out of the belt once a real key is configured.
This is data, not advice. The positive EV tool reports an edge computed against one sharp reference book. That is an estimate, not a guarantee, and nothing this package returns is betting advice.
pip install -e ".[dev,langchain,llamaindex]"
pytest # unit tests, no network
PARLAYAPI_LIVE_TESTS=1 pytest -m network # keyless live smoke test
ruff check .Every fixture under tests/fixtures/ is a real response captured from the live API on 2026-09-01.
None of it is hand written.
MIT. See LICENSE.
Part of the ParlayAPI ecosystem: a real-time sports odds API with a free tier of 1,000 credits per month, no card required. Explore all the tools at github.com/JacobiusMakes.