← cookbook/pydanticai-instadash
5 min read·intermediate·updated just now

PydanticAI + Instadash — type-safe agent, live grid

A PydanticAI agent constrained to a typed result model, with a select-cell action column so the dashboard becomes a CRM-lite the moment the rows land.

#pydantic-ai#python#agent#types

What it builds

  • A Lead Pydantic model with 5 typed fields
  • PydanticAI agent with result_type=LeadList
  • Grid created with a select action column (outreach status)
  • Real CRM-lite UX in zero lines of frontend code

The key step

class Lead(BaseModel):
    company:  str
    domain:   str
    industry: str
    size:     str
    why_fit:  str
 
agent = Agent(
    "anthropic:claude-opus-4-7",
    result_type=LeadList,
    system_prompt="Generate 8 high-fit example companies for the ICP.",
)
 
result = agent.run_sync(icp)
push_to_instadash([l.model_dump() for l in result.data.leads])
note
This is the core of the recipe. The full file (including setup, error handling, and the surrounding scaffolding) lives in the GitHub folder linked below — clone or copy it directly.

Run it

bash⎘ copy
git clone https://github.com/instadashio/instadash-recipes
cd instadash-recipes/pydanticai-instadash
pip install -r requirements.txt
cp .env.example .env       # fill in your keys
python agent.py

Stack

pydantic-aipythonanthropic
Full source on GitHub

README, runnable code, .env.example, dependencies — all in one folder.

↗ view on github
─ related recipesview all →