★ OverviewIntermediate11 min
Functional API
Alternative to Graph API using @entrypoint and @task decorators. When to use Functional API vs StateGraph. Simpler syntax for common patterns.
Quick Reference
- →@entrypoint: marks a function as a LangGraph workflow — handles checkpointing, streaming, and human-in-the-loop automatically
- →@task: marks a function as an individual unit of work — checkpointed independently, returns a future
- →entrypoint.final(value=X, save=Y): decouple what the caller receives from what gets saved to the checkpoint
- →Injectable params: previous (last return value), store (long-term memory), writer (custom streaming), config (RunnableConfig)
- →Determinism rule: wrap all randomness and side effects inside @task — not in the entrypoint body
@entrypoint & @task
Functional API: simple decorated functions. StateGraph: explicit graph definition.
A complete workflow with the Functional API
@entrypoint defines the workflow. @task marks individual steps. Each task is independently checkpointed -- if the workflow crashes after research() completes but before summarize() finishes, restarting resumes from the summarize() step. The key insight is that the Functional API gives you the same durability and checkpointing guarantees as StateGraph, but with plain Python function syntax. No state schema, no add_node, no add_edge -- just decorated async functions.