Composio Client
Composio Client is the official Python library for interacting with the Composio API. It enables developers to integrate and automate actions across various tools and platforms. The library maintains a rapid release cadence, with frequent updates to its API surface to reflect changes and additions in the underlying Composio platform.
Warnings
- gotcha The Composio API client is frequently updated, often multiple times a week. While semantic versioning (v1.x.y) is used, rapid 'api update' commits can sometimes introduce subtle changes to method signatures or return types within minor versions, requiring careful attention during upgrades.
- gotcha Authentication requires a `COMPOSIO_API_KEY`. The client expects this to be provided either as an environment variable or explicitly passed during client instantiation. Failing to provide a valid key will result in authentication errors.
- gotcha The library primarily interacts with 'tools' registered within the Composio platform. To perform meaningful actions (e.g., calling `client.action.run_action`), you must have corresponding tools configured and installed in your Composio account.
Install
-
pip install composio-client
Imports
- ComposioClient
from composio_client import ComposioClient
- ActionType
from composio_client.enums import ActionType
Quickstart
import os
from composio_client import ComposioClient
# Ensure COMPOSIO_API_KEY is set in your environment
# Example: export COMPOSIO_API_KEY="your_api_key_here"
api_key = os.environ.get('COMPOSIO_API_KEY', '')
if not api_key:
print("Error: COMPOSIO_API_KEY environment variable not set.")
print("Please set it before running the quickstart.")
else:
try:
client = ComposioClient(api_key=api_key)
# Fetch a list of installed tools
tools = client.tool.get_installed_tools()
print(f"Successfully initialized ComposioClient. Found {len(tools)} installed tools:")
for tool in tools:
print(f"- {tool.name} (ID: {tool.id})")
except Exception as e:
print(f"An error occurred: {e}")