Access 500+ tools and integrations through Composio’s unified API platform for AI agents, with OAuth handling, event-driven workflows, and multi-user support.
Use this file to discover all available pages before exploring further.
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.
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 Composiofrom composio_langchain import LangchainProvider# Initialize Composio with LangChain providercomposio = Composio(provider=LangchainProvider())# Get tools from specific toolkits# You can specify one or more toolkitstools = composio.tools.get( user_id="default", toolkits=["GITHUB"])print(f"Loaded {len(tools)} tools from GitHub toolkit")
Composio supports multi-user scenarios with user-specific authentication:
# Get tools for a specific user# This user must have authenticated their accounts firsttools = composio.tools.get( user_id="user_123", toolkits=["GITHUB"])
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.
For local development and prototyping, you can subscribe directly to triggers:
from composio import Composiocomposio = Composio(api_key="your_api_key")# Subscribe to trigger eventssubscription = 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
from fastapi import FastAPI, Requestimport jsonapp = 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"}
Before using tools that require authentication, users need to connect their accounts:
from composio import Composiocomposio = Composio()# Get authentication URL for a userauth_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
# Each user authenticates their own accountstools_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 accountagent_1 = create_agent(llm, tools_user_1)# User 2's agent will act on User 2's GitHub accountagent_2 = create_agent(llm, tools_user_2)
from pydantic import BaseModel, Fieldfrom composio import Composiocomposio = 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_tooldef add_two_numbers(request: AddTwoNumbersInput) -> int: """Add two numbers.""" return request.a + request.b# Use with your agenttools = composio.tools.get(user_id="default", toolkits=["GITHUB"])tools.append(add_two_numbers)
# Get tools with specific permissionstools = composio.tools.get( user_id="default", toolkits=["GITHUB"], # Limit to read-only operations permissions=["read"])