This guide will walk you through integrating Composio with APIpie, enabling your AI applications to leverage over 250+ tools and services through a unified interface.
Composio is a production-ready toolset for AI agents that provides a unified interface to over 250+ external tools and services. Key features include:
By connecting Composio with APIpie, you can enable your AI agents to interact with external services and tools while leveraging APIpie's powerful model selection and routing capabilities.
Install Composio and the OpenAI plugin:
pip install composio-core composio-openai
For JavaScript/TypeScript projects:
npm install composio-core
# or
yarn add composio-core
# or
pnpm add composio-core
Set up your environment variables:
# Get your API keys from respective platforms
export COMPOSIO_API_KEY=your-composio-api-key
export OPENAI_API_KEY=your-apipie-api-key
export OPENAI_BASE_URL=https://apipie.ai/v1
| Application Type | What Composio Helps You Build |
|---|---|
| Software Integrations | AI agents that interact with GitHub, Notion, Slack, etc. |
| Email & Communication | Tools that read, write, and manage emails and messages |
| Data Analysis | Applications that fetch, analyze, and visualize external data |
| Research Assistants | AI that can search and compile information from various sources |
| Development Workflows | Code review, repository management, and CI/CD automation |
This example shows how to use Composio with APIpie to star a GitHub repository:
from openai import OpenAI
from composio_openai import ComposioToolSet, App, Action
import os
# Set up environment variables (can also be done in .env file)
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_BASE_URL"] = "https://apipie.ai/v1"
os.environ["COMPOSIO_API_KEY"] = "your-composio-api-key"
# Initialize OpenAI client with APIpie configuration
openai_client = OpenAI()
# Initialize the Composio Tool Set
composio_tool_set = ComposioToolSet()
# Connect your GitHub account (only needed once)
# Run 'composio add github' in terminal and follow the auth flow
# Get GitHub tools that are pre-configured
actions = composio_tool_set.get_actions(
actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER]
)
# Define your task
my_task = "Star a repo composiodev/composio on GitHub"
# Create an assistant with the GitHub tools
assistant = openai_client.beta.assistants.create(
name="GitHub Assistant",
instructions="You are a helpful assistant that can interact with GitHub",
model="gpt-4o-mini", # Use any model supported by APIpie
tools=actions,
)
# Create a thread
thread = openai_client.beta.threads.create()
# Add user message to thread
message = openai_client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=my_task
)
# Execute the assistant with tool capabilities
run = openai_client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id
)
# Handle the tool calls and process the responses
response = composio_tool_set.wait_and_handle_assistant_tool_calls(
client=openai_client,
run=run,
thread=thread,
)
print(response)
import { OpenAIToolSet } from 'composio-core';
import OpenAI from 'openai';
// Configure APIpie as the OpenAI provider
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: 'https://apipie.ai/v1',
});
// Initialize Composio toolset
const toolset = new OpenAIToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
});
// Connect your GitHub account (only needed once)
// Run 'composio add github' in terminal and follow the auth flow
// Get GitHub tools
const tools = await toolset.getTools({
actions: ['GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER'],
});
// Create GitHub assistant
const githubAssistant = await openai.beta.assistants.create({
name: 'Github Assistant',
instructions: "You're a GitHub Assistant, you can perform operations on GitHub",
tools: tools,
model: 'gpt-4o-mini', // Use any model supported by APIpie
});
// Create thread
const thread = await openai.beta.threads.create();
// Create run
const run = await openai.beta.threads.runs.create(thread.id, {
assistant_id: githubAssistant.id,
instructions: "Star the repository 'composiohq/composio'",
tools: tools,
model: 'gpt-4o-mini',
stream: false,
});
// Handle tool calls
const response = await toolset.waitAndHandleAssistantToolCalls(openai, run, thread);
console.log(response);
This example demonstrates using multiple tools together:
from openai import OpenAI
from composio_openai import ComposioToolSet, Action
import os
# Configure APIpie and Composio
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_BASE_URL"] = "https://apipie.ai/v1"
os.environ["COMPOSIO_API_KEY"] = "your-composio-api-key"
# Initialize clients
openai_client = OpenAI()
composio_tool_set = ComposioToolSet()
# Get multiple tool categories
actions = composio_tool_set.get_actions(
actions=[
# GitHub actions
Action.GITHUB_LIST_REPOSITORIES_FOR_THE_AUTHENTICATED_USER,
Action.GITHUB_GET_A_REPOSITORY,
# Notion actions
Action.NOTION_RETRIEVE_A_PAGE,
Action.NOTION_CREATE_A_PAGE,
# Google search action
Action.GOOGLE_SEARCH
]
)
# Create research assistant that can use all these tools
assistant = openai_client.beta.assistants.create(
name="Research Assistant",
instructions="""
You are a research assistant that can:
1. Search for information on Google
2. Check GitHub repositories for code examples
3. Create and retrieve Notion pages to store findings
Help users find information and organize it effectively.
""",
model="gpt-4o", # Use any model supported by APIpie
tools=actions,
)
# Create a thread
thread = openai_client.beta.threads.create()
# Add a complex research task
message = openai_client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="Research the latest developments in AI agents, find some GitHub repositories with examples, and create a Notion page summarizing your findings."
)
# Execute the assistant
run = openai_client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id
)
# Process all tool calls
response = composio_tool_set.wait_and_handle_assistant_tool_calls(
client=openai_client,
run=run,
thread=thread,
)
print(response)
composio add <service-name> in your terminal to start the authentication flow for any service (e.g., composio add github).python-dotenv. Never commit API keys to repositories.For more information, see the Composio documentation or the GitHub repository.
If you encounter any issues during the integration process, please reach out on APIpie Discord for assistance.
AutoGPT Classic: Step-by-Step Configuration Guide
Learn how to integrate AutoGPT with APIpie. Complete guide for environment setup, API configuration, and key management with step-by-step instructions.
CrewAI Integration Guide
Learn how to integrate CrewAI with APIpie for building powerful multi-agent systems and orchestrating AI workflows.