In short.
This guide teaches Python developers to build and visualize typed workflows with pydantic-graph, but its additional structure is most useful when branching control flow is already difficult. It connects GraphBuilder, asynchronous node classes, shared state and declared transitions through arithmetic, vending-machine and AI email-review examples. The library can be used without Pydantic AI. The page does not establish package versions, licensing, prices or durable recovery behavior, and its examples have not been executed for this report.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete selected Graphs page at [https://pydantic.dev/docs/ai/graph/graph/index.md], including its documentation-navigation notices, installation instructions, explanations, code examples and diagrams. Linked pages, including the documentation index, API references, builder guide and multi-agent guide, are excluded. No package installation or code execution was performed. Example outputs, runtime behavior, compatibility, performance and recovery guarantees remain unverified.
The overview
Resource identity
Graphs is a documentation guide for pydantic-graph, an asynchronous Python graph and finite state machine library developed alongside Pydantic AI. A finite state machine describes the stages a process can occupy and the transitions allowed between them. The guide is available at [https://pydantic.dev/docs/ai/graph/graph/index.md].
The library itself has no dependency on pydantic-ai and can support ordinary software workflows as well as generative AI applications. The resource covered here is this guide, rather than the complete library documentation.
Practical assessment
The guide is useful when a workflow needs explicit branches, loops, shared state and a diagram that reflects its declared transitions. It explains these ideas with concrete code before introducing model calls.
Its main tradeoff is setup and typing complexity. The documentation itself recommends considering plain Python and simpler multi-agent approaches first. The examples support understanding the design, but do not establish reliability, performance or production readiness.
Who it suits
The strongest fit is Python developers whose workflow logic has become difficult to follow through ordinary function calls and conditionals. Developers building agents may find the draft-and-review loop relevant, while developers outside AI can use the arithmetic and vending-machine examples.
Beginners will benefit from familiarity with dataclasses, async def and await, type unions and generic type parameters. Experienced developers get concrete details about transition inference, typed state, dependency injection and graph construction.
Documented capabilities
The page demonstrates asynchronous execution, conditional branches, loops, optional mutable state, typed inputs and outputs, and injected dependencies. Dependencies are supplied objects, such as an executor, that nodes access through their execution context.
It describes graph.iter() for inspecting execution, overriding the next step or driving execution manually, although detailed iteration examples are on a linked page. Built graphs can produce Mermaid stateDiagram-v2 source through graph.render() or print(graph), with configurable layout direction.
Using it
Requirements
The core examples require Python and pydantic-graph. The page states that pydantic-ai includes pydantic-graph as a required dependency, while pydantic-ai-slim offers it as an optional dependency. A minimum Python version, exact package versions and supported operating systems are not specified.
Example requirements vary. The vending machine imports rich.prompt.Prompt; the AI example imports pydantic and pydantic_ai and configures provider-backed agents. Provider credentials, model availability and complete dependency configuration are not explained on this page.
How it works
Each BaseNode subclass represents a workflow stage. Its asynchronous run method performs work and returns either another node or End with the final value. The library reads the method's return annotation to determine allowed outgoing transitions; the guide says these transitions also inform diagrams and are enforced at runtime.
GraphBuilder assembles registered nodes, step functions and connecting edges into an executable Graph. GraphRunContext exposes shared state and dependencies to nodes, while StepContext supplies context to step functions. Node generic parameters describe state, dependencies and, for terminating nodes, the graph's return type.
Setup described by the guide
The direct installation commands are pip install pydantic-graph and uv add pydantic-graph. The examples then define node classes, declare the necessary GraphBuilder types, register nodes with g.node(), connect g.start_node to an entry step and call g.build().
Execution uses await graph.run(), with state, dependencies or inputs passed as needed. The page notes that its examples need an asyncio import and an asyncio.run(main()) entry point. These are documented setup instructions; installation and execution have not been verified.
Examples and expected behavior
The smallest complete example alternates between DivisibleBy5 and Increment nodes until the number is divisible by five. The documentation shows input 4 producing 5. The vending-machine example adds shared balance and product state, with branches for insufficient funds and invalid products.
The AI example asks one agent to draft a welcome email and another to review whether it references the user's interests. EmailRequiresWrite sends feedback back to the writer; EmailOk allows the graph to return the email. Shared state preserves the writer's message history. These are documented examples and expected outputs, not independently observed results.
Assessment & evidence
Limitations and unknowns
The guide introduces substantial structure for small workflows. Type hints describe permitted transitions, but this page does not establish correctness of business logic or the quality of model-generated emails.
The introduction mentions resumable transitions, but the page does not demonstrate persistent checkpoints or recovery after process failure. The AI loop shows no explicit revision cap or provider-error handling. Performance, concurrency behavior and deployment operation are not assessed. The process-pool example is explicitly described as too trivial to benefit from that optimization.
Why the design may help
The design connects transition declarations, execution checks and diagrams through node return annotations. This could make a branching workflow easier to inspect because the declared destinations also inform its visual representation. That is a design inference, not a measured productivity result.
Its value therefore depends on the problem: explicit state and repeated transitions may justify graph construction, while a short sequence of calls may gain little. The examples illustrate this distinction without providing comparative benchmarks.
Alternatives discussed
The page recommends considering plain Python, Pydantic AI agents and simpler multi-agent patterns before adopting a graph. Ordinary functions and conditionals are a plausible starting point when explicit transition modeling and diagrams are unnecessary.
The linked multi-agent guide is outside this page's scope. Other frameworks and their relative features, costs or performance are not assessed by the supplied evidence.
Evidence and its strength
The evidence is the complete Graphs documentation page at [https://pydantic.dev/docs/ai/graph/graph/index.md]. Its source revision is sha256:b20a0ace2200a07ae8e373c7fd093f87b374dbb3286d7545c1eae2b60f8cef17.
It supports the described API structure and intended example behavior through explanations, code and diagrams. It supplies no independent execution results, benchmarks or deployment evidence. Linked documentation and package contents are outside the supplied evidence.
Access & freshness
Costs
The page supplies no library price, support pricing or model rates, so monetary costs are unknown. The arithmetic and vending-machine examples contain no model calls.
The AI example calls both a writer and a reviewer. Further revisions introduce further calls, and no explicit revision limit appears in the example. Token consumption, provider charges and total cost are not established.
License and reuse
The supplied page contains no explicit license terms for the library, documentation or example code. Permission to redistribute these materials and applicable commercial-use conditions are therefore unknown from this evidence. Installation instructions alone do not establish reuse rights.
Freshness and version context
The documentation was captured on 14 November 2026 at 16:34:49.240 UTC. The supplied page gives no publication date, update date or pydantic-graph release number.
The examples use GraphBuilder, g.node() and an entry step connected from g.start_node. Their compatibility with any particular installed release is unknown. The capture date also does not confirm availability of the model identifiers shown in the AI example.
How to evaluate the fit
Start by identifying whether your workflow needs explicit states, branches or repeated transitions. If it does, the arithmetic example provides a small introduction before adding shared state or AI agents.
Before adopting the approach, establish compatible package versions and license terms. For a model-backed workflow, also establish provider configuration, spending limits, a revision cap and failure behavior. If recovery after interruption matters, consult the relevant documentation because this page does not demonstrate durable recovery.
