Skip to main content

Installation

Get started with Composio by installing the SDK for your preferred language.
npm install @composio/core

Initialize Composio

import { Composio } from '@composio/core';

// Initialize the SDK
const composio = new Composio({
  // apiKey: 'your-api-key',
});

Build Your First Agent

Create a simple agent that can fetch the latest Hacker News posts using OpenAI Agents.
1

Install OpenAI Agents Provider

npm install @composio/openai-agents @openai/agents
2

Initialize Composio with Provider

import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, run } from '@openai/agents';

const composio = new Composio({
  provider: new OpenAIAgentsProvider(),
});

const userId = '[email protected]';
3

Get Tools from a Toolkit

const tools = await composio.tools.get(userId, {
  toolkits: ['HACKERNEWS'],
});
4

Create and Run Your Agent

const agent = new Agent({
  name: 'Hackernews assistant',
  tools: tools,
});

const result = await run(agent, 'What is the latest hackernews post about?');

console.log(JSON.stringify(result.finalOutput, null, 2));
// will return the response from the agent with data from HACKERNEWS API.

Complete Example

Here’s the full code to get you started:
import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, run } from '@openai/agents';

const composio = new Composio({
  provider: new OpenAIAgentsProvider(),
});

const userId = '[email protected]';

const tools = await composio.tools.get(userId, {
  toolkits: ['HACKERNEWS'],
});

const agent = new Agent({
  name: 'Hackernews assistant',
  tools: tools,
});

const result = await run(agent, 'What is the latest hackernews post about?');

console.log(JSON.stringify(result.finalOutput, null, 2));
// will return the response from the agent with data from HACKERNEWS API.

Next Steps

Explore Toolkits

Browse 1000+ available toolkits and integrations

Authentication

Learn how to connect user accounts to external services

AI Providers

Integrate with OpenAI, Anthropic, LangChain, and more

Custom Tools

Create your own custom tools and actions

Build docs developers (and LLMs) love