Quick decision guide
Use the Graph API when you need:- Complex workflow visualization for debugging and documentation
- Explicit state management with shared data across multiple nodes
- Conditional branching with multiple decision points
- Parallel execution paths that need to merge later
- Team collaboration where visual representation aids understanding
- Minimal code changes to existing procedural code
- Standard control flow (if/else, loops, function calls)
- Function-scoped state without explicit state management
- Rapid prototyping with less boilerplate
- Linear workflows with simple branching logic
Detailed comparison
When to use the Graph API
The Graph API uses a declarative approach where you define nodes, edges, and shared state to create a visual graph structure. 1. Complex decision trees and branching logic When your workflow has multiple decision points that depend on various conditions, the Graph API makes these branches explicit and easy to visualize.When to use the Functional API
The Functional API uses an imperative approach that integrates LangGraph features into standard procedural code. 1. Existing procedural code When you have existing code that uses standard control flow and want to add LangGraph features with minimal refactoring.Combining both APIs
You can use both APIs together in the same application. This is useful when different parts of your system have different requirements.Migration between APIs
From Functional to Graph API
When your functional workflow grows complex, you can migrate to the Graph API:From Graph to Functional API
When your graph becomes overly complex for simple linear processes:Summary
Choose the Graph API when you need explicit control over workflow structure, complex branching, parallel processing, or team collaboration benefits. Choose the Functional API when you want to add LangGraph features to existing code with minimal changes, have simple linear workflows, or need rapid prototyping capabilities. Both APIs provide the same core LangGraph features (persistence, streaming, human-in-the-loop, memory) but package them in different paradigms to suit different development styles and use cases.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.