Pydantic AI
Pydantic AI is a Python agent framework from the Pydantic team. Its capability library, Pydantic AI Harness, includes two capabilities backed by You.com APIs:
YouSearchaddsweb_search(Web Search API) andget_page(Contents API).YouResearchaddsanswer(Answer API),research(Research API), andfinance_research(Finance Research API).
Each tool returns a Sources: block the model can cite, plus the same sources as structured metadata for your code.
Getting Started
Install the Package
The youdotcom extra installs the You.com Python SDK, and anthropic installs the model provider used in the examples below. For another provider, add its Pydantic AI extra, such as "pydantic-ai-slim[openai]". Requires Python 3.11+.
Pydantic AI Harness is on 0.x releases, so its API can change between minor versions.
Set Your API Keys
Get your You.com API key at you.com/platform. Creating a capability without YDC_API_KEY set raises an error.
Usage
Basic
Search controls
Research controls
Citations
Use YouSearch alone if the agent only needs search and page reads.
The Pydantic AI Harness reference lists every field and covers custom clients, multiple instances, native search fallback, and YAML agent specs.
Tools
Each tool call is billed at the rate of its underlying API.
Error Handling
The error code reference lists what each status means.
Durable Execution
Under Temporal, Prefect, or DBOS, each You.com request is recorded under the capability id (you_search or you_research), so a recovered run reuses the result instead of calling the API again. Keep the id stable once deployed—renaming it breaks in-flight runs.
A Temporal activity times out after 60 seconds by default, which research can exceed. Give the you_research toolset more time:
Cookbook
The pydantic-cookbook repo has four runnable examples: