Skip to main content

Installation

Install the Composio Python SDK using your preferred package manager:
pip install composio

Requirements

  • Python: Version 3.9 or higher (Python 3.10+ recommended)
  • pip: Latest version recommended

Environment Setup

1

Get your API key

Sign up at composio.dev and obtain your API key from the dashboard.
2

Configure environment variables

Create a .env file in your project root and add your API key:
COMPOSIO_API_KEY=your-api-key-here
COMPOSIO_BASE_URL=https://backend.composio.dev/api  # Optional: Custom API base URL
COMPOSIO_LOG_LEVEL=info                              # Optional: silent, error, warn, info, debug
COMPOSIO_DISABLE_TELEMETRY=false                     # Optional: Set to "true" to disable telemetry
For production applications, use a secure method to manage environment variables such as python-dotenv or your deployment platform’s secret management.
3

Initialize the SDK

Import and initialize the Composio SDK in your application:
import os
from composio import Composio

composio = Composio(
    api_key=os.getenv("COMPOSIO_API_KEY"),
)

Verification

Verify your installation by running a simple test:
import os
from composio import Composio

composio = Composio(
    api_key=os.getenv("COMPOSIO_API_KEY"),
)

# Test the connection
def verify():
    try:
        user_id = "test-user"
        tools = composio.tools.get(user_id=user_id, toolkits=["HACKERNEWS"])
        print(f"Successfully connected! Found {len(tools)} tools.")
    except Exception as error:
        print(f"Connection failed: {error}")

verify()

Provider-Specific Packages

Depending on your AI framework, you may want to install a provider-specific package:
pip install composio-openai

Quick Start Example

Here’s a complete example using OpenAI Agents:
1

Install dependencies

pip install composio-openai-agents openai-agents
2

Create your agent

import asyncio
import os
from agents import Agent, Runner
from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider

# Initialize Composio client with OpenAI Agents Provider
composio = Composio(provider=OpenAIAgentsProvider())

user_id = "[email protected]"
tools = composio.tools.get(user_id=user_id, toolkits=["HACKERNEWS"])

# Create an agent with the tools
agent = Agent(
    name="Hackernews Agent",
    instructions="You are a helpful assistant.",
    tools=tools,
)

# Run the agent
async def main():
    result = await Runner.run(
        starting_agent=agent,
        input="What's the latest Hackernews post about?",
    )
    print(result.final_output)

asyncio.run(main())
It’s recommended to use a virtual environment for your Python projects:
# Create virtual environment
python -m venv .venv

# Activate (Linux/macOS)
source .venv/bin/activate

# Activate (Windows)
.venv\Scripts\activate

# Install Composio
pip install composio

Next Steps

Build docs developers (and LLMs) love