Skip to main content

Installation

Install the Composio TypeScript SDK using your preferred package manager:
npm install @composio/core

Requirements

  • Node.js: Version 16 or higher
  • TypeScript: Version 4.5 or higher (optional, but recommended)

Environment Setup

1

Get your API key

Sign up at composio.dev and obtain your API key from the dashboard.
2

Configure environment variables

Create a .env file in your project root and add your API key:
COMPOSIO_API_KEY=your-api-key-here
COMPOSIO_BASE_URL=https://backend.composio.dev/api  # Optional: Custom API base URL
COMPOSIO_LOG_LEVEL=info                              # Optional: silent, error, warn, info, debug
COMPOSIO_DISABLE_TELEMETRY=false                     # Optional: Set to "true" to disable telemetry
3

Initialize the SDK

Import and initialize the Composio SDK in your application:
import { Composio } from '@composio/core';

const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
});

Verification

Verify your installation by running a simple test:
import { Composio } from '@composio/core';

const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
});

// Test the connection
async function verify() {
  try {
    const userId = 'test-user';
    const tools = await composio.tools.get(userId, {
      toolkits: ['HACKERNEWS'],
    });
    console.log(`Successfully connected! Found ${tools.length} tools.`);
  } catch (error) {
    console.error('Connection failed:', error);
  }
}

verify();

Provider-Specific Packages

Depending on your AI framework, you may want to install a provider-specific package:
npm install @composio/openai

Quick Start Example

Here’s a complete example using OpenAI Agents:
1

Install dependencies

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

Create your agent

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));

Next Steps

Build docs developers (and LLMs) love