How to beginner · 3 min read

How to install Composio

Quick answer
Install composio-core and composio-openai Python packages via pip to use Composio for AI tool integrations. Use environment variables for your OpenAI API key and import ComposioToolSet to start integrating tools.

PREREQUISITES

  • Python 3.8+
  • OpenAI API key (free tier works)
  • pip install openai>=1.0
  • pip install composio-core composio-openai

Setup

Install the required Python packages and set your OpenAI API key as an environment variable.

bash
pip install composio-core composio-openai openai
output
Collecting composio-core
Collecting composio-openai
Collecting openai
Installing collected packages: openai, composio-core, composio-openai
Successfully installed composio-core-1.0.0 composio-openai-1.0.0 openai-1.x.x

Step by step

Use the following Python code to initialize Composio with your OpenAI API key and create a toolset for AI tool integrations.

python
import os
from composio_openai import ComposioToolSet, Action
from openai import OpenAI

# Ensure your OpenAI API key is set in the environment
# export OPENAI_API_KEY="your_api_key_here"

# Initialize Composio toolset
toolset = ComposioToolSet(api_key=os.environ["OPENAI_API_KEY"])

# Get tools for a specific action
tools = toolset.get_tools(actions=[Action.GITHUB_STAR_A_REPOSITORY])

# Initialize OpenAI client
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# Create a chat completion using Composio tools
response = client.chat.completions.create(
    model="gpt-4o-mini",
    tools=tools,
    messages=[{"role": "user", "content": "Star the openai/openai-python repo"}]
)

print(response.choices[0].message.content)
output
Thank you! I've starred the openai/openai-python repository on GitHub.

Common variations

You can use different OpenAI models by changing the model parameter, or integrate Composio with LangChain by using composio_langchain. Async usage is possible by adapting the OpenAI client calls to async methods.

python
import asyncio
import os
from composio_openai import ComposioToolSet, Action
from openai import OpenAI

async def main():
    toolset = ComposioToolSet(api_key=os.environ["OPENAI_API_KEY"])
    tools = toolset.get_tools(actions=[Action.GITHUB_STAR_A_REPOSITORY])
    client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

    response = await client.chat.completions.acreate(
        model="gpt-4o",
        tools=tools,
        messages=[{"role": "user", "content": "Star the openai/openai-python repo"}]
    )
    print(response.choices[0].message.content)

asyncio.run(main())
output
Thank you! I've starred the openai/openai-python repository on GitHub.

Troubleshooting

  • If you see ModuleNotFoundError, ensure you installed composio-core and composio-openai correctly.
  • If API calls fail, verify your OPENAI_API_KEY environment variable is set and valid.
  • For permission errors on GitHub actions, check your GitHub token or OAuth scopes if applicable.

Key Takeaways

  • Install Composio with pip using pip install composio-core composio-openai.
  • Set your OpenAI API key in the environment variable OPENAI_API_KEY before running code.
  • Use ComposioToolSet to get tools and pass them to OpenAI chat completions via the tools parameter.
  • You can run Composio code asynchronously by using async client methods like acreate.
  • Check installation and API key setup if you encounter import or authentication errors.
Verified 2026-04 · gpt-4o-mini, gpt-4o
Verify ↗