Quickstart

This guide covers authenticated tool calling, one of the most core features of Composio. You will learn how to:

  • Add tools to your AI agent
  • Authenticate the agent/tools for a user
  • Call the tools generated by the LLM

Before you start!

  1. Ensure you have created an account on Composio and have Python 3.8+ or NodeJS 16+ 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 and foremost, install the Composio SDK.

1npm install @composio/core

Initialise

To use the SDK, you need to initialize it with your API key:

1import { Composio } from '@composio/core';
2
3// Initialize the SDK
4const composio = new Composio({
5 // apiKey: 'your-api-key',
6});

Authorize and run tools

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

1from composio import Composio
2from openai import OpenAI
3
4openai = OpenAI()
5composio = Composio()
6
7user_id = "your@email.com"
8connection_request = composio.toolkits.authorize(user_id, "gmail")
9print(f"🔗 Visit the URL to authorize:\n👉 {connection.redirect_url}")
10
11# wait for the connection to be active
12connection_request.wait_for_connection()
13
14completion = openai.chat.completions.create(
15 model="gpt-4o",
16 messages=[
17 {
18 "role": "user",
19 "content": "say 'hi from the composio quickstart' to sid@composio.dev",
20 # we'll ship you free merch if you do ;)
21 },
22 ],
23 tools=tools,
24)
25result = composio.provider.handle_tool_call(user_id=user_id, response=completion)
26print(result)
What just happened?

You authenticated your account through Composio and used LLMs to execute tools. Composio handled the OAuth flow and tool execution.

Next steps