You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
PydanticAI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI.
27
+
Pydantic AI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI.
28
28
29
-
FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of[Pydantic](https://docs.pydantic.dev).
29
+
FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of[Pydantic Validation](https://docs.pydantic.dev).
30
30
31
-
Similarly, virtually every agent framework and LLM library in Python uses Pydantic, yet when we began to use LLMs in[Pydantic Logfire](https://pydantic.dev/logfire), we couldn't find anything that gave us the same feeling.
31
+
Similarly, virtually every agent framework and LLM library in Python uses Pydantic Validation, yet when we began to use LLMs in[Pydantic Logfire](https://pydantic.dev/logfire), we couldn't find anything that gave us the same feeling.
32
32
33
-
We builtPydanticAI with one simple aim: to bring that FastAPI feeling to GenAI app development.
33
+
We builtPydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app development.
34
34
35
-
##Why usePydanticAI
35
+
##Why usePydantic AI
36
36
37
-
*__Builtby the PydanticTeam__
38
-
Built by the team behind[Pydantic](https://docs.pydantic.dev/latest/) (the validation layer of the OpenAI SDK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more).
37
+
-**Builtby the PydanticTeam**
38
+
Built by the team behind[Pydantic Validation](https://docs.pydantic.dev/latest/) (the validation layer of the OpenAI SDK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more).
39
39
40
-
*__Model-agnostic__
41
-
Supports OpenAI, Anthropic, Gemini, Deepseek, Ollama, Groq, Cohere, and Mistral, and there is a simple interface to implement support for[other models](https://ai.pydantic.dev/models/).
40
+
-**Model-agnostic**
41
+
Supports OpenAI, Anthropic, Gemini, Deepseek, Ollama, Groq, Cohere, and Mistral, and there is a simple interface to implement support for[other models](https://ai.pydantic.dev/models/).
42
42
43
-
*__PydanticLogfireIntegration__
44
-
Seamlessly[integrates](https://ai.pydantic.dev/logfire/) with[Pydantic Logfire](https://pydantic.dev/logfire) for real-time debugging, performance monitoring, and behavior tracking of your LLM-powered applications.
43
+
-**PydanticLogfireIntegration**
44
+
Seamlessly[integrates](https://ai.pydantic.dev/logfire/) with[Pydantic Logfire](https://pydantic.dev/logfire) for real-time debugging, performance monitoring, and behavior tracking of your LLM-powered applications.
45
45
46
-
*__Type-safe__
47
-
Designed to make[type checking](https://ai.pydantic.dev/agents/#static-type-checking) as powerful and informative as possible for you.
46
+
-**Type-safe**
47
+
Designed to make[type checking](https://ai.pydantic.dev/agents/#static-type-checking) as powerful and informative as possible for you.
48
48
49
-
*__Python-centricDesign__
50
-
Leverages Python's familiar control flow and agent composition to build your AI-driven projects, making it easy to apply standard Python best practices you'd use in any other (non-AI) project.
49
+
-**Python-centricDesign**
50
+
Leverages Python's familiar control flow and agent composition to build your AI-driven projects, making it easy to apply standard Python best practices you'd use in any other (non-AI) project.
51
51
52
-
*__Structured Responses__
53
-
Harnesses the power of[Pydantic](https://docs.pydantic.dev/latest/) to[validate and structure](https://ai.pydantic.dev/output/#structured-output) model outputs, ensuring responses are consistent across runs.
52
+
-**Structured Responses**
53
+
Harnesses the power of[Pydantic Validation](https://docs.pydantic.dev/latest/) to[validate and structure](https://ai.pydantic.dev/output/#structured-output) model outputs, ensuring responses are consistent across runs.
54
54
55
-
*__DependencyInjectionSystem__
56
-
Offers an optional[dependency injection](https://ai.pydantic.dev/dependencies/) system to provide data and services to your agent's[system prompts](https://ai.pydantic.dev/agents/#system-prompts),[tools](https://ai.pydantic.dev/tools/) and[output validators](https://ai.pydantic.dev/output/#output-validator-functions).
57
-
This is useful for testing and eval-driven iterative development.
55
+
-**DependencyInjectionSystem**
56
+
Offers an optional[dependency injection](https://ai.pydantic.dev/dependencies/) system to provide data and services to your agent's[system prompts](https://ai.pydantic.dev/agents/#system-prompts),[tools](https://ai.pydantic.dev/tools/) and[output validators](https://ai.pydantic.dev/output/#output-validator-functions).
57
+
This is useful for testing and eval-driven iterative development.
58
58
59
-
*__Streamed Responses__
60
-
Provides the ability to[stream](https://ai.pydantic.dev/output/#streamed-results) LLM outputs continuously, with immediate validation, ensuring rapid and accurate outputs.
59
+
-**Streamed Responses**
60
+
Provides the ability to[stream](https://ai.pydantic.dev/output/#streamed-results) LLM outputs continuously, with immediate validation, ensuring rapid and accurate outputs.
61
61
62
-
*__Graph Support__
63
-
[Pydantic Graph](https://ai.pydantic.dev/graph) provides a powerful way to define graphs using typing hints, this is useful in complex applications where standard control flow can degrade to spaghetti code.
62
+
-**Graph Support**
63
+
[Pydantic Graph](https://ai.pydantic.dev/graph) provides a powerful way to define graphs using typing hints, this is useful in complex applications where standard control flow can degrade to spaghetti code.
64
64
65
65
##Hello World Example
66
66
67
-
Here's a minimal example ofPydanticAI:
67
+
Here's a minimal example ofPydantic AI:
68
68
69
69
```python
70
70
from pydantic_aiimport Agent
@@ -78,7 +78,7 @@ agent = Agent(
78
78
)
79
79
80
80
# Run the agent synchronously, conducting a conversation with the LLM.
81
-
# Here the exchange should be very short:PydanticAI will send the system prompt and the user query to the LLM,
81
+
# Here the exchange should be very short:Pydantic AI will send the system prompt and the user query to the LLM,
82
82
# the model will return a text response. See below for a more complex run.
83
83
result= agent.run_sync('Where does "hello world" come from?')
84
84
print(result.output)
@@ -93,7 +93,7 @@ Not very interesting yet, but we can easily add "tools", dynamic system prompts,
93
93
94
94
##Tools & Dependency Injection Example
95
95
96
-
Here is a concise example usingPydanticAI to build a support agent for a bank:
96
+
Here is a concise example usingPydantic AI to build a support agent for a bank:
97
97
98
98
**(Better documented example[in the docs](https://ai.pydantic.dev/#tools-dependency-injection-example))**
99
99
@@ -187,8 +187,8 @@ async def main():
187
187
188
188
##Next Steps
189
189
190
-
To tryPydanticAI yourself, follow the instructions[in the examples](https://ai.pydantic.dev/examples/).
190
+
To tryPydantic AI yourself, follow the instructions[in the examples](https://ai.pydantic.dev/examples/).
191
191
192
-
Read the[docs](https://ai.pydantic.dev/agents/) to learn more about building applications withPydanticAI.
192
+
Read the[docs](https://ai.pydantic.dev/agents/) to learn more about building applications withPydantic AI.
193
193
194
-
Read the[API Reference](https://ai.pydantic.dev/api/agent/) to understandPydanticAI's interface.
194
+
Read the[API Reference](https://ai.pydantic.dev/api/agent/) to understandPydantic AI's interface.
Copy file name to clipboardExpand all lines: docs/a2a.md
+8-9Lines changed: 8 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ communication and interoperability between AI agents, regardless of the framewor
5
5
6
6
At Pydantic, we built the[FastA2A](#fasta2a) library to make it easier to implement the A2A protocol in Python.
7
7
8
-
We also built a convenience method that exposePydanticAI agents as A2A servers - let's have a quick look at how to use it:
8
+
We also built a convenience method that exposePydantic AI agents as A2A servers - let's have a quick look at how to use it:
9
9
10
10
```py {title="agent_to_a2a.py" hl_lines="4"}
11
11
from pydantic_aiimport Agent
@@ -18,12 +18,12 @@ _You can run the example with `uvicorn agent_to_a2a:app --host 0.0.0.0 --port 80
18
18
19
19
This will expose the agent as an A2A server, and you can start sending requests to it.
20
20
21
-
See more about[exposingPydanticAIagents as A2A servers](#pydanticai-agent-to-a2a-server).
21
+
See more about[exposingPydantic AIagents as A2A servers](#pydantic-ai-agent-to-a2a-server).
22
22
23
23
##FastA2A
24
24
25
25
**FastA2A** is an agentic framework agnostic implementation of the A2A protocol in Python.
26
-
The library is designed to be used with any agentic framework, and is**not exclusive toPydanticAI**.
26
+
The library is designed to be used with any agentic framework, and is**not exclusive toPydantic AI**.
27
27
28
28
###Design
29
29
@@ -75,8 +75,7 @@ The [`Storage`][fasta2a.Storage] component serves two purposes:
75
75
76
76
This design allows for agents to store rich internal state (e.g., tool calls, reasoning traces) as well as store task-specific A2A-formatted messages and artifacts.
77
77
78
-
For example, a PydanticAI agent might store its complete internal message format (including tool calls and responses) in the context storage, while storing only the A2A-compliant messages in the task history.
79
-
78
+
For example, a Pydantic AI agent might store its complete internal message format (including tool calls and responses) in the context storage, while storing only the A2A-compliant messages in the task history.
80
79
81
80
###Installation
82
81
@@ -92,15 +91,15 @@ The only dependencies are:
92
91
-[pydantic](https://pydantic.dev): to validate the request/response messages
93
92
-[opentelemetry-api](https://opentelemetry-python.readthedocs.io/en/latest): to provide tracing capabilities
94
93
95
-
You can installPydanticAI with the`a2a` extra to include**FastA2A**:
94
+
You can installPydantic AI with the`a2a` extra to include**FastA2A**:
96
95
97
96
```bash
98
97
pip/uv-add'pydantic-ai-slim[a2a]'
99
98
```
100
99
101
-
###PydanticAI Agent to A2A Server
100
+
###Pydantic AI Agent to A2A Server
102
101
103
-
To expose aPydanticAI agent as an A2A server, you can use the`to_a2a` method:
102
+
To expose aPydantic AI agent as an A2A server, you can use the`to_a2a` method: