Skip to content
Skills Library
AI & agents · Learning & explanation

pydanticai-docs

/pydanticai-docs

Use this skill whenever the user is working with the Pydantic AI framework — including building AI agents, defining structured outputs with Pydantic models, wiring up tools/function calling, configuring model providers (OpenAI, Anthropic, Gemini, etc.), managing dependencies via agent context, handling streaming responses, or debugging agent runs. Trigger this skill even for adjacent tasks like "how do I make my agent return JSON", "set up a multi-step agent", "add a tool to my agent", or "validate LLM output with Pydantic" — any time Pydantic AI is mentioned or implied as the target framework

Licence
MIT
Last repository change
23.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
9
Scripts
0
HTML comments
0
URLs in SKILL.md
14
Deprecation

No signals detected. Repository changed on 23.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use this skill whenever the user is working with the Pydantic AI framework — including building AI agents, defining structured outputs with Pydantic models, wiring up tools/function calling, configuring model providers (OpenAI, Anthropic, Gemini, etc.), managing dependencies via agent context, handling streaming responses, or debugging agent runs. Trigger this skill even for adjacent tasks like "how do I make my agent return JSON", "set up a multi-step agent", "add a tool to my agent", or "validate LLM output with Pydantic" — any time Pydantic AI is mentioned or implied as the target framework

Triggers from the description

how do I make my agent return JSONset up a multi-step agentadd a tool to my agentvalidate LLM output with Pydantic
Original author description

Use this skill whenever the user is working with the Pydantic AI framework — including building AI agents, defining structured outputs with Pydantic models, wiring up tools/function calling, configuring model providers (OpenAI, Anthropic, Gemini, etc.), managing dependencies via agent context, handling streaming responses, or debugging agent runs. Trigger this skill even for adjacent tasks like "how do I make my agent return JSON", "set up a multi-step agent", "add a tool to my agent", or "validate LLM output with Pydantic" — any time Pydantic AI is mentioned or implied as the target framework

How it works

  1. What is Pydantic AI?
  2. Core Concepts
  3. Additional Topics
  4. Agent Behavior Rules
Original SKILL.md headings · 114 lines, 526 words
SKILL.md preview
---
name: pydanticai-docs
description: Use this skill whenever the user is working with the Pydantic AI framework — including building AI agents, defining structured outputs with Pydantic models, wiring up tools/function calling, configuring model providers (OpenAI, Anthropic, Gemini, etc.), managing dependencies via agent context, handling streaming responses, or debugging agent runs. Trigger this skill even for adjacent tasks like "how do I make my agent return JSON", "set up a multi-step agent", "add a tool to my agent", or "validate LLM output with Pydantic" — any time Pydantic AI is mentioned or implied as the target framework.
license: Apache-2.0
metadata:
  author: Douglas Trajano
  version: "1.0"
---

# Pydantic AI Documentation Skill

## What is Pydantic AI?

Pydantic AI is a production-grade Python agent framework for building type-safe, dependency-injected Generative AI applications. It supports multiple LLM providers, structured outputs via Pydantic models, and composable multi-agent patterns.

Doc: <https://ai.pydantic.dev/>

---

## Core Concepts

### 1. Agent Instantiation

```python
from pydantic_ai import Agent

agent = Agent(
    'openai:gpt-4o',          # model string: provider:model-name
    system_prompt='Be helpful.',
)
result = agent.run_sync('What is the capital of France?')
print(result.output)
```

For full constructor parameters, run methods, and streaming: load `references/AGENT.md`.

### 2. Function Tools (`@agent.tool`)

```python
from pydantic_ai import Agent, RunContext

agent = Agent('openai:gpt-4o', deps_type=str)

@agent.tool
def get_user_name(ctx: RunContext[str]) -> str:
    """Return the current user's name."""
    return ctx.deps

result = agent.run_sync('What is my name?', deps='Alice')
```

Use `@agent.tool_plain` when you don't need `RunContext`. For tool registration, return types, and retries: load `references/FUNCTION_TOOLS.md`.

### 3. Dependency Injection (`RunContext`)

```python
from dataclasses import dataclass
from pydantic_ai import Agent, RunContext

@dataclass
class MyDeps:
    api_key: str
    user_id: int

agent = Agent('openai:gpt-4o', deps_type=MyDeps)

@agent.tool
async def fetch_data(ctx: RunContext[MyDeps]) -> str:
    return f'User {ctx.deps.user_id}'
```

For `RunContext` fields, injection into system prompts and output validators: load `references/DEPENDENCIES.md`.

### 4. Structured Output

```python
from pydantic import BaseModel
from pydantic_ai import Agent

class CityInfo(BaseModel):
    city: str
    country: str

agent = Agent('openai:gpt-4o', output_type=CityInfo)
result = agent.run_sync('Where were the 2012 Olympics held?')
print(result.output)  # CityInfo(city='London', country='United Kingdom')
```

For union types, plain scalars, `output_validator`, and partial validation: load `references/OUTPUT.md`.

---

## Additional Topics

> For these topics, load the named reference file or follow the doc link — no implementation code is provided here.

| Topic | Reference file | Doc link |
|---|---|---|
| Message history / multi-turn conversations | `references/MESSAGES.md` | <https://ai.pydantic.dev/core-concepts/message-history/index.md> |
| Model / provider setup (all providers) | `references/MODELS.md` | <https://ai.pydantic.dev/models/overview/index.md> |
| Toolsets (`FunctionToolset`, composition) | `references/TOOLS_AND_TOOLSETS.md` | <https://ai.pydantic.dev/tools-toolsets/toolsets/index.md> |
| MCP server integration | `references/MCP.md` | <https://ai.pydantic.dev/mcp/client/index.md> |
| Multi-agent applications | doc link only | <https://ai.pydantic.dev/guides/multi-agent-applications/index.md> |
| Graphs (pydantic-graph) | doc link only | <https://ai.pydantic.dev/graph/graph/index.md> |
| Evals (pydantic-evals) | doc link only | <https://ai.pydantic.dev/evals/evals/index.md> |
| Durable execution | doc link only | <https://ai.pydantic.dev/durable_execution/overview/index.md> |
| Retries | doc link only | <https://ai.pydantic.dev/core-concepts/retries/index.md> |
| Testing (`TestModel`, `override`) | doc link only | <https://ai.pydantic.dev/guides/testing/index.md> |
| Logfire integration | doc link only | <https://ai.pydantic.dev/integrations/logfire/index.md> |
| Native tools (formerly builtin tools) | doc link only | <https://ai.pydantic.dev/tools-toolsets/native-tools/index.md> |
| Streaming | doc link only | <https://ai.pydantic.dev/core-concepts/agent/index.md> |

---

## Agent Behavior Rules

1. **Default to this file** — answer from core concepts first; load only the specific `references/<CONCEPT>.md` relevant to the user's question when more depth is needed.
2. **Never fabricate API details** — always end with "For details, see: \<URL\>" using a link from the official index above.
3. **No implementation code for non-core topics** — return a doc link only for topics listed in the Additional Topics table.
4. **Prefer specificity** — route to the most specific page (e.g., `models/anthropic/index.md`) when the user's question targets a specific provider, not the overview.
5. **Out of scope** — do not debug user code passively, do not generate full production agent implementations, do not answer questions unrelated to the Pydantic AI ecosystem.
Files in this package (9)
  • SKILL.md 5 KB
  • references/AGENT.md 3 KB
  • references/DEPENDENCIES.md 2 KB
  • references/FUNCTION_TOOLS.md 2 KB
  • references/MCP.md 2 KB
  • references/MESSAGES.md 2 KB
  • references/MODELS.md 4 KB
  • references/OUTPUT.md 2 KB
  • references/TOOLS_AND_TOOLSETS.md 3 KB

Versions

The database has no other skills named pydanticai-docs.

Database snapshot: 13.11.2026 · package version 69c11e2c5e42 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100pydantic-ai
    Builds type-safe AI agents in Python with PydanticAI, the agent framework from the Pydantic team. Use when a user asks to create an LLM agent with validated structured output, add tools with dependency injection, stream responses, switch between OpenAI, Anthropic, Gemini or…
  • 100pydantic-ai-agent-creation
    Create PydanticAI agents with type-safe dependencies, structured outputs, and proper configuration. Use when building AI agents, creating chat systems, or integrating LLMs with Pydantic validation.
  • 100pydantic-ai-tool-system
    Register and implement PydanticAI tools with proper context handling, type annotations, and docstrings. Use when adding tool capabilities to agents, implementing function calling, or creating agent actions.
  • 100pydanticai
    Build type-safe AI agents and graph-based workflows with PydanticAI and PydanticGraph. Agent creation, function tools, capabilities, dependency injection, structured output, streaming, multi-agent patterns, testing, evals, and graph state machines. Use whenever you are building…
  • 100building-pydantic-ai-agents
    Build AI agents with Pydantic AI — tools, capabilities, structured output, streaming, testing, and multi-agent patterns. Use when the user mentions Pydantic AI, imports pydantic_ai, or asks to build an AI agent, add tools/capabilities, stream output, define agents from YAML, or test agent behavior.
  • 100pydantic-ai
    Pydantic AI Python agent framework. Covers typed tools, model providers, evals, MCP, UI adapters, and observability. Use when building Python AI agents with Pydantic AI, configuring model providers, implementing typed tools/dependencies, running evals, or integrating MCP…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.