[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2701":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},2701,"pydantic-ai","pydantic\u002Fpydantic-ai","pydantic","AI Agent Framework, the Pydantic way","https:\u002F\u002Fai.pydantic.dev",null,"Python",17698,2207,112,410,0,17,181,687,113,45,"MIT License",false,"main",[26,27,28,7,29],"agent-framework","genai","llm","python","2026-06-12 02:00:43","\u003Cdiv align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fai.pydantic.dev\u002F\">\n    \u003Cpicture>\n      \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"https:\u002F\u002Fpydantic.dev\u002Fdocs\u002Fai\u002Fimg\u002Fpydantic-ai-dark.svg\">\n      \u003Cimg src=\"https:\u002F\u002Fpydantic.dev\u002Fdocs\u002Fai\u002Fimg\u002Fpydantic-ai-light.svg\" alt=\"Pydantic AI\">\n    \u003C\u002Fpicture>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\u003Cdiv align=\"center\">\n  \u003Ch3>GenAI Agent Framework, the Pydantic way\u003C\u002Fh3>\n\u003C\u002Fdiv>\n\u003Cdiv align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fpydantic\u002Fpydantic-ai\u002Factions\u002Fworkflows\u002Fci.yml?query=branch%3Amain\">\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fpydantic\u002Fpydantic-ai\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg?event=push\" alt=\"CI\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fcoverage-badge.samuelcolvin.workers.dev\u002Fredirect\u002Fpydantic\u002Fpydantic-ai\">\u003Cimg src=\"https:\u002F\u002Fcoverage-badge.samuelcolvin.workers.dev\u002Fpydantic\u002Fpydantic-ai.svg\" alt=\"Coverage\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fpydantic-ai\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fpydantic-ai.svg\" alt=\"PyPI\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fpydantic\u002Fpydantic-ai\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fpyversions\u002Fpydantic-ai.svg\" alt=\"versions\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fpydantic\u002Fpydantic-ai\u002Fblob\u002Fmain\u002FLICENSE\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fpydantic\u002Fpydantic-ai.svg?v\" alt=\"license\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Flogfire.pydantic.dev\u002Fdocs\u002Fjoin-slack\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSlack-Join%20Slack-4A154B?logo=slack\" alt=\"Join Slack\" \u002F>\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n---\n\n**Documentation**: [ai.pydantic.dev](https:\u002F\u002Fai.pydantic.dev\u002F)\n\n---\n\n### \u003Cem>Pydantic AI is a Python agent framework designed to help you quickly, confidently, and painlessly build production grade applications and workflows with Generative AI.\u003C\u002Fem>\n\n\nFastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic Validation](https:\u002F\u002Fdocs.pydantic.dev) and modern Python features like type hints.\n\nYet despite virtually every Python agent framework and LLM library using Pydantic Validation, when we began to use LLMs in [Pydantic Logfire](https:\u002F\u002Fpydantic.dev\u002Flogfire), we couldn't find anything that gave us the same feeling.\n\nWe built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app and agent development.\n\n## Why use Pydantic AI\n\n1. **Built by the Pydantic Team**:\n[Pydantic Validation](https:\u002F\u002Fdocs.pydantic.dev\u002Flatest\u002F) is the validation layer of the OpenAI SDK, the Google ADK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more. _Why use the derivative when you can go straight to the source?_ :smiley:\n\n2. **Model-agnostic**:\nSupports virtually every [model](https:\u002F\u002Fai.pydantic.dev\u002Fmodels\u002Foverview) and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Vertex AI, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel, Nebius, OVHcloud, Alibaba Cloud, SambaNova, and Outlines. If your favorite model or provider is not listed, you can easily implement a [custom model](https:\u002F\u002Fai.pydantic.dev\u002Fmodels\u002Foverview#custom-models).\n\n3. **Seamless Observability**:\nTightly [integrates](https:\u002F\u002Fai.pydantic.dev\u002Flogfire) with [Pydantic Logfire](https:\u002F\u002Fpydantic.dev\u002Flogfire), our general-purpose OpenTelemetry observability platform, for real-time debugging, evals-based performance monitoring, and behavior, tracing, and cost tracking. If you already have an observability platform that supports OTel, you can [use that too](https:\u002F\u002Fai.pydantic.dev\u002Flogfire#alternative-observability-backends).\n\n4. **Fully Type-safe**:\nDesigned to give your IDE or AI coding agent as much context as possible for auto-completion and [type checking](https:\u002F\u002Fai.pydantic.dev\u002Fagents#static-type-checking), moving entire classes of errors from runtime to write-time for a bit of that Rust \"if it compiles, it works\" feel.\n\n5. **Powerful Evals**:\nEnables you to systematically test and [evaluate](https:\u002F\u002Fai.pydantic.dev\u002Fevals) the performance and accuracy of the agentic systems you build, and monitor the performance over time in Pydantic Logfire.\n\n6. **Extensible by Design**:\nBuild agents from composable [capabilities](https:\u002F\u002Fai.pydantic.dev\u002Fcapabilities) that bundle tools, hooks, instructions, and model settings into reusable units. Use built-in capabilities for [web search](https:\u002F\u002Fai.pydantic.dev\u002Fcapabilities#provider-adaptive-tools), [thinking](https:\u002F\u002Fai.pydantic.dev\u002Fcapabilities#thinking), and [MCP](https:\u002F\u002Fai.pydantic.dev\u002Fcapabilities#provider-adaptive-tools), pick from the [Pydantic AI Harness](https:\u002F\u002Fai.pydantic.dev\u002Fharness\u002Foverview) capability library, build your own, or install [third-party capability packages](https:\u002F\u002Fai.pydantic.dev\u002Fextensibility). Define agents entirely in [YAML\u002FJSON](https:\u002F\u002Fai.pydantic.dev\u002Fagent-spec) — no code required.\n\n7. **MCP, A2A, and UI**:\nIntegrates the [Model Context Protocol](https:\u002F\u002Fai.pydantic.dev\u002Fmcp\u002Foverview), [Agent2Agent](https:\u002F\u002Fai.pydantic.dev\u002Fa2a), and various [UI event stream](https:\u002F\u002Fai.pydantic.dev\u002Fui\u002Foverview) standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.\n\n8. **Human-in-the-Loop Tool Approval**:\nEasily lets you flag that certain tool calls [require approval](https:\u002F\u002Fai.pydantic.dev\u002Fdeferred-tools#human-in-the-loop-tool-approval) before they can proceed, possibly depending on tool call arguments, conversation history, or user preferences.\n\n9. **Durable Execution**:\nEnables you to build [durable agents](https:\u002F\u002Fai.pydantic.dev\u002Fdurable_execution\u002Foverview\u002F) that can preserve their progress across transient API failures and application errors or restarts, and handle long-running, asynchronous, and human-in-the-loop workflows with production-grade reliability.\n\n10. **Streamed Outputs**:\nProvides the ability to [stream](https:\u002F\u002Fai.pydantic.dev\u002Foutput#streamed-results) structured output continuously, with immediate validation, ensuring real time access to generated data.\n\n11. **Graph Support**:\nProvides a powerful way to define [graphs](https:\u002F\u002Fai.pydantic.dev\u002Fgraph) using type hints, for use in complex applications where standard control flow can degrade to spaghetti code.\n\nRealistically though, no list is going to be as convincing as [giving it a try](#next-steps) and seeing how it makes you feel!\n\n## Hello World Example\n\nHere's a minimal example of Pydantic AI:\n\n```python\nfrom pydantic_ai import Agent\n\n# Define a very simple agent including the model to use, you can also set the model when running the agent.\nagent = Agent(\n    'anthropic:claude-sonnet-4-6',\n    # Register static instructions using a keyword argument to the agent.\n    # For more complex dynamically-generated instructions, see the example below.\n    instructions='Be concise, reply with one sentence.',\n)\n\n# Run the agent synchronously, conducting a conversation with the LLM.\nresult = agent.run_sync('Where does \"hello world\" come from?')\nprint(result.output)\n\"\"\"\nThe first known use of \"hello, world\" was in a 1974 textbook about the C programming language.\n\"\"\"\n```\n\n_(This example is complete, it can be run \"as is\", assuming you've [installed the `pydantic_ai` package](https:\u002F\u002Fai.pydantic.dev\u002Finstall))_\n\nThe exchange will be very short: Pydantic AI will send the instructions and the user prompt to the LLM, and the model will return a text response.\n\nNot very interesting yet, but we can easily add [tools](https:\u002F\u002Fai.pydantic.dev\u002Ftools), [dynamic instructions](https:\u002F\u002Fai.pydantic.dev\u002Fagents#instructions), [structured outputs](https:\u002F\u002Fai.pydantic.dev\u002Foutput), or composable [capabilities](https:\u002F\u002Fai.pydantic.dev\u002Fcapabilities) to build more powerful agents.\n\nHere's the same agent with [thinking](https:\u002F\u002Fai.pydantic.dev\u002Fcapabilities#thinking) and [web search](https:\u002F\u002Fai.pydantic.dev\u002Fcapabilities#provider-adaptive-tools) capabilities:\n\n```python\nfrom pydantic_ai import Agent\nfrom pydantic_ai.capabilities import Thinking, WebSearch\n\nagent = Agent(\n    'anthropic:claude-sonnet-4-6',\n    instructions='Be concise, reply with one sentence.',\n    capabilities=[Thinking(), WebSearch()],\n)\n\nresult = agent.run_sync('What was the mass of the largest meteorite found this year?')\nprint(result.output)\n```\n\n## Tools & Dependency Injection Example\n\nHere is a concise example using Pydantic AI to build a support agent for a bank:\n\n**(Better documented example [in the docs](https:\u002F\u002Fai.pydantic.dev\u002F#tools-dependency-injection-example))**\n\n```python\nfrom dataclasses import dataclass\n\nfrom pydantic import BaseModel, Field\nfrom pydantic_ai import Agent, RunContext\n\nfrom bank_database import DatabaseConn\n\n\n# SupportDependencies is used to pass data, connections, and logic into the model that will be needed when running\n# instructions and tool functions. Dependency injection provides a type-safe way to customise the behavior of your agents.\n@dataclass\nclass SupportDependencies:\n    customer_id: int\n    db: DatabaseConn\n\n\n# This Pydantic model defines the structure of the output returned by the agent.\nclass SupportOutput(BaseModel):\n    support_advice: str = Field(description='Advice returned to the customer')\n    block_card: bool = Field(description=\"Whether to block the customer's card\")\n    risk: int = Field(description='Risk level of query', ge=0, le=10)\n\n\n# This agent will act as first-tier support in a bank.\n# Agents are generic in the type of dependencies they accept and the type of output they return.\n# In this case, the support agent has type `Agent[SupportDependencies, SupportOutput]`.\nsupport_agent = Agent(\n    'openai:gpt-5.2',\n    deps_type=SupportDependencies,\n    # The response from the agent will be guaranteed to be a SupportOutput,\n    # if validation fails the agent is prompted to try again.\n    output_type=SupportOutput,\n    instructions=(\n        'You are a support agent in our bank, give the '\n        'customer support and judge the risk level of their query.'\n    ),\n)\n\n\n# Dynamic instructions can make use of dependency injection.\n# Dependencies are carried via the `RunContext` argument, which is parameterized with the `deps_type` from above.\n# If the type annotation here is wrong, static type checkers will catch it.\n@support_agent.instructions\nasync def add_customer_name(ctx: RunContext[SupportDependencies]) -> str:\n    customer_name = await ctx.deps.db.customer_name(id=ctx.deps.customer_id)\n    return f\"The customer's name is {customer_name!r}\"\n\n\n# The `tool` decorator let you register functions which the LLM may call while responding to a user.\n# Again, dependencies are carried via `RunContext`, any other arguments become the tool schema passed to the LLM.\n# Pydantic is used to validate these arguments, and errors are passed back to the LLM so it can retry.\n@support_agent.tool\nasync def customer_balance(\n        ctx: RunContext[SupportDependencies], include_pending: bool\n) -> float:\n    \"\"\"Returns the customer's current account balance.\"\"\"\n    # The docstring of a tool is also passed to the LLM as the description of the tool.\n    # Parameter descriptions are extracted from the docstring and added to the parameter schema sent to the LLM.\n    balance = await ctx.deps.db.customer_balance(\n        id=ctx.deps.customer_id,\n        include_pending=include_pending,\n    )\n    return balance\n\n\n...  # In a real use case, you'd add more tools and a longer system prompt\n\n\nasync def main():\n    deps = SupportDependencies(customer_id=123, db=DatabaseConn())\n    # Run the agent asynchronously, conducting a conversation with the LLM until a final response is reached.\n    # Even in this fairly simple case, the agent will exchange multiple messages with the LLM as tools are called to retrieve an output.\n    result = await support_agent.run('What is my balance?', deps=deps)\n    # The `result.output` will be validated with Pydantic to guarantee it is a `SupportOutput`. Since the agent is generic,\n    # it'll also be typed as a `SupportOutput` to aid with static type checking.\n    print(result.output)\n    \"\"\"\n    support_advice='Hello John, your current account balance, including pending transactions, is $123.45.' block_card=False risk=1\n    \"\"\"\n\n    result = await support_agent.run('I just lost my card!', deps=deps)\n    print(result.output)\n    \"\"\"\n    support_advice=\"I'm sorry to hear that, John. We are temporarily blocking your card to prevent unauthorized transactions.\" block_card=True risk=8\n    \"\"\"\n```\n\n## Next Steps\n\nTo try Pydantic AI for yourself, [install it](https:\u002F\u002Fai.pydantic.dev\u002Finstall) and follow the instructions [in the examples](https:\u002F\u002Fai.pydantic.dev\u002Fexamples\u002Fsetup).\n\nRead the [docs](https:\u002F\u002Fai.pydantic.dev\u002Fagents\u002F) to learn more about building applications with Pydantic AI.\n\nRead the [API Reference](https:\u002F\u002Fai.pydantic.dev\u002Fapi\u002Fagent\u002F) to understand Pydantic AI's interface.\n\nJoin [Slack](https:\u002F\u002Flogfire.pydantic.dev\u002Fdocs\u002Fjoin-slack\u002F) or file an issue on [GitHub](https:\u002F\u002Fgithub.com\u002Fpydantic\u002Fpydantic-ai\u002Fissues) if you have any questions.\n","Pydantic AI 是一个基于 Python 的生成式人工智能代理框架，旨在帮助开发者快速、自信且轻松地构建生产级别的应用程序和工作流。该项目利用了 Pydantic 验证的强大功能以及现代 Python 特性如类型提示，为 GenAI 应用程序的开发带来了类似 FastAPI 的高效体验。其核心特点包括由 Pydantic 团队直接支持的模型验证机制与广泛的模型及提供商兼容性（涵盖OpenAI、Anthropic等主流平台）。适用于需要集成生成式AI能力的各种场景，如自动化客服系统、内容创作助手或复杂的多步骤任务处理流程中。",2,"2026-06-11 02:50:56","top_language"]