Comparison · Updated 2026-06-18

OpenAI Agents SDK vs LangGraph

Two Python agent frameworks, both open source, both MIT-licensed, both used in production -- and they solve genuinely different problems. The OpenAI Agents SDK is a small, opinionated runtime for shipping single agents with tools and handoffs against OpenAI models. LangGraph is a stateful, graph-shaped execution engine for agents that need branches, retries, and resumable state. Picking the wrong one is expensive: a stateful workflow forced through the SDK becomes a tangle of retry logic; a single-agent loop forced through a graph becomes overengineered. This is the honest side-by-side.

Published 2026-06-18 · ~6 min read · Independent, no paid placements (disclosure)

OpenAI Agents SDK

Opinionated Python SDK from OpenAI. Agent + tools + handoffs + guardrails + tracing -- batteries included for production single-agent workflows.

See alternatives →

LangGraph

State-graph agent framework from the LangChain team. Nodes, edges, persistent state, time-travel debugging -- explicit control flow for stateful agents.

See alternatives →

The short answer

  • Winner for single-agent on OpenAI: OpenAI Agents SDK. Tracing, guardrails, and handoffs are built in.
  • Winner for stateful, branchy, resumable workflows: LangGraph. Graph edges, checkpoints, and persistence are first-class.
  • Winner for learning curve: OpenAI Agents SDK -- ship in 50 lines.
  • Winner for long-running workflows: LangGraph -- checkpoints survive crashes and approvals.
  • Best for: OpenAI Agents SDK for production single agents and triage/handoff shapes; LangGraph for plan-and-execute, retries, and human-in-the-loop.

Snapshot comparison

Before the section-by-section breakdown, the one-screen version.

Dimension OpenAI Agents SDK LangGraph
Primary shapeSingle agent + tools + handoffsStateful graph (nodes + edges)
LanguagePython (TypeScript port exists)Python (JS port exists)
LicenseMITMIT
MaintainerOpenAILangChain Inc.
Model coverageOpenAI-first; others via LiteLLMProvider-agnostic
TracingBuilt-in trace UI, free with usageLangSmith (paid, free tier)
GuardrailsFirst-class input/output guardrailsRoll your own (node-level)
State managementImplicit (conversation history)Explicit, persistable, time-travel
Branching & retriesLimited (handoffs only)First-class graph edges
Resumable runsNo (single-process loop)Yes (checkpoints survive crashes)
Human-in-the-loopManualNative interrupt + resume
Learning curveSmaller -- ship in 50 linesSteeper -- think in graphs
Hosted optionNone official; OpenAI traces hostedLangGraph Platform (paid)
Best forProduction single-agent on OpenAIStateful, branchy, long-running agents

Two different mental models

The right framework depends on which of these reads like your workflow.

OpenAI Agents SDK thinks "one agent with tools". You define an Agent with an instruction prompt, a list of tools, and optionally a handoff target -- another Agent it can transfer the conversation to. The runtime handles the loop: model call → tool call → result → next model call → done. Multi-agent is modelled as handoffs ("transfer this to the specialist"), not as a graph.

LangGraph thinks "state machine with LLM nodes". You define a graph: nodes are functions (often LLM calls), edges are transitions, and state is a typed object passed between nodes. Branching is conditional edges. Retries are loops. Pausing for human approval is a checkpoint. The mental model is closer to a workflow engine than to an agent runtime.

If you find yourself writing "the agent gets a question, calls a search tool, calls a database tool, then answers", that is OpenAI Agents SDK shaped. If you find yourself writing "if the validator passes, continue; otherwise retry with a revised prompt", that is LangGraph shaped.

Use cases -- when each one wins

OpenAI Agents SDK fits when

  • Customer support agent with tools. One agent, knowledge base search + order lookup + refund tool + handoff to a human specialist.
  • Internal Q&A bot over docs. RAG retrieval as a tool, structured output for citations, guardrails for off-topic queries.
  • Triage and routing. Classifies inbound messages and hands off to specialist agents per category.
  • Data enrichment agent. Reads a CRM record, calls enrichment APIs, writes structured results back.
  • Anything where built-in tracing and guardrails matter more than explicit state.

LangGraph fits when

  • Plan-and-execute agents. Planner proposes steps; executor runs them; planner adjusts based on the result.
  • Long-running workflows. Agents that pause for hours or days waiting for human approval, then resume from saved state.
  • Retries and self-correction. Loops that re-prompt with error context until a tool call succeeds.
  • Auditable production agents. Workflows where every transition needs to be inspectable, replayable, and time-travel debuggable.
  • Stateful multi-agent. Multiple specialist agents sharing a typed state object, with explicit handoffs between graph nodes.

Learning curve

OpenAI Agents SDK is friendlier in the first 30 minutes. You learn one concept (Agent), one decorator (@function_tool), and the handoff pattern. Tracing is on by default -- open the OpenAI dashboard, see every run. Errors surface with clear stack traces; tool call mismatches are caught early. For most engineers, time-to-first-working agent is under an hour.

LangGraph is steeper in the first 30 minutes, gentler at month three. You have to think in terms of state schemas, nodes, edges, and conditional routing before you ship anything. The reward arrives when production starts behaving unpredictably: LangGraph gives you the tools to see exactly what happened, replay it, and patch the transition. The SDK gives you a stack trace and a hope.

Practical rule: if the team is shipping a single-agent product on OpenAI models, the SDK clicks instantly. If the team has built workflow engines before (Airflow, Temporal, Step Functions), LangGraph clicks instantly. Pick the mental model that matches the team you already have.

Pricing comparison

Both frameworks are MIT-licensed and free. The real bill is model inference and, optionally, hosted observability or runtime services.

Cost line OpenAI Agents SDK LangGraph
Framework licenceFree (MIT)Free (MIT)
Self-hostingYour infra (any Python host)Your infra (any Python host)
Model inferencePay-per-token (OpenAI primary)Pay-per-token (any provider)
Hosted runtimeNone officialLangGraph Platform: usage-based
ObservabilityIncluded with OpenAI usageLangSmith (paid, generous free tier)
Typical single-agent cost (per 1k turns)~$5-20 on GPT-4o-mini~$5-25 on GPT-4o-mini
Typical long-workflow cost (per 1k runs)Higher (full history per turn)Lower (per-node state slice)
Hidden costsTrace storage at scaleState storage at scale

The pattern: framework cost is zero for both. Model inference dominates. For a tight single-agent loop, the SDK is competitive on cost and saves engineering time on tracing. For long-running, multi-step workflows, LangGraph's per-node state discipline materially reduces token spend at scale.

Final verdict

These two frameworks are not direct substitutes -- they are competing for the same decision. The right call comes down to one question: does my workflow need explicit state and branching, or is it a single-agent loop that benefits from batteries-included tracing and guardrails?

  1. Single-agent loop on OpenAI models: OpenAI Agents SDK wins. Smaller surface, lower ceremony, tracing and guardrails included.
  2. Stateful, branchy, retry-heavy, or resumable: LangGraph wins. The graph model exists for exactly this shape, and persistence keeps long workflows safe.
  3. Neither feels right: the workflow may be multi-agent shaped instead. See the AI Agent Frameworks pillar for the wider landscape, or the best OpenAI Agents SDK alternatives and best LangGraph alternatives shortlists.

Meta-recommendation: a lot of "we need LangGraph" architectures are actually single-agent loops with one or two retry conditions -- shippable as an OpenAI Agents SDK agent with a guardrail and a handoff. Reach for LangGraph when the workflow genuinely needs explicit state: human-in-the-loop pauses, multi-day runs, or branches the SDK cannot model cleanly.

Next reads

FAQ

OpenAI Agents SDK vs LangGraph -- which one should I pick?
If your workflow is "one agent with tools" against OpenAI models and you want tracing and guardrails out of the box, pick the OpenAI Agents SDK. If your workflow has branches, retries, human-in-the-loop pauses, or needs to resume after a crash, pick LangGraph. They are not really substitutes -- one is an opinionated runtime, the other is a control-flow engine.
Is LangGraph better than the OpenAI Agents SDK for production?
Only when the workflow is genuinely stateful or branchy. LangGraph gives you persistence, time-travel debugging, and explicit transitions, which matter when an agent has to recover from a failed tool call or wait days for a human approval. For a straightforward single-agent loop, the OpenAI Agents SDK ships faster, costs less, and includes tracing out of the box.
Is the OpenAI Agents SDK easier to learn than LangGraph?
Yes. The SDK has the smaller surface: Agent, tools, handoffs, guardrails. You can ship a working agent in 50 lines. LangGraph requires thinking in state schemas, nodes, and edges before you ship anything -- closer to writing a state machine than configuring an agent. Most engineers ship a first OpenAI Agents SDK agent in under an hour.
How do token costs compare?
For single-agent workloads they are similar -- both call the same underlying model. The difference appears in multi-step or multi-agent shapes. LangGraph nodes only see the state slice they need, which keeps prompts small across long workflows. The OpenAI Agents SDK keeps the full conversation history per agent, which is fine for short loops but more expensive for long-running runs.
Is the OpenAI Agents SDK only for OpenAI models?
It is OpenAI-first but not OpenAI-only. The SDK supports any model that LiteLLM can reach (Anthropic, Google, Bedrock, Azure, local). In practice, tracing, structured output, and tool calling have the smoothest ergonomics on OpenAI models; cross-provider works but loses some polish.
Can I use the OpenAI Agents SDK and LangGraph together?
In principle yes -- you can wrap an OpenAI Agents SDK agent as a single LangGraph node, using LangGraph for control flow and the SDK for the agent loop. In practice teams pick one. Mixing both adds a second mental model and a second set of failure modes.
Which one wins for stateful or long-running workflows?
LangGraph -- decisively. Checkpoints, persistence, and time-travel debugging are first-class. The OpenAI Agents SDK assumes the agent loop runs to completion in one process; resumable, multi-day workflows are not its shape.
Are both open source?
Yes. Both are MIT-licensed. The OpenAI Agents SDK is open source but tightly aligned with OpenAI as a model provider. LangGraph is open source and provider-agnostic. Neither has commercial restrictions; both are safe to embed in proprietary products.
Best OpenAI Agents SDK alternatives → Best LangGraph alternatives → AI Agent Frameworks pillar →