Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | # Tool-router Example |
| 2 | |
| 3 | This example demonstrates how to use Composio SDK for tool-router. |
| 4 | |
| 5 | ## Setup |
| 6 | |
| 7 | 1. **Install dependencies:** |
| 8 | |
| 9 | ```bash |
| 10 | pnpm install |
| 11 | ``` |
| 12 | |
| 13 | 2. **Configure environment:** |
| 14 | |
| 15 | ```bash |
| 16 | cp .env.example .env |
| 17 | ``` |
| 18 | |
| 19 | Then edit `.env` and add your API keys: |
| 20 | - `COMPOSIO_API_KEY`: Get it from [Composio Dashboard](https://app.composio.dev) |
| 21 | - `OPENAI_API_KEY`: Required for OpenAI Agents examples |
| 22 | - `OPENAI_MODEL`: Optional model override for OpenAI Agents examples |
| 23 | |
| 24 | ## Running the Example |
| 25 | |
| 26 | ```bash |
| 27 | # Run the example |
| 28 | pnpm start |
| 29 | |
| 30 | # Run in development mode (with file watching) |
| 31 | pnpm dev |
| 32 | |
| 33 | # Explicit preload for app tools and SDK custom tools |
| 34 | pnpm preload |
| 35 | |
| 36 | # Direct-tools preset for sessions where all tools are known upfront |
| 37 | pnpm direct-tools |
| 38 | ``` |
| 39 | |
| 40 | ## What This Example Does |
| 41 | |
| 42 | - Initializes Composio SDK |
| 43 | - Fetches available tools |
| 44 | - Demonstrates basic usage patterns |
| 45 | - Shows how to preload selected app tools and SDK-local custom tools into `session.tools()` |
| 46 | - Shows `SessionPreset.DIRECT_TOOLS` for loading all tools allowed by session filters without meta/helper tools |
| 47 | |
| 48 | ## Customization |
| 49 | |
| 50 | Edit `src/index.ts` to: |
| 51 | |
| 52 | - Add specific apps you want to integrate with |
| 53 | - Implement your business logic |
| 54 | - Add error handling and logging |
| 55 | |
| 56 | ## Related Examples |
| 57 | |
| 58 | - [OpenAI Example](../openai) - Shows integration with OpenAI |
| 59 | - [LangChain Example](../langchain) - Shows integration with LangChain |
| 60 | - [More Examples](../) - Browse all available examples |
| 61 | |
| 62 | ## Support |
| 63 | |
| 64 | - [Documentation](https://docs.composio.dev) |
| 65 | - [Discord Community](https://discord.gg/composio) |
| 66 | - [GitHub Issues](https://github.com/ComposioHQ/composio/issues) |