Quickstart

Add composio tools to your AI agents

This guide walks you through authenticated tool calling—the foundation of how Composio connects your AI agents to real-world actions.

You’ll learn how to:

  1. Discover and add tools relevant to your use case (e.g., Slack, GitHub, Notion) to your AI agent
  2. Authenticate tools securely on behalf of a specific user, with fine-grained access control
  3. Enable your LLM (like OpenAI, Claude, or LangChain) to invoke these tools reliably using structured tool call formats

Prerequisites

Before you begin, ensure you have:

  1. A Composio account - Sign up here if you haven’t already
  2. Python 3.10+ or Node.js 18+ installed on your system
  3. Your API key - Get it from the developer dashboard and set it as an environment variable:
$export COMPOSIO_API_KEY=your_api_key

Install the SDK

First, install the Composio SDK for your preferred language:

$pip install composio

Authorize Tools & Run Them with an Agent

Composio supports multiple LLM providers. Here’s how to use Composio with some of the most popular ones:

Install the OpenAI Agents provider!

Installation

$pip install composio openai-agents composio-openai-agents
Python
1import asyncio
2from composio import Composio
3from agents import Agent, Runner
4from composio_openai_agents import OpenAIAgentsProvider
5
6composio = Composio(api_key="your-api-key", provider=OpenAIAgentsProvider())
7
8# Id of the user in your system
9externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ad9ebc4"
10
11# Create an auth config for gmail from the dashboard or programmatically
12auth_config_id = "your-auth-config-id"
13connection_request = composio.connected_accounts.link(
14 user_id=externalUserId,
15 auth_config_id=auth_config_id,
16)
17
18# Redirect user to the OAuth flow
19redirect_url = connection_request.redirect_url
20
21print(
22 f"Please authorize the app by visiting this URL: {redirect_url}"
23) # Print the redirect url to the user
24
25# Wait for the connection to be established
26connected_account = connection_request.wait_for_connection()
27print(
28 f"Connection established successfully! Connected account id: {connected_account.id}"
29)
30
31# Get Gmail tools that are pre-configured
32tools = composio.tools.get(user_id=externalUserId, tools=["GMAIL_SEND_EMAIL"])
33
34agent = Agent(
35 name="Email Manager", instructions="You are a helpful assistant", tools=tools
36)
37
38# Run the agent
39async def main():
40 result = await Runner.run(
41 starting_agent=agent,
42 input="Send an email to soham.g@composio.dev with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",
43 )
44 print(result.final_output)
45
46asyncio.run(main())
What just happened?

You just:

  1. Authorized a user account with Composio
  2. Passed those tool permissions into an LLM framework
  3. Let the LLM securely call real tools on the user’s behalf

All OAuth flows and tool execution were automatically handled by Composio.

Next steps