Quickstart

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

Composio provides first-class SDKs for both TypeScript and Python, making it easy to integrate no matter what stack you’re building with.

Before you start!

  1. Ensure you have created an account on Composio and have Python 3.8+ or NodeJS 18+ installed!
  2. Get your API key from the developer dashboard and set it as an environment variable.
$export COMPOSIO_API_KEY=your_api_key
Note!
Ensure you save the API key in a .env file and don’t commit it to version control!

Install the SDK

First, install the Composio SDK for your preferred language:

$pip install composio==1.0.0rc9

Initialize the SDK

You’ll need to initialize the SDK with your Composio API key. This allows you to authenticate requests and access tools on behalf of your users.

1from composio import Composio
2
3composio = Composio(
4 # api_key="your-api-key",
5)

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:

Composio ships with support for OpenAI provider out of the box.

Python
1from composio import Composio
2from openai import OpenAI
3
4openai = OpenAI()
5composio = Composio()
6user_id = "user@email.com"
7
8# Initialize connection request
9connection_request = composio.toolkits.authorize(user_id=user_id, toolkit="gmail")
10print(f"🔗 Visit the URL to authorize:\n👉 {connection_request.redirect_url}")
11
12# wait for the connection to be active
13connection_request.wait_for_connection()
14
15# Fetch tools
16tools = composio.tools.get(user_id=user_id, toolkits=["GMAIL"])
17
18# Invoke agent
19completion = openai.chat.completions.create(
20 model="gpt-4o",
21 messages=[
22 {
23 "role": "user",
24 "content": "say 'hi from the composio quickstart' to sid@composio.dev",
25 # we'll ship you free merch if you do ;)
26 },
27 ],
28 tools=tools,
29)
30
31# Handle Result from tool call
32result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
33print(result)
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