Pydantic AI Integration
Give your Pydantic AI agent the knowledge, chats and leads of a whole website
Overview
Pydantic AI is a Python framework for building AI agents. The pydantic-ai-asyntai package adds one capability, AsyntaiCapability, that gives those agents a real website to draw on.
Point Asyntai at a domain. Asyntai reads the pages, the product feed and the documents, and keeps them current. Your agent then asks that website a question and gets the answer a visitor would get, built from the real pages and the real prices. You build and maintain no index.
The same capability opens the other side of the website: the chats visitors had, and the email addresses and phone numbers they left.
Tools
The capability adds these tools, plus a short instruction that tells the model to ask the website instead of guessing:
asyntai_ask_website: answers a question from the website's pages, products and knowledge base.asyntai_list_websites: lists the website agents on your account, with their ids.asyntai_list_knowledge: lists what the website agent knows.asyntai_get_leads: returns visitors who left an email address or a phone number, newest first.asyntai_get_conversation: returns the messages of one website chat.asyntai_add_textandasyntai_add_url: store a text or read a page into the knowledge base. Turn these on withknowledge_tools=True.
Requirements
- Python 3.10 or higher
- Pydantic AI 1.75 or higher
- An Asyntai account on the Starter plan or higher, because the capability uses the Asyntai API
Installation
Follow these steps to add Asyntai to a Pydantic AI agent:
Install the Package
pip install pydantic-ai-asyntai
Get Your API Key
Sign in to Asyntai, open Settings, then API, and copy your API key.
Set the Key
Put the key in the ASYNTAI_API_KEY environment variable, or pass it as api_key= to the capability.
Add the Capability
Pass AsyntaiCapability() to your agent's capabilities.
Example
from pydantic_ai import Agent
from pydantic_ai_asyntai import AsyntaiCapability
agent = Agent("anthropic:claude-sonnet-4-5", capabilities=[AsyntaiCapability()])
result = agent.run_sync("Do they ship to Spain, and how long does it take?")
print(result.output)
Each run starts its own website conversation, and follow-up questions in the run share its context. To continue one conversation across runs, for example one per customer, pass session_id="customer-42". Every conversation also shows in your Asyntai chat logs.
Options
AsyntaiCapability(
website_id=42, # which website agent, when the account has several
lead_tools=False, # hide visitor contact details and chats
knowledge_tools=True, # allow writing to the knowledge base
)
Agent Specs
The capability takes only plain values, so it also works in Pydantic AI agent specs:
# agent.yaml
model: anthropic:claude-sonnet-4-5
capabilities:
- AsyntaiCapability: {website_id: 42}
from pydantic_ai import Agent
from pydantic_ai_asyntai import AsyntaiCapability
agent = Agent.from_file("agent.yaml", custom_capability_types=[AsyntaiCapability])
Several Websites on One Agent
An Asyntai account can run an agent per website. Give each capability its own website_id and a tool prefix:
agent = Agent(
"anthropic:claude-sonnet-4-5",
capabilities=[
AsyntaiCapability(website_id=1).prefix_tools("bakery"),
AsyntaiCapability(website_id=2).prefix_tools("bikeshop"),
],
)
Agencies run this pattern across a client book: one Asyntai account, one agent per client site, one website_id per agent.
Tip: The answer quality follows the knowledge base. Add the pages that matter in the Asyntai dashboard, or with asyntai_add_url, and check the result with asyntai_list_knowledge.
Errors
A wrong argument, such as an unknown chat session_id, goes back to the model as ModelRetry, so the model can correct the call. A wrong API key, a plan without API access, or a reached message limit raises AsyntaiError and stops the run with a message you can show to a user.
from pydantic_ai_asyntai import AsyntaiError
try:
agent.run_sync("...")
except AsyntaiError as exc:
print(exc)
Plans & Pricing
The package is free. It uses the Asyntai API, which needs the Starter plan or higher. View pricing.
Need Help?
If you have any questions or run into issues, contact us at [email protected].