LlamaIndex
The LlamaIndex provider transforms Composio tools into LlamaIndex's FunctionTool format with built-in execution.
Install
pip install composio composio_llamaindex llama-index llama-index-llms-openainpm install @composio/core @composio/llamaindex @llamaindex/openai @llamaindex/workflowConfigure API Keys
Set COMPOSIO_API_KEY with your API key from Settings and OPENAI_API_KEY with your OpenAI API key.
COMPOSIO_API_KEY=xxxxxxxxx
OPENAI_API_KEY=xxxxxxxxxCreate session and run
import asyncio
from composio import Composio
from composio_llamaindex import LlamaIndexProvider
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
composio = Composio(provider=LlamaIndexProvider())
llm = OpenAI(model="gpt-5.2")
# Create a session for your user
session = composio.create(user_id="user_123")
tools = session.tools()
agent = FunctionAgent(tools=tools, llm=llm)
async def main():
result = await agent.run(
user_msg="Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
)
print(result)
asyncio.run(main())import { Composio } from '@composio/core';
import { LlamaindexProvider } from '@composio/llamaindex';
import { openai } from '@llamaindex/openai';
import { agent } from '@llamaindex/workflow';
const composio = new Composio({
provider: new LlamaindexProvider(),
});
// Create a session for your user
const session = await composio.create("user_123");
const tools = await session.tools();
const myAgent = agent({
llm: openai({ model: 'gpt-5.2' }),
tools,
});
const result = await myAgent.run(
"Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
);
console.log(result.data.result);