Skip to content

Pydantic AI

Dinobase provides a Pydantic AI toolset that lets your agents query business data from 100+ sources with full type safety and dependency injection.

Terminal window
pip install "dinobase[pydantic-ai]"

Set up your data sources:

Terminal window
dinobase init
dinobase add stripe --api-key sk_test_...
dinobase add hubspot --api-key pat-...
dinobase sync

See Connecting Sources for the full list of 100+ supported sources, and Syncing & Scheduling for background sync options.

Use the pre-configured agent:

from dinobase.integrations.pydantic_ai.tools import DinobaseDeps, dinobase_agent
result = dinobase_agent.run_sync(
"Which customers have overdue invoices?",
deps=DinobaseDeps(),
)
print(result.output)

Attach the dinobase_tools toolset to any Pydantic AI agent:

from pydantic_ai import Agent
from dinobase.integrations.pydantic_ai.tools import DinobaseDeps, dinobase_tools
agent = Agent(
"anthropic:claude-sonnet-4-6",
deps_type=DinobaseDeps,
toolsets=[dinobase_tools],
instructions="You are a financial analyst. Be concise.",
)
result = agent.run_sync("What is our MRR trend?", deps=DinobaseDeps())
print(result.output)

The dinobase_tools toolset provides four tools:

ToolDescription
dinobase_queryExecute SQL queries (DuckDB dialect)
dinobase_describeGet table schema, types, and sample data
dinobase_list_sourcesList connected sources with freshness status
dinobase_refreshRe-sync a stale data source

All tools use RunContext[DinobaseDeps] for type-safe dependency injection. The DinobaseDeps dataclass lazily initializes the Dinobase QueryEngine.

Tools wrap Dinobase’s Python API via Pydantic AI’s FunctionToolset. Dependencies are injected through RunContext[DinobaseDeps], which provides access to the QueryEngine.

The typical agent workflow:

  1. dinobase_list_sources — discover available data
  2. dinobase_describe — understand table schemas
  3. dinobase_query — run cross-source SQL queries
  4. Present and analyze results

See the example agent:

Terminal window
export ANTHROPIC_API_KEY=sk-ant-...
python examples/analyst.py "Which deals closed this quarter?"