Skip to main content
Composio is an integration platform that provides access to 500+ tools across popular applications like GitHub, Slack, Notion, and more. It enables AI agents to interact with external services through a unified API, handling authentication, permissions, and event-driven workflows.

Overview

Integration details

ClassPackageSerializableJS supportVersion
Composiocomposio-langchainPyPI - Version

Tool features

  • 500+ Tool Access: Pre-built integrations for GitHub, Slack, Gmail, Jira, Notion, and more
  • Authentication Management: Handles OAuth flows, API keys, and authentication state
  • Event-Driven Workflows: Trigger agents based on external events (new Slack messages, GitHub issues, etc.)
  • Fine-Grained Permissions: Control tool access and data exposure per user
  • Custom Tool Support: Add proprietary APIs and internal tools

Setup

The integration lives in the composio-langchain package.
pip install -U composio-langchain

Credentials

You’ll need a Composio API key. Sign up for free at composio.dev to get your API key.
Set API key
import getpass
import os

if not os.environ.get("COMPOSIO_API_KEY"):
    os.environ["COMPOSIO_API_KEY"] = getpass.getpass("Enter your Composio API key: ")
It’s also helpful to set up LangSmith for tracing:
Enable tracing
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
# os.environ["LANGSMITH_TRACING"] = "true"

Instantiation

Initialize Composio with the LangChain provider and get tools from specific toolkits. Each toolkit represents a service (e.g., GitHub, Slack) with multiple tools (actions you can perform).
Initialize Composio
from composio import Composio
from composio_langchain import LangchainProvider

# Initialize Composio with LangChain provider
composio = Composio(provider=LangchainProvider())

# Get tools from specific toolkits
# You can specify one or more toolkits
tools = composio.tools.get(
    user_id="default",
    toolkits=["GITHUB"]
)

print(f"Loaded {len(tools)} tools from GitHub toolkit")

Available toolkits

Composio provides toolkits for various services: Productivity: GitHub, Slack, Gmail, Jira, Notion, Asana, Trello, ClickUp Communication: Discord, Telegram, WhatsApp, Microsoft Teams Development: GitLab, Bitbucket, Linear, Sentry Data & Analytics: Google Sheets, Airtable, HubSpot, Salesforce And 100+ more…

Invocation

Get tools from multiple toolkits

You can load tools from multiple services at once:
# Get tools from multiple toolkits
tools = composio.tools.get(
    user_id="default",
    toolkits=["GITHUB", "SLACK", "GMAIL"]
)

Get specific tools

Instead of entire toolkits, you can load specific tools:
# Get specific tools by name
tools = composio.tools.get(
    user_id="default",
    tools=["GITHUB_CREATE_ISSUE", "SLACK_SEND_MESSAGE"]
)

User-specific tools

Composio supports multi-user scenarios with user-specific authentication:
# Get tools for a specific user
# This user must have authenticated their accounts first
tools = composio.tools.get(
    user_id="user_123",
    toolkits=["GITHUB"]
)

Use within an agent

Here’s a complete example using Composio tools with a LangChain agent to interact with GitHub:
import os
import getpass

if not os.environ.get("OPENAI_API_KEY"):
    os.environ["OPENAI_API_KEY"] = getpass.getpass("Enter your OpenAI API key: ")
# | output: false
# | echo: false

from langchain.chat_models import init_chat_model

llm = init_chat_model(model="gpt-5", model_provider="openai")
Agent with Composio tools
from composio import Composio
from composio_langchain import LangchainProvider
from langchain import hub
from langchain.agents import AgentExecutor, create_openai_functions_agent

# Pull the prompt template
prompt = hub.pull("hwchase17/openai-functions-agent")

# Initialize Composio
composio = Composio(provider=LangchainProvider())

# Get GitHub tools
tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])

# Define task
task = "Star a repo composiohq/composio on GitHub"

# Create agent
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

# Execute using agent_executor
agent_executor.invoke({"input": task})

Event-driven workflows

Composio supports triggering agents based on external events. When events occur in connected apps (like new GitHub commits or Slack messages), triggers automatically send structured payloads to your application.

Creating a trigger

First, create a trigger for the events you want to monitor:
from composio import Composio

composio = Composio(api_key="your_api_key")
user_id = "user_123"

# Check what configuration is required for the trigger
trigger_type = composio.triggers.get_type("GITHUB_COMMIT_EVENT")
print(trigger_type.config)

# Create trigger with required configuration
trigger = composio.triggers.create(
    slug="GITHUB_COMMIT_EVENT",
    user_id=user_id,
    trigger_config={
        "owner": "composiohq",
        "repo": "composio"
    }
)

print(f"Trigger created: {trigger.trigger_id}")

Subscribing to triggers (Development)

For local development and prototyping, you can subscribe directly to triggers:
from composio import Composio

composio = Composio(api_key="your_api_key")

# Subscribe to trigger events
subscription = composio.triggers.subscribe()

# Define event handler
@subscription.handle(trigger_id="your_trigger_id")
def handle_github_commit(data):
    print(f"New commit detected: {data}")
    # Process the event with your agent
    # ... invoke your agent with the task

# Note: For production, use webhooks instead

Webhooks (Production)

For production, configure webhooks in the Composio dashboard:
from fastapi import FastAPI, Request
import json

app = FastAPI()

@app.post("/webhook")
async def webhook_handler(request: Request):
    # Get the webhook payload
    payload = await request.json()

    print("Received trigger event:")
    print(json.dumps(payload, indent=2))

    # Process the event with your agent
    if payload.get("triggerSlug") == "GITHUB_COMMIT_EVENT":
        commit_data = payload.get("payload")
        # ... invoke your agent with commit_data

    return {"status": "success"}
For more details, see the Composio Triggers documentation

Authentication setup

Before using tools that require authentication, users need to connect their accounts:
from composio import Composio

composio = Composio()

# Get authentication URL for a user
auth_connection = composio.integrations.create(
    user_id="user_123",
    integration="github"
)

print(f"Authenticate at: {auth_connection.redirect_url}")

# After authentication, the user's connected account will be available
# and tools will work with their credentials

Multi-user scenarios

For applications with multiple users:
# Each user authenticates their own accounts
tools_user_1 = composio.tools.get(user_id="user_1", toolkits=["GITHUB"])
tools_user_2 = composio.tools.get(user_id="user_2", toolkits=["GITHUB"])

# Tools will use the respective user's credentials
# User 1's agent will act on User 1's GitHub account
agent_1 = create_agent(llm, tools_user_1)

# User 2's agent will act on User 2's GitHub account
agent_2 = create_agent(llm, tools_user_2)

Advanced features

Custom tools

Composio allows you to create custom tools that can be used alongside built-in tools. There are two types:

Standalone tools

Simple tools that don’t require authentication:
from pydantic import BaseModel, Field
from composio import Composio

composio = Composio()

class AddTwoNumbersInput(BaseModel):
    a: int = Field(..., description="The first number to add")
    b: int = Field(..., description="The second number to add")

# Function name will be used as the tool slug
@composio.tools.custom_tool
def add_two_numbers(request: AddTwoNumbersInput) -> int:
    """Add two numbers."""
    return request.a + request.b

# Use with your agent
tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])
tools.append(add_two_numbers)

Toolkit-based tools

Tools that require authentication and can use toolkit credentials:
from composio.types import ExecuteRequestFn

class GetIssueInfoInput(BaseModel):
    issue_number: int = Field(
        ..., description="The number of the issue to get information about"
    )

@composio.tools.custom_tool(toolkit="github")
def get_issue_info(
    request: GetIssueInfoInput,
    execute_request: ExecuteRequestFn,
    auth_credentials: dict,
) -> dict:
    """Get information about a GitHub issue."""
    response = execute_request(
        endpoint=f"/repos/composiohq/composio/issues/{request.issue_number}",
        method="GET",
        parameters=[
            {
                "name": "Accept",
                "value": "application/vnd.github.v3+json",
                "type": "header",
            },
            {
                "name": "Authorization",
                "value": f"Bearer {auth_credentials['access_token']}",
                "type": "header",
            },
        ],
    )
    return {"data": response.data}
Execute custom tools:
response = composio.tools.execute(
    user_id="default",
    slug="get_issue_info",  # Use function name as slug
    arguments={"issue_number": 1},
)
For more details, see the Composio Custom Tools documentation

Fine-grained permissions

Control what actions tools can perform:
# Get tools with specific permissions
tools = composio.tools.get(
    user_id="default",
    toolkits=["GITHUB"],
    # Limit to read-only operations
    permissions=["read"]
)

API reference

For detailed documentation of all Composio features and configurations, visit:
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.