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.
Install
Section titled “Install”pip install "dinobase[pydantic-ai]"Set up your data sources:
dinobase initdinobase add stripe --api-key sk_test_...dinobase add hubspot --api-key pat-...dinobase syncSee Connecting Sources for the full list of 100+ supported sources, and Syncing & Scheduling for background sync options.
Quick Start
Section titled “Quick Start”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)Toolset on Your Own Agent
Section titled “Toolset on Your Own Agent”Attach the dinobase_tools toolset to any Pydantic AI agent:
from pydantic_ai import Agentfrom 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:
| Tool | Description |
|---|---|
dinobase_query | Execute SQL queries (DuckDB dialect) |
dinobase_describe | Get table schema, types, and sample data |
dinobase_list_sources | List connected sources with freshness status |
dinobase_refresh | Re-sync a stale data source |
All tools use RunContext[DinobaseDeps] for type-safe dependency injection. The DinobaseDeps dataclass lazily initializes the Dinobase QueryEngine.
How It Works
Section titled “How It Works”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:
dinobase_list_sources— discover available datadinobase_describe— understand table schemasdinobase_query— run cross-source SQL queries- Present and analyze results
Example
Section titled “Example”See the example agent:
export ANTHROPIC_API_KEY=sk-ant-...python examples/analyst.py "Which deals closed this quarter?"Next steps
Section titled “Next steps”- Getting Started — Full setup walkthrough
- Connecting Sources — Add your business data
- Querying Data — SQL patterns and cross-source joins
- Syncing & Scheduling — Keep data fresh
- Schema Annotations — Add context for AI agents
- Python API Reference — QueryEngine and SyncEngine