LangChain
The LangChain provider formats Composio tools for LangChain and LangGraph agents. Pick the tab that matches your setup.
The LangChain provider transforms each Composio tool into a LangChain DynamicStructuredTool with built-in execution. You can hand the tools to create_agent in Python or wire them into a graph node in TypeScript, and the framework runs the tool loop for you.
Install
uv add composio composio_langchain langchain langchain_openaiConfigure API Keys
Set COMPOSIO_API_KEY with your API key from Settings and OPENAI_API_KEY with your OpenAI API key.
COMPOSIO_API_KEY=xxxxxxxxx
OPENAI_API_KEY=xxxxxxxxxCreate session and run
from composio import Composio
from composio_langchain import LangchainProvider
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
composio = Composio(provider=LangchainProvider())
llm = ChatOpenAI(model="gpt-5.2")
# Create a session for your user
session = composio.create(user_id="user_123")
tools = session.tools()
agent = create_agent(tools=tools, model=llm)
result = agent.invoke({"messages": [("user", "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'")]})
print(result["messages"][-1].content)Python argument validation
The Python LangChain and LangGraph providers build a Pydantic argument model from each tool's JSON Schema. Object arguments that declare no properties accept and preserve arbitrary nested keys. For objects that declare named properties, undeclared keys are rejected unless the schema allows them with additionalProperties.
Schemas that use patternProperties or schema-valued additionalProperties validate dynamic keys before execution. The providers also preserve whether an optional argument was omitted or explicitly set to None. By default, declared defaults are included, while optional arguments without defaults stay absent. Set schema_config={"skip_defaults": True} when creating the provider to leave declared defaults absent too.
When validation fails, the tool does not run. LangChain surfaces the failure as a tool error observation so the agent can correct its arguments and retry.
Next
What is a session?
How sessions scope users, tools, and auth, and how to reuse them across requests.