Agent Frameworks
How do you use Claude with LangGraph?
QUICK ANSWER
To use Claude with LangGraph, install the '@langchain/anthropic' integration package, initialize ChatAnthropic with your target model string, and bind it to your graph nodes.
TypeScript Implementation Example
import { ChatAnthropic } from "@langchain/anthropic";
import { StateGraph } from "@langchain/langgraph";
const model = new ChatAnthropic({
modelName: "claude-3-5-sonnet-20241022",
temperature: 0
});
// Define graph nodes and bind the model
const graph = new StateGraph({ channels: {} })
.addNode("agent", async (state) => {
const response = await model.invoke(state.messages);
return { messages: [response] };
});
Verified against: LangGraph v0.2.0 ยท LangChain Anthropic v0.3.0