Overview
Use the provider’s own SDK for production agents whose behavior you must trace and tune; reach for LangChain or LangGraph when provider portability, prebuilt integrations, or durable workflow state is worth an extra abstraction layer. LangChain 1.x centers on create_agent, a configurable agent harness with middleware, built on LangGraph for durable execution, human-in-the-loop, and persistence; LangGraph is the lower-level option for mixed deterministic and agentic flows. Provider SDKs now include agent runtimes of their own: the OpenAI Agents SDK, and the Claude Agent SDK (claude-agent-sdk for Python, @anthropic-ai/claude-agent-sdk for TypeScript).
Comparison
| Dimension | Provider SDK | LangChain 1.x and LangGraph |
|---|---|---|
| Surface | One vendor’s API, with new features available on release | Common model interface across OpenAI, Anthropic, Google, Azure OpenAI, Bedrock, Ollama, and others |
| Debugging | Requests and responses are visible directly | Extra layers (middleware, graph runtime); LangSmith for tracing |
| Agent loop | You write it, or use the vendor’s agent SDK | create_agent; LangGraph for stateful graphs |
| Durable state | Build it yourself | LangGraph persistence and human-in-the-loop |
| Integrations | Write thin clients for stores and loaders | Many prebuilt connectors |
| Provider features | Immediate, including provider-specific options | Through the standard interface; vendor-only features may need provider-specific parameters |
| Dependencies | One or two packages | A larger dependency tree |
Pick the provider SDK when
Pick the provider SDK for most production tool-using agents.
- You rely on provider-specific features (caching, structured outputs, hosted tools) and want them the day they ship.
- Debugging and cost control matter: log raw requests, responses, and token usage at the HTTP client.
- The loop is simple: call model, run tools, repeat. Use the vendor’s agent SDK if you want a ready runtime.
- For Claude, use current model IDs such as
claude-sonnet-5-5, and avoid sampling parameters the model rejects.
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)Pick LangChain or LangGraph when
Pick them when their features are the requirement.
- A workflow with branches, retries, checkpoints, and human approval steps, where LangGraph’s persistence replaces custom state code.
- Frequent model or provider swaps across a team, or evaluation across vendors, behind one interface.
- RAG prototypes that use ready loaders, splitters, and retrievers. See rag.
- An existing LangChain system that works: keep it. LangChain 1.x moved legacy chains to the separate
langchain-classicpackage, so upgrades may need import changes. - Keep prompts, tool schemas, and retrieval queries in your own modules, so a framework change is a wiring change.
Migrate
Moving from LangChain to a provider SDK means re-implementing orchestration, not data: reuse prompts, tool definitions, and retrieval queries, replace retrievers with direct store clients, and map tool calls to the provider’s tool-use API. Migrate only for a concrete problem such as an unsupported provider feature, trace opacity, or dependency conflicts. For multi-provider setups without a framework, a thin adapter you own (or a router such as LiteLLM) is an option; see claude-vs-gpt for vendor trade-offs and multi-agent for agent architecture.
FAQ
Do I need LangChain to build an AI agent?
No; for most production tool-using agents the provider SDK is enough, because the loop is call model, run tools, repeat. Use the vendor’s agent SDK, such as the OpenAI Agents SDK or the Claude Agent SDK, if you want a ready runtime.
When is LangGraph worth using?
Use LangGraph for workflows with branches, retries, checkpoints, and human approval steps, where its persistence replaces custom state code. It is the lower-level option for mixed deterministic and agentic flows.
Will upgrading to LangChain 1.x break my code?
Possibly; LangChain 1.x moved legacy chains to the separate langchain-classic package, so upgrades may need import changes. Keep a working LangChain system rather than rewriting it.