> ## Documentation Index
> Fetch the complete documentation index at: https://composio-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LlamaIndex

> Build an agent with LlamaIndex and enable it to use 1000+ tools with Composio.

The LlamaIndex provider turns Composio tools into LlamaIndex [`FunctionTool`](https://docs.llamaindex.ai/en/stable/module_guides/deploying/agents/) objects that execute themselves. You connect an account, fetch the tools, hand them to a `FunctionAgent`, and LlamaIndex drives the calls. The provider ships for both Python and TypeScript.

**1. Install**

**Install**

> [tab] Python
>
> ```bash uv theme={null}
> uv add composio composio_llamaindex llama-index llama-index-llms-openai
> ```
>
> ```bash pip theme={null}
> pip install composio composio_llamaindex llama-index llama-index-llms-openai
> ```

> [tab] TypeScript
>
> ```bash npm theme={null}
> npm install @composio/core @composio/llamaindex @llamaindex/openai @llamaindex/workflow
> ```
>
> ```bash pnpm theme={null}
> pnpm add @composio/core @composio/llamaindex @llamaindex/openai @llamaindex/workflow
> ```
>
> ```bash yarn theme={null}
> yarn add @composio/core @composio/llamaindex @llamaindex/openai @llamaindex/workflow
> ```
>
> ```bash bun theme={null}
> bun add @composio/core @composio/llamaindex @llamaindex/openai @llamaindex/workflow
> ```

**2. Configure API Keys**

**Configure API Keys**

> [!NOTE]
>
> Set `COMPOSIO_API_KEY` with your API key from [Settings](https://dashboard.composio.dev/~/project/settings/api-keys?utm_source=docs\&utm_medium=content\&utm_campaign=docs-providers-llamaindex) and `OPENAI_API_KEY` with your [OpenAI API key](https://platform.openai.com/api-keys).

```txt .env theme={null}
COMPOSIO_API_KEY=xxxxxxxxx
OPENAI_API_KEY=xxxxxxxxx
```

**3. Create session and run**

**Create session and run**

> [tab] Python
>
> ```python theme={null}
> 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())
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> 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);
> ```

## TypeScript tool schemas

The TypeScript provider passes each tool's JSON Schema directly to the model, preserving keywords such as `format`, `contentEncoding`, and `contentMediaType`. Tool arguments are still validated before execution.

## Next

> [card] [What is a session?](https://composio-preview.mintlify.site/docs/how-composio-works.md)
>
> How sessions scope users, tools, and auth, and how to reuse them across requests.
