Composio Python SDK Reference

This is the comprehensive SDK reference for the Composio Python SDK.

Main SDK Class

The main entry point for the Composio SDK.

composio.Composio

View source

1composio.Composio(provider: TProvider = <composio.core.provider._openai.OpenAIProvider object at 0x7f8f73dada90>, **kwargs: te.Unpack[SDKConfig])

Composio SDK for Python.

Core Models

Tools

composio.core.models.Tools

View source

1composio.core.models.Tools(client: HttpClient, provider: TProvider)

Tools class definition

This class is used to manage tools in the Composio SDK. It provides methods to list, get, and execute tools.

execute

View source

1execute(slug: str, arguments: t.Dict, connected_account_id: t.Optional[str] = None, custom_auth_params: t.Optional[tool_execute_params.CustomAuthParams] = None, user_id: t.Optional[str] = None, text: t.Optional[str] = None, version: t.Optional[str] = None, modifiers: t.Optional[Modifiers] = None)

Execute a tool with the provided parameters.

This method calls the Composio API or a custom tool handler to execute the tool and returns the response. It automatically determines whether to use a custom tool or a Composio API tool based on the slug.

ParameterDescription
slugThe slug of the tool to execute
argumentsThe arguments to pass to the tool
connected_account_idThe ID of the connected account to use for the tool
custom_auth_paramsThe custom auth params to use for the tool
user_idThe ID of the user to execute the tool for
textThe text to pass to the tool
versionThe version of the tool to execute
modifiersThe modifiers to apply to the tool

Returns: The response from the tool.

get

View source

1get(user_id: str, slug: t.Optional[str] = None, tools: t.Optional[list[str]] = None, search: t.Optional[str] = None, toolkits: t.Optional[list[str]] = None, scopes: t.Optional[t.List[str]] = None, modifiers: t.Optional[Modifiers] = None, limit: t.Optional[int] = None)

Get a tool or list of tools based on the provided arguments.

get_raw_composio_tool_by_slug

View source

1get_raw_composio_tool_by_slug(slug: str)

Returns schema for the given tool slug.

get_raw_composio_tools

View source

1get_raw_composio_tools(tools: t.Optional[list[str]] = None, search: t.Optional[str] = None, toolkits: t.Optional[list[str]] = None, scopes: t.Optional[t.List[str]] = None, limit: t.Optional[int] = None)

Get a list of tool schemas based on the provided filters.

proxy

View source

1proxy(**options: te.Unpack[tool_proxy_params.ToolProxyParams])

Proxy a tool call to the Composio API

Toolkits

composio.core.models.Toolkits

View source

1composio.core.models.Toolkits(client: HttpClient)

Toolkits are a collectiono of tools that can be used to perform various tasks. They’re conceptualized as a set of tools. Ex: Github toolkit can perform Github actions via its collection of tools. This is a replacement of the apps concept in the earlier versions of the SDK.

authorize

View source

1authorize(user_id: str, toolkit: str)

Authorize a user to a toolkit

If auth config is not found, it will be created using composio managed auth.

ParameterDescription
user_idThe ID of the user to authorize
toolkitThe slug of the toolkit to authorize

Returns: The connection request.

get_auth_config_creation_fields

View source

1get_auth_config_creation_fields(toolkit: str, auth_scheme: AuthSchemeL, required_only: bool = False)

Get the required property for a given toolkit and auth scheme.

get_connected_account_initiation_fields

View source

1get_connected_account_initiation_fields(toolkit: str, auth_scheme: AuthSchemeL, required_only: bool = False)

Get the required property for a given toolkit and auth scheme.

list_categories

View source

List all categories of toolkits.

Connected Accounts

composio.core.models.ConnectedAccounts

View source

1composio.core.models.ConnectedAccounts(client: HttpClient)

Manage connected accounts.

This class is used to manage connected accounts in the Composio SDK. These are used to authenticate with third-party services.

initiate

View source

1initiate(user_id: str, auth_config_id: str, callback_url: t.Optional[str] = None, config: t.Optional[connected_account_create_params.ConnectionState] = None)

Compound function to create a new coneected account. This function creates a new connected account and returns a connection request.

Users can then wait for the connection to be established using the wait_for_connection method.

ParameterDescription
user_idThe user ID to create the connected account for
auth_config_idThe auth config ID to create the connected account for
callback_urlCallback URL to use for OAuth apps
optionsThe options to create the connected account with

Returns: The connection request.

wait_for_connection

View source

1wait_for_connection(id: str, timeout: t.Optional[float] = None)

Wait for connected account with given ID to be active

Auth Configs

composio.core.models.AuthConfigs

View source

1composio.core.models.AuthConfigs(client: HttpClient)

Manage authentication configurations.

create

View source

1create(toolkit: str, options: auth_config_create_params.AuthConfig)

Create a new auth config

ParameterDescription
toolkitThe toolkit to create the auth config for
optionsThe options to create the auth config with

Returns: The created auth config.

delete

View source

1delete(nanoid: str)

Deletes an existing authentication configuration.

ParameterDescription
nanoidThe ID of the auth config to delete

Returns: The deleted auth config.

disable

View source

1disable(nanoid: str)

Disables an existing authentication configuration.

ParameterDescription
nanoidThe ID of the auth config to disable

Returns: The disabled auth config.

enable

View source

1enable(nanoid: str)

Enables an existing authentication configuration.

ParameterDescription
nanoidThe ID of the auth config to enable

Returns: The enabled auth config.

get

View source

1get(nanoid: str)

Retrieves a specific authentication configuration by its ID

ParameterDescription
nanoidThe ID of the auth config to retrieve

Returns: The retrieved auth config.

list

View source

1list(**query: te.Unpack[auth_config_list_params.AuthConfigListParams])

Lists authentication configurations based on provided filter criteria.

update

View source

1update(nanoid: str, options: auth_config_update_params.AuthConfigUpdateParams)

Updates an existing authentication configuration.

This method allows you to modify properties of an auth config such as credentials, scopes, or tool restrictions. The update type (custom or default) determines which fields can be updated.

ParameterDescription
nanoidThe ID of the auth config to update
optionsThe options to update the auth config with

Returns: The updated auth config.

Triggers

composio.core.models.Triggers

View source

1composio.core.models.Triggers(client: HttpClient)

Triggers (instance) class

create

View source

1create(slug: str, user_id: t.Optional[str] = None, connected_account_id: t.Optional[str] = None, trigger_config: t.Optional[t.Dict[str, t.Any]] = None)

Create a trigger instance

ParameterDescription
slugThe slug of the trigger
connected_account_idThe ID of the connected account
trigger_configThe configuration of the trigger

Returns: The trigger instance

list_active

View source

1list_active(trigger_ids: t.Optional[list[str]] = None, trigger_names: t.Optional[list[str]] = None, auth_config_ids: t.Optional[list[str]] = None, connected_account_ids: t.Optional[list[str]] = None, show_disabled: t.Optional[bool] = None, limit: t.Optional[int] = None, page: t.Optional[int] = None)

List all active triggers

ParameterDescription
trigger_idsList of trigger IDs to filter by
trigger_namesList of trigger names to filter by
auth_config_idsList of auth config IDs to filter by
connected_account_idsList of connected account IDs to filter by
show_disabledWhether to show disabled triggers
limitLimit the number of triggers to return
pagePage number to return

Returns: List of active triggers

subscribe

View source

1subscribe(timeout: float = 15.0)

Subscribe to a trigger and receive trigger events.

ParameterDescription
timeoutThe timeout to wait for the subscription to be established

Returns: The trigger subscription handler.

Decorators

before_execute

composio.before_execute

View source

1composio.before_execute(modifier: t.Optional[BeforeExecute] = None, tools: t.Optional[t.List[str]] = None, toolkits: t.Optional[t.List[str]] = None)

after_execute

composio.after_execute

View source

1composio.after_execute(modifier: t.Optional[AfterExecute] = None, tools: t.Optional[t.List[str]] = None, toolkits: t.Optional[t.List[str]] = None)

schema_modifier

composio.schema_modifier

View source

1composio.schema_modifier(modifier: t.Optional[SchemaModifier] = None, tools: t.Optional[t.List[str]] = None, toolkits: t.Optional[t.List[str]] = None)

Cross References

The Composio class is the main entry point for all SDK operations. It provides access to:

  • Tools for tool management and execution
  • Toolkits for toolkit operations
  • ConnectedAccounts for managing authentication
  • Triggers for webhook and event handling

When you call Tools.execute, it can use the before_execute() and after_execute() decorators to modify behavior.