Skip to Content
PythonUse ToolsLangchain Example

LangChain Integration

```python from reacter_openapitools import LangChainAdapter from langchain_anthropic import ChatAnthropic from langgraph.prebuilt import create_react_agent from langchain_core.messages import HumanMessage # Initialize the language model model = ChatAnthropic( model_name="claude-3-sonnet-20240229", api_key="your-anthropic-api-key" ) # Initialize the adapter adapter = LangChainAdapter(api_key="your OpenAPI Tools Apikey - https://openapitools.com/dashboard/settings") # Get tools in LangChain format tools = adapter.get_langchain_tools() # Create a LangChain agent with tools agent_executor = create_react_agent(model, tools) # Use the agent response = agent_executor.invoke({ "messages": [HumanMessage(content="Can you generate an OTP for me?")] }) print(response["messages"])
Last updated on