Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 04:45 UTC
| 1 | # composio-llamaindex |
| 2 | |
| 3 | Adapts Composio tools to LlamaIndex's `FunctionTool` format so a LlamaIndex agent can call 1000+ apps through a single Composio session. |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```bash |
| 8 | pip install composio composio-llamaindex llama-index llama-index-llms-openai |
| 9 | ``` |
| 10 | |
| 11 | Set `COMPOSIO_API_KEY` (get one from [dashboard.composio.dev/settings](https://dashboard.composio.dev/settings)) and `OPENAI_API_KEY` in your environment: |
| 12 | |
| 13 | ```bash |
| 14 | export COMPOSIO_API_KEY=xxxxxxxxx |
| 15 | export OPENAI_API_KEY=xxxxxxxxx |
| 16 | ``` |
| 17 | |
| 18 | ## Quickstart |
| 19 | |
| 20 | Create a session for your user, fetch its tools, and hand them to a `FunctionAgent`. LlamaIndex drives the tool calls; each tool executes itself through Composio. |
| 21 | |
| 22 | ```python |
| 23 | import asyncio |
| 24 | |
| 25 | from composio import Composio |
| 26 | from composio_llamaindex import LlamaIndexProvider |
| 27 | from llama_index.core.agent.workflow import FunctionAgent |
| 28 | from llama_index.llms.openai import OpenAI |
| 29 | |
| 30 | composio = Composio(provider=LlamaIndexProvider()) |
| 31 | llm = OpenAI(model="gpt-5.2") |
| 32 | |
| 33 | # Each session is scoped to one of your users |
| 34 | session = composio.create(user_id="user_123") |
| 35 | tools = session.tools() |
| 36 | |
| 37 | agent = FunctionAgent(tools=tools, llm=llm) |
| 38 | |
| 39 | |
| 40 | async def main(): |
| 41 | result = await agent.run( |
| 42 | user_msg="Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'" |
| 43 | ) |
| 44 | print(result) |
| 45 | |
| 46 | |
| 47 | asyncio.run(main()) |
| 48 | ``` |
| 49 | |
| 50 | ## Links |
| 51 | |
| 52 | - [LlamaIndex provider docs](https://docs.composio.dev/docs/providers/llamaindex) |
| 53 | - [Composio documentation](https://docs.composio.dev) |