Composio Tutorial: Tool Integration Platform for AI Agents

# Tutorial Composio: Platform Integrasi Tool untuk AI Agents Composio adalah platform open-source yang memungkinkan AI agents terhubung dengan lebih dari 250+ tools dan aplikasi eksternal seperti Git...

By Ruby Abdullah · · tutorial
ComposioAI AgentsTool IntegrationLangChainPython

Composio Tutorial: Tool Integration Platform for AI Agents

Composio is an open-source platform that enables AI agents to connect with 250+ external tools and applications such as GitHub, Slack, Gmail, Google Sheets, Jira, and many more. With Composio, you can build AI agents that don't just think but also take real-world actions through secure, managed API integrations.

In this tutorial, we'll learn how to use Composio from installation and authentication to building AI agents that can interact with various tools automatically.

Why Composio?

Building AI agents that interact with external tools typically requires significant boilerplate code: managing OAuth tokens, writing API wrappers, handling rate limiting, and ensuring security. Composio solves all these problems by providing:

  • Managed Authentication: OAuth2, API Key, and Basic Auth handled automatically
  • 250+ Pre-built Integrations: GitHub, Slack, Gmail, Notion, Jira, Linear, Google Drive, and more
  • Framework Agnostic: Supports LangChain, CrewAI, AutoGen, LlamaIndex, OpenAI, and other frameworks
  • Type-safe Actions: Every tool action has a clear schema for input and output
  • Execution Environment: Supports local, Docker, and cloud execution

Installation

Python SDK Installation

pip install composio-core

For integration with specific frameworks, install additional packages:

# For OpenAI

pip install composio-openai

For LangChain

pip install composio-langchain

For CrewAI

pip install composio-crewai

For Autogen

pip install composio-autogen

For LlamaIndex

pip install composio-llamaindex

CLI Installation

Composio provides a CLI for managing connections and tools:

pip install composio-core

Login to Composio

composio login

Check status

composio whoami

API Key Setup

After logging in, you can obtain your API key from the Composio dashboard:

export COMPOSIOAPIKEY="your-api-key-here"

Or save it in a .env file:

COMPOSIOAPIKEY=your-api-key-here

Basic Usage

Connecting an App

The first step is connecting the application you want your agent to use. Composio handles the OAuth process automatically:

from composio import ComposioToolSet, App, Action

Initialize toolset

toolset = ComposioToolSet()

Start connection to GitHub

This will open a browser for OAuth authorization

entity = toolset.getentity(id="default")

connectionrequest = entity.initiateconnection(

appname=App.GITHUB

)

print(f"Open this URL to authorize: {connectionrequest.redirectUrl}")

print(f"Connection status: {connectionrequest.connectionStatus}")

For CLI, the connection process is simpler:

# Add GitHub connection

composio add github

Add Slack connection

composio add slack

View active connections

composio connections

Using Tools with OpenAI

Here's a simple example using Composio with OpenAI to create an agent that can interact with GitHub:

from composioopenai import ComposioToolSet, Action

from openai import OpenAI

Initialize

client = OpenAI()

toolset = ComposioToolSet()

Get GitHub tools

tools = toolset.gettools(actions=[

Action.GITHUBCREATEISSUE,

Action.GITHUBLISTREPOS,

Action.GITHUBSTARREPO,

])

Make request to OpenAI with tools

response = client.chat.completions.create(

model="gpt-4o",

messages=[

{

"role": "system",

"content": "You are an assistant that helps manage GitHub repositories."

},

{

"role": "user",

"content": "Create a new issue in 'myorg/myproject' repo with title 'Fix login bug' and description 'Login page returns 500 error when using SSO'"

}

],

tools=tools,

toolchoice="auto"

)

Execute tool calls

result = toolset.handletoolcalls(response)

print(result)

Related Articles

LangChain Tutorial: The Most Popular Framework for Building LLM Applications

Tutorial LangChain: Framework Paling Populer untuk Membangun Aplikasi LLM LangChain adalah framework open-source yang di...

Complete LangGraph Tutorial: Building Complex AI Agents

Tutorial Lengkap LangGraph: Membangun AI Agents yang Kompleks LangGraph adalah library dari LangChain untuk membangun st...

Complete Tavily Tutorial: AI Search API for RAG and AI Agents

Tutorial Lengkap Tavily: AI Search API untuk RAG dan AI Agents Tavily adalah search API yang dirancang khusus untuk apli...

E2B Code Interpreter Tutorial: Complete Guide to Secure Code Execution for AI Applications

Tutorial Lengkap E2B Code Interpreter: Eksekusi Kode yang Aman untuk Aplikasi AI E2B Code Interpreter adalah platform sa...