Step 1: install and configure LangGraph
**Install the package and dependencies.** LangGraph requires `langgraph`, the LangChain model integration for your chosen provider, and any tool dependencies. For a Claude-backed agent: `pip install langgraph langchain-anthropic` — this pulls in LangGraph's core graph engine and Anthropic's LangChain wrapper. For OpenAI: `pip install langgraph langchain-openai`. Source: LangGraph installation guide.
**Configure your API key.** `import os; os.environ['ANTHROPIC_API_KEY'] = '<your_key>'` or export it in your shell environment. Never hardcode API keys in application code — use environment variables or a secrets manager (AWS Secrets Manager, HashiCorp Vault, Doppler). LangGraph reads keys via the underlying LangChain model integration, which uses the standard `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` environment variable convention.
**Initialize the model.** `from langchain_anthropic import ChatAnthropic; llm = ChatAnthropic(model='claude-sonnet-4-6', temperature=0, max_tokens=1000)`. Set `temperature=0` for deterministic, reproducible agent behavior. Set `max_tokens` explicitly — LangGraph agents can loop for many turns, and unbounded output on each turn is the most common cause of unexpectedly high costs. For Opus 4.7: `model='claude-opus-4-7'`. For OpenAI: `from langchain_openai import ChatOpenAI; llm = ChatOpenAI(model='gpt-5.5', temperature=0)`.
**Verify your installation.** Run a quick smoke test: `result = llm.invoke('Say hi'); print(result.content)`. If you get a response, the model is configured correctly. If you get an authentication error, the API key is missing or malformed. If you get a model-not-found error, check the model ID — LangChain model IDs exactly mirror the provider's documented model names. See LangChain Anthropic integration docs for the full list.
**Set up LangSmith tracing for observability (optional but recommended).** `os.environ['LANGCHAIN_TRACING_V2'] = 'true'; os.environ['LANGCHAIN_API_KEY'] = '<langsmith_key>'`. LangSmith traces every LangGraph execution — nodes, edges, inputs, outputs, token counts, latency. For production agents, tracing is how you debug unexpected loops, high-cost runs, and tool failures. LangSmith Hobby plan is free; Pro is $39/month at usage-based pricing. Running without tracing in production is flying blind. See langchain-ai.github.io/langgraph for the full observability setup.
**LangGraph v0.3 breaking changes from earlier versions.** If you're migrating from LangGraph v0.1 or v0.2: `StateGraph` initialization changed — you now pass the state schema class as the type argument directly (`StateGraph(AgentState)` not `StateGraph(state_schema=AgentState)`). The `add_node` / `add_edge` API is unchanged. `MemorySaver` is now the only in-memory checkpointer (no more `InMemorySaver`). The `create_react_agent` shortcut still works but gives you less control over node structure — use explicit graph construction for production agents.