OpenAI Agents API vs LangGraph

The OpenAI Agents API is a managed service: OpenAI runs the Codex harness, keeps session state and can provide a sandbox, while your app sends tasks and handles events. LangGraph is a library you run yourself, with full control over graph, state and model choice. The trade is managed convenience on OpenAI models versus control and portability.

Facts side by side

OpenAI Agents API vs LangGraph. Data as of 2026-09-30.
Fact OpenAI Agents API LangGraph
What it is (source) An OpenAI-managed API that gives an application access to the Codex harness; OpenAI manages sessions, orchestration, context compaction and recovery. An MIT-licensed Python library: a graph runtime you run in your own process.
Where the agent loop runs (source) On OpenAI's side (a managed Codex harness). Your application sends input and receives events. In your application, or on Agent Server if you deploy through LangSmith.
State between tasks (source) Saved session configuration, turns and items, kept by OpenAI; a session can be resumed. Checkpoints of graph state per thread, stored by a checkpointer you choose.
Execution environment (source) OpenAI-hosted sandbox, self-hosted sandbox connected through an executor, or none. Whatever your code runs in; no sandbox is provided by the library.
Multi-agent model (source) The harness breaks work into subtasks and delegates to subagents (multi_agent setting with a concurrency limit). You compose graphs: subgraphs as nodes, conditional edges, parallel branches.
MCP (source) The harness connects to MCP servers configured on the agent. Agent Server exposes LangGraph agents as MCP tools at /mcp (evidence on the LangGraph tool page).
Pricing (source) Model usage at the selected model's API rates; OpenAI tools and hosted sandboxes at their standard rates. Library is free; LangSmith Deployment is a paid plan feature.
API status (source) Exposed under the beta namespace of the OpenAI SDK (client.beta.agents). v1 released; the v1 release notes say graph primitives and the execution model were kept unchanged (source on the LangGraph tool page).

Choose OpenAI Agents API if

  • You want OpenAI to run the agent loop, context compaction, recovery and session storage.
  • Your tasks need a sandbox for running commands and editing files, hosted by OpenAI or connected from your own infrastructure.
  • You are fine with an API under the beta namespace and with billing at OpenAI model, tool and container rates.

Choose LangGraph if

  • You need to define the control flow yourself: branches, loops, parallel steps and approval points.
  • You need to choose or mix model providers, or keep all state in your own storage.
  • You want an open-source runtime you can self-host without a managed service in the loop.

Migration notes

These are different layers, so there is no mechanical migration. Moving a LangGraph agent to the Agents API means giving up the explicit graph: instructions, tools, MCP servers and the multi_agent setting replace nodes and edges, and the harness decides how to split work. Function tools stay in your application: the docs state your code receives each call and must return a result, and that a session can remain waiting if the handler is unavailable. Moving from the Agents API to LangGraph means writing the loop the harness provided: state schema, checkpointer, tool execution, context management and any sandbox. OpenAI's own docs position the Agents SDK (not covered on this page) as the middle option, where the loop runs in your application: see OpenAI Agents SDK vs LangGraph.

FAQ

Is the OpenAI Agents API the same as the OpenAI Agents SDK?

No. OpenAI's docs list them as separate runtime options: the Agents API runs a managed Codex harness on OpenAI's side, while the Agents SDK runs the agent loop inside your application.

Is the OpenAI Agents API the same as Agent Builder?

No. Agent Builder is a visual canvas that OpenAI is deprecating, with shutdown scheduled for 2026-11-30 according to its documentation page.

Can the Agents API run without a sandbox?

Yes. With environment.type set to none the harness can still call remote MCP tools and your function tools, but the built-in Bash and apply-patch tools and workspace files are unavailable.

Does LangGraph require LangSmith?

No. The library runs standalone. LangSmith adds managed deployment, and Agent Server provides the MCP and A2A endpoints.