Skip to main content

Composio logo

Composio Python SDK

Composio gives your AI agents 1000+ pre-authenticated toolkits, per-user sessions, authentication, triggers, and a sandbox. This package is the Python SDK.

Install

Requires Python 3.10+.

pip install composio

Quickstart

Create a session for one of your users and hand its tools to your agent:

from composio import Composio

composio = Composio()  # reads COMPOSIO_API_KEY, or pass api_key=...

session = composio.create(user_id="user_123")
tools = session.tools()  # OpenAI-format tool definitions by default

By default a session gets meta tools that discover, authenticate, and execute app tools at runtime, so you don't load hundreds of tool definitions into context. Store session.session_id and reuse the session across turns:

session = composio.use(session_id)

See how Composio works for sessions and meta tools, and configuring sessions for restricting toolkits, tools, auth_configs, and connected_accounts on composio.create().

Use with an agent framework

Provider packages adapt session.tools() to your framework's native tool format. With OpenAI Agents:

pip install composio composio-openai-agents openai-agents
from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner

composio = Composio(provider=OpenAIAgentsProvider())

session = composio.create(user_id="user_123")
tools = session.tools()

agent = Agent(
    name="Personal Assistant",
    instructions="You are a helpful assistant. Use Composio tools to take action.",
    tools=tools,
)

result = Runner.run_sync(starting_agent=agent, input="Summarize my emails from today")
print(result.final_output)

Other Python providers: composio-openai, composio-anthropic, composio-claude-agent-sdk, composio-langchain, composio-langgraph, composio-llamaindex, composio-crewai, composio-autogen, composio-gemini, composio-google, composio-google-adk. Don't see yours? Build a custom provider.

MCP

Every session also exposes a hosted MCP endpoint. Pass mcp=True and point Claude, Cursor, or any MCP client at it:

from composio import Composio

composio = Composio()

session = composio.create(user_id="user_123", mcp=True)
print(session.mcp.url)      # MCP endpoint for this session
print(session.mcp.headers)  # auth headers for the endpoint

See sessions via MCP.

Authentication

Sessions manage connections for you by default; the agent walks the user through OAuth with the session's meta tools. To drive the flow yourself, authorize a toolkit from the session:

connection_request = session.authorize("gmail")
print(connection_request.redirect_url)  # send the user here to approve access
connection_request.wait_for_connection()

See authentication for auth configs, custom OAuth apps, and connection lifecycle.

Triggers

Subscribe to events from connected apps (new email, new commit, and so on) and react to them:

from composio import Composio

composio = Composio()

trigger = composio.triggers.create(
    slug="GITHUB_COMMIT_EVENT",
    user_id="user_123",
    trigger_config={"owner": "composiohq", "repo": "composio"},
)

subscription = composio.triggers.subscribe()

@subscription.handle(trigger_id=trigger.trigger_id)
def handle_event(data):
    print("Event received:", data)

subscription.wait_forever()

subscribe() streams events over a WebSocket for local development. In production, register a webhook URL and parse deliveries with composio.triggers.parse(). See setting up triggers.

Development

This package lives in the Composio SDK monorepo under python/. See the contribution guidelines to get set up.

Support

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

composio-0.19.0.tar.gz (260.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

composio-0.19.0-py3-none-any.whl (165.5 kB view details)

Uploaded Python 3

File details

Details for the file composio-0.19.0.tar.gz.

File metadata

  • Download URL: composio-0.19.0.tar.gz
  • Upload date:
  • Size: 260.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for composio-0.19.0.tar.gz
Algorithm Hash digest
SHA256 828d4072d35b511f44d97575801e2bf1412dbbe4c51c33f165b151d2da98b083
MD5 2d18b07bf5b4458e396e29a5d3972254
BLAKE2b-256 6bcbf76d015ec30a2c67dd9946e3e3d139b0d906842830f42a0718962d38ffc9

See more details on using hashes here.

File details

Details for the file composio-0.19.0-py3-none-any.whl.

File metadata

  • Download URL: composio-0.19.0-py3-none-any.whl
  • Upload date:
  • Size: 165.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for composio-0.19.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c3b6884cf2b82e103fe0dcf269167d6fa0d885c6d889e9ddcb11b9031148ea2
MD5 2caede46d421ec627e7b80124226ef09
BLAKE2b-256 4f9ca5e869f2b922f06daef36f074e5a23c19b4872da343af2547c4e44c90612

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page