Skip to main content
This guide shows you how to add Snow Leopard data retrieval to a Pydantic AI agent.

Prerequisites

Don’t have data? Use our sample superheroes dataset to get started, or choose from our other sample datasets.

Start from scratch

Clone and run the complete working example:
git clone https://github.com/SnowLeopard-AI/snowy-examples.git
cd snowy-examples/quickstart/pydantic-ai
Set your environment variables:
export ANTHROPIC_API_KEY=your-anthropic-key
export SNOWLEOPARD_API_KEY=your-snowleopard-key
export SNOWLEOPARD_DATAFILE_ID=your-datafile-id
Run the agent:
uv run clai --agent agent:agent
You now have an interactive REPL where you can ask questions about your data:
clai ➤ How many superheroes are there?

Bring your own agent

Already have a Pydantic AI agent? Add Snow Leopard data retrieval with these steps.

1. Install dependencies

uv add snowleopard

2. Create the Snow Leopard tool

Add a tool to your agent that calls Snow Leopard to retrieve data:
from pydantic_ai import Agent, RunContext
from snowleopard import SnowLeopardClient

# Your existing agent
agent = Agent(
    'anthropic:claude-sonnet-4-5',
    instructions='Be concise, reply with one sentence.',
)

# Initialize the Snow Leopard client
snowy = SnowLeopardClient(api_key="{your-snowleopard-api-key}")

# Add the data retrieval tool
@agent.tool
def get_data(ctx: RunContext[str], user_query: str) -> str:
    """
    Retrieve data from the database.
    Describe your data here - this becomes part of the agent's context.
    """
    response = snowy.retrieve(user_query=user_query, datafile_id="{your-datafile-id}")
    return str(response)

3. Customize the tool description

The tool’s docstring tells the agent when and how to use it. Update it to describe your specific data:
@agent.tool
def get_data(ctx: RunContext[str], user_query: str) -> str:
    """
    Retrieve customer order data.
    Contains order history, products, and customer information.
    Use this to answer questions about sales, orders, and customers.
    """
    response = snowy.retrieve(user_query=user_query, datafile_id=datafile_id)
    return str(response)

Next steps