5 phút đọc
pydantic/pydantic-ai: How Python does AI. Agents, realtime voice, image generation, embeddings. Every model, eve – Repository pydantic/pydantic-ai. Mô tả: How Python does AI. Agents, realtime voice, image generation, embeddings. Every model, every interface, typed end to end.. 20407 stars, 2861 forks, ngôn ngữ chính Python, cập nhật 2026-10-04.
1. Repository làm gì?
Agents, realtime voice, image generation, embeddings. Every model, every interface, typed end to end.
Pydantic AI is the Python AI SDK: a typed, extensible agent loop with every model a string swap away. The same agent runs everywhere you need it: behind a web frontend, in the terminal, on a voice call, on a durable background queue, in GitHub Actions, or as a plain object you call run() on. Image generation and embeddings come in the same box; Pydantic Graph and Pydantic Evals are separate packages, for typed control flow and for testing agent behavior the way pytest tests code.
Pydantic AI Harness has everything an agent needs for complex, long-running work, snapped on as capabilities, from memory, guardrails, and sub-agents to planning, context management, and persistence, up to a complete coding agent.
Pydantic Logfire is the AI observability platform that sees your whole app, not just the LLM calls, and the Pydantic AI Gateway is one key for every model with real-time cost monitoring and budget control; the Gateway self-hosts if you would rather, and our instrumentation is plain OpenTelemetry, so any backend you already run works. Underneath both, genai-prices keeps model pricing current, and Monty is the sandboxed Python interpreter that runs model-written code.
View the complete documentation at pydantic.dev/docs/ai.
From simple typed data extraction to complex, long-running multi-agent collaboration, Pydantic AI and Pydantic AI Harness have got you covered.
2. Dữ liệu và cấu trúc đáng chú ý
A complete coding agent in your terminal: workspace-rooted file access, allowlisted shell, repo orientation, planning, and context management that survives long sessions. Here with web search and a second-opinion advisor snapped on alongside:
Coder is a regular combined capability, not a black box: use it whole, or use the blocks it bundles directly; the two are equivalent:
Run the file and you're chatting with the agent in your terminal. To try it before writing any code, run the exported coder_agent with clai (the Pydantic AI CLI), via uvx:
Build this → Coder, from the Harness
Run it on GitHub → GitHub Agentic Workflows, on issues, pull requests or a schedule
Give the agent an output type and tools, and every run comes back validated and typed:
The @agent.tool function receives a RunContext that carries your dependencies in; the rest of its signature and its docstring become the tool schema, arguments are validated before your code runs, and the run is guaranteed to return a Sentiment, so your IDE, type checker, and the LLM all agree on the returned type.
3. Khả năng ứng dụng và giới hạn
Build this → Agents, Function Tools, and Structured Output
Attach TemporalDurability and the same agent runs inside a Temporal workflow under durable execution: every model and tool call becomes a durable activity, so a run working through a background queue survives restarts, failures, and long waits:
DBOS and Prefect attach the same way, first-party and co-maintained, with Restate, AWS Lambda, Kitaru, Airflow, and Absurd integrations besides.
Put the same agent on a live voice session, tools and capabilities included:
The model calls your tools mid-conversation while it keeps talking, and every session is instrumented; voice is just another frontend, on OpenAI Realtime, Gemini Live, Azure, and xAI Grok Voice.
Generate an image with a dedicated image model, no agent run required:
That standalone image API is for when your application decides; when an agent run decides, there is provider-native generation with output_type=BinaryImage for a typed image output, and the ImageGeneration capability with its fallbacks for models that generate no images of their own.
Tip: Add two lines before any of these agents runs, and every model call and tool call shows up in Pydantic Logfire. Logfire has a free tier that needs no credit card, and you can sign up with just a GitHub account. Run uvx logfire auth and uvx logfire projects new once first, or point your coding agent at the Logfire setup skill to do it for you. The Logfire guide has the details, and any OpenTelemetry backend works instead.
Any model, one Python API. Virtually every model and provider (OpenAI, Anthropic, Google, Bedrock, Azure AI Foundry, Groq, Mistral, xAI, Ollama, and dozens more), swappable with a string, or through the Pydantic AI Gateway: one key for all of them, with failover and cost monitoring built in. No flagship feature is locked to one vendor.
Số liệu repository có thể thay đổi; nên mở liên kết nguồn để kiểm tra README, giấy phép và trạng thái phát hành.
Nguồn tham khảo: Xem bài gốc