Use this file to discover all available pages before exploring further.
This guide walks you through installing Composio, initializing the client, fetching tools from a toolkit, and running a real AI agent that uses those tools. By the end you will have a working agent that can query the HackerNews API through Composio.
Set COMPOSIO_API_KEY as an environment variable before you start. The SDK reads it automatically so you never have to hard-code credentials in your source files.
1
Install the SDK
Install the core Composio package plus the provider adapter for your AI framework. The examples below use OpenAI.
Fetch the tools for a specific user and toolkit. The tools are automatically wrapped in the format your AI framework expects — no manual schema conversion required.
TypeScript
Python
import { Composio } from '@composio/core';const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY,});// Fetch HackerNews tools for this userconst tools = await composio.tools.get('user@example.com', { toolkits: ['HACKERNEWS'],});console.log(`Loaded ${tools.length} tools`);
import osfrom composio import Composiocomposio = Composio(api_key=os.environ['COMPOSIO_API_KEY'])# Fetch HackerNews tools for this usertools = composio.tools.get( user_id='user@example.com', toolkits=['HACKERNEWS'],)print(f"Loaded {len(tools)} tools")
The user_id / first argument scopes tool execution to a specific user’s connected accounts. Use a stable identifier like a database UUID in production — avoid "default" outside of experimentation.
5
Run an agent
Pass the tools directly to your AI framework. Composio handles tool execution automatically when the model calls a tool.
TypeScript
Python
import { Composio } from '@composio/core';import { OpenAI } from 'openai';const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });const userId = 'user@example.com';// Fetch tools for the userconst tools = await composio.tools.get(userId, { toolkits: ['HACKERNEWS'],});// First model call — ask the model to pick and call a toolconst response = await openai.chat.completions.create({ model: 'gpt-4o-mini', messages: [ { role: 'system', content: 'You are a helpful assistant.' }, { role: 'user', content: "What is the latest HackerNews post about?" }, ], tools: tools, tool_choice: 'auto',});// Execute any tool calls the model requested and get the final responseconst result = await composio.provider.handleToolCalls(userId, response);console.log(result);
import osfrom openai import OpenAIfrom composio import Composioopenai_client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])composio = Composio(api_key=os.environ['COMPOSIO_API_KEY'])user_id = 'user@example.com'# Fetch tools for the usertools = composio.tools.get(user_id=user_id, toolkits=['HACKERNEWS'])# First model call — ask the model to pick and call a toolresponse = openai_client.chat.completions.create( model='gpt-4o-mini', messages=[ {'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': 'What is the latest HackerNews post about?'}, ], tools=tools, tool_choice='auto',)# Execute any tool calls the model requested and get the final responseresult = composio.provider.handle_tool_calls(user_id, response)print(result)
The examples above use OpenAI. Composio supports many other AI frameworks with dedicated provider adapters — see Providers for the full list and setup instructions.