mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-10 13:02:37 +00:00
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Check Documentation Broken Links / Check broken links (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Build uv cache / build-cache (3.10) (push) Has been cancelled
Build uv cache / build-cache (3.11) (push) Has been cancelled
Build uv cache / build-cache (3.12) (push) Has been cancelled
Build uv cache / build-cache (3.13) (push) Has been cancelled
* docs: update Composio tool docs across locales Align the Composio automation docs with the new session-based example flow and keep localized pages in sync with the updated English content. Made-with: Cursor * docs: clarify manual user authentication wording Refine the Composio auth section language to reflect session-based automatic auth during agent chat while keeping the manual `authorize` flow explicit. Made-with: Cursor * docs: sync updated Composio auth wording across locales Propagate the latest English wording updates for CrewAI provider initialization and manual user authentication guidance to pt-BR and ko docs. Made-with: Cursor
89 lines
2.5 KiB
Plaintext
89 lines
2.5 KiB
Plaintext
---
|
|
title: Composio Tool
|
|
description: Composio provides 250+ production-ready tools for AI agents with flexible authentication management.
|
|
icon: gear-code
|
|
mode: "wide"
|
|
---
|
|
|
|
# `ComposioToolSet`
|
|
|
|
## Description
|
|
Composio is an integration platform that allows you to connect your AI agents to 250+ tools. Key features include:
|
|
|
|
- **Enterprise-Grade Authentication**: Built-in support for OAuth, API Keys, JWT with automatic token refresh
|
|
- **Full Observability**: Detailed tool usage logs, execution timestamps, and more
|
|
|
|
## Installation
|
|
|
|
To incorporate Composio tools into your project, follow the instructions below:
|
|
|
|
```shell
|
|
pip install composio composio-crewai
|
|
pip install crewai
|
|
```
|
|
|
|
After the installation is complete, set your Composio API key as `COMPOSIO_API_KEY`. Get your Composio API key from [here](https://platform.composio.dev)
|
|
|
|
## Example
|
|
|
|
The following example demonstrates how to initialize the tool and execute a github action:
|
|
|
|
1. Initialize Composio with CrewAI Provider
|
|
|
|
```python Code
|
|
from composio_crewai import ComposioProvider
|
|
from composio import Composio
|
|
from crewai import Agent, Task, Crew
|
|
|
|
composio = Composio(provider=ComposioProvider())
|
|
```
|
|
|
|
2. Create a new Composio Session and retrieve the tools
|
|
<CodeGroup>
|
|
```python
|
|
session = composio.create(
|
|
user_id="your-user-id",
|
|
toolkits=["gmail", "github"] # optional, default is all toolkits
|
|
)
|
|
tools = session.tools()
|
|
```
|
|
Read more about sessions and user management [here](https://docs.composio.dev/docs/configuring-sessions)
|
|
</CodeGroup>
|
|
|
|
3. Authenticating users manually
|
|
|
|
Composio automatically authenticates the users during the agent chat session. However, you can also authenticate the user manually by calling the `authorize` method.
|
|
```python Code
|
|
connection_request = session.authorize("github")
|
|
print(f"Open this URL to authenticate: {connection_request.redirect_url}")
|
|
```
|
|
|
|
4. Define agent
|
|
|
|
```python Code
|
|
crewai_agent = Agent(
|
|
role="GitHub Agent",
|
|
goal="You take action on GitHub using GitHub APIs",
|
|
backstory="You are AI agent that is responsible for taking actions on GitHub on behalf of users using GitHub APIs",
|
|
verbose=True,
|
|
tools=tools,
|
|
llm= # pass an llm
|
|
)
|
|
```
|
|
|
|
5. Execute task
|
|
|
|
```python Code
|
|
task = Task(
|
|
description="Star a repo composiohq/composio on GitHub",
|
|
agent=crewai_agent,
|
|
expected_output="Status of the operation",
|
|
)
|
|
|
|
crew = Crew(agents=[crewai_agent], tasks=[task])
|
|
|
|
crew.kickoff()
|
|
```
|
|
|
|
* More detailed list of tools can be found [here](https://docs.composio.dev/toolkits)
|