Back to Composio

Composio Class

ts/docs/api/composio.md

0.11.13.6 KB
Original Source

Composio Class

The Composio class is the main entry point to the Composio SDK. It initializes the SDK and provides access to all the core functionality.

Initialization

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

const composio = new Composio({
  apiKey: 'your-api-key',
  baseURL: 'https://api.composio.dev', // Optional: Custom API endpoint
  allowTracking: true, // Optional: Enable/disable telemetry
  autoUploadDownloadFiles: true, // Optional: Enable/disable automatic file handling
  provider: new OpenAIProvider(), // Optional: Custom provider
});

Configuration Options

The Composio constructor accepts a configuration object with the following properties:

PropertyTypeRequiredDefaultDescription
apiKeystringYes-Your Composio API key
baseURLstringNohttps://api.composio.devThe base URL for the Composio API
allowTrackingbooleanNotrueWhether to allow analytics/tracking
autoUploadDownloadFilesbooleanNotrueWhether to automatically handle file operations
providerBaseComposioProviderNonew OpenAIProvider()The provider to use for this Composio instance

Properties

The Composio class provides access to the following core models:

PropertyTypeDescription
toolsToolsAccess to tools functionality
toolkitsToolkitsAccess to toolkits functionality
triggersTriggersAccess to triggers functionality
authConfigsAuthConfigsAccess to auth configs functionality
connectedAccountsConnectedAccountsAccess to connected accounts functionality
filesFilesAccess to file upload/download functionality
providerBaseComposioProviderThe provider being used

Methods

getClient()

Returns the internal Composio API client.

typescript
const client = composio.getClient();

Returns: ComposioClient

Throws: Error if the client is not initialized

Examples

Basic Initialization

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

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

Custom Provider

typescript
import { Composio } from '@composio/core';
import { OpenAIProvider } from '@composio/openai';

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

Disable Tracking

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

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

Disable Automatic File Handling

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

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