ts/README.md
The Composio SDK is a powerful toolkit that enables you to integrate third-party tools and services into your applications. It helps you connect to various services (toolkits), execute tools, and manage user connections seamlessly.
The SDK is thoroughly documented in the docs directory:
For SDK maintainers and contributors:
# Using npm
npm install @composio/core
# Using yarn
yarn add @composio/core
# Using pnpm
pnpm add @composio/core
import { Composio } from '@composio/core';
// Initialize the SDK
const composio = new Composio({
apiKey: 'your-api-key',
});
// Get tools from a specific toolkit
const tools = await composio.tools.get('default', {
toolkits: ['github'],
});
// Get a specific tool
const specificTool = await composio.tools.get('default', 'GITHUB_GET_REPOS');
// Execute a tool
const result = await composio.tools.execute('GITHUB_GET_REPO', {
userId: 'default',
arguments: {
owner: 'composio',
repo: 'sdk',
},
});
console.log(result.data);
import { Composio } from '@composio/core';
import OpenAI from 'openai';
// Initialize Composio and OpenAI
const composio = new Composio({
apiKey: 'your-composio-api-key',
});
const openai = new OpenAI({
apiKey: 'your-openai-api-key',
});
// Get GitHub tools
const tools = await composio.tools.get('default', {
toolkits: ['github'],
});
// Create a chat completion with the tools
const completion = await openai.chat.completions.create({
model: 'gpt-4',
messages: [
{ role: 'system', content: 'You are a helpful assistant with access to GitHub tools.' },
{ role: 'user', content: 'Find information about the Composio SDK repository' },
],
tools, // Pass the tools to OpenAI
});
// If the model wants to use a tool
if (completion.choices[0].message.tool_calls) {
const toolCall = completion.choices[0].message.tool_calls[0];
const args = JSON.parse(toolCall.function.arguments);
// Execute the tool
const result = await composio.tools.execute(toolCall.function.name, {
userId: 'default',
arguments: args,
});
console.log(result.data);
}
import { z } from 'zod';
// Create a custom tool
const customTool = await composio.tools.createCustomTool({
name: 'Weather Forecast',
description: 'Get the weather forecast for a location',
slug: 'WEATHER_FORECAST',
inputParams: z.object({
location: z.string().describe('The location to get the forecast for'),
days: z.number().optional().default(3).describe('Number of days for the forecast')
}),
execute: async (input) => {
try {
const { location, days = 3 } = input;
// Your implementation here
const forecast = [
{ date: '2025-05-21', temperature: 72, conditions: 'Sunny' },
{ date: '2025-05-22', temperature: 68, conditions: 'Partly Cloudy' },
{ date: '2025-05-23', temperature: 65, conditions: 'Rainy' },
];
return {
data: { forecast },
successful: true,
error: null,
};
} catch (error) {
return {
data: {},
successful: false,
error: error.message,
};
}
},
});
composio/
├── packages/ # Main packages directory
│ ├── core/ # Core SDK package
│ └── providers/ # Provider implementations
├── examples/ # Example implementations
│ ├── connected-accounts/ # Connected accounts examples
│ ├── langchain/ # LangChain integration examples
│ ├── openai/ # OpenAI integration examples
│ ├── modifiers/ # Modifiers examples
│ ├── toolkits/ # Toolkits examples
│ └── vercel/ # Vercel AI examples
├── docs/ # Documentation
├── scripts/ # Development and build scripts
└── .github/ # GitHub configuration
Prerequisites
Clone and Install
git clone https://github.com/ComposioHQ/sdk-v3-ts.git
cd composio
pnpm install
Build
pnpm build
Development Commands
# Lint code
pnpm lint
# Fix linting issues
pnpm lint:fix
# Format code
pnpm format
# Create a new provider
pnpm create:provider <provider-name> [--agentic]
# Create a new example
pnpm create:example <example-name>
# Check peer dependencies
pnpm check:peer-deps
# Update peer dependencies
pnpm update:peer-deps
Use the create:example script:
pnpm create:example my-example
The script will create a new example in examples/my-example with:
package.json with minimal dependencies (@composio/core and dotenv)tsconfig.json for TypeScript configuration.env.example and .env files for environment variablessrc/index.ts with basic Composio SDK setupREADME.md with setup and usage instructionsNext steps after creation:
.env and add your COMPOSIO_API_KEYsrc/index.ts with your example logicpnpm start or pnpm dev (with file watching)Use the create:provider script:
pnpm create:provider my-provider [--agentic]
The script will create a new provider in packages/providers/my-provider with:
Implement the required methods in src/index.ts:
wrapTool and wrapToolswrapTool, wrapTools, and execution handlersFor detailed information about both automated and manual release processes, please refer to our Release Process Documentation.
COMPOSIO_API_KEY: Your Composio API keyCOMPOSIO_BASE_URL: Custom API base URL (optional)COMPOSIO_LOG_LEVEL: Logging level (silent, error, warn, info, debug)COMPOSIO_DISABLE_TELEMETRY: Disable telemetry when set to "true"COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_NAME>: Specific version for a toolkit (e.g., COMPOSIO_TOOLKIT_VERSION_GITHUB=20250902_00)DEVELOPMENT: Development mode flagCI: CI environment flagWe welcome contributions! Please see our Contributing Guide for more details.
ISC License
For support, please visit our Documentation or join our Discord Community.