> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/composiohq/composio/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK Installation

> Install and set up the Composio Python SDK in your project

## Installation

Install the Composio Python SDK using your preferred package manager:

<CodeGroup>
  ```bash pip theme={null}
  pip install composio
  ```

  ```bash poetry theme={null}
  poetry add composio
  ```
</CodeGroup>

## Requirements

* **Python**: Version 3.9 or higher (Python 3.10+ recommended)
* **pip**: Latest version recommended

## Environment Setup

<Steps>
  <Step title="Get your API key">
    Sign up at [composio.dev](https://composio.dev) and obtain your API key from the dashboard.
  </Step>

  <Step title="Configure environment variables">
    Create a `.env` file in your project root and add your API key:

    ```bash theme={null}
    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
    ```

    <Note>
      For production applications, use a secure method to manage environment variables such as python-dotenv or your deployment platform's secret management.
    </Note>
  </Step>

  <Step title="Initialize the SDK">
    Import and initialize the Composio SDK in your application:

    ```python theme={null}
    import os
    from composio import Composio

    composio = Composio(
        api_key=os.getenv("COMPOSIO_API_KEY"),
    )
    ```
  </Step>
</Steps>

## Verification

Verify your installation by running a simple test:

```python theme={null}
import os
from composio import Composio

composio = Composio(
    api_key=os.getenv("COMPOSIO_API_KEY"),
)

# Test the connection
def verify():
    try:
        user_id = "test-user"
        tools = composio.tools.get(user_id=user_id, toolkits=["HACKERNEWS"])
        print(f"Successfully connected! Found {len(tools)} tools.")
    except Exception as error:
        print(f"Connection failed: {error}")

verify()
```

## Provider-Specific Packages

Depending on your AI framework, you may want to install a provider-specific package:

<CodeGroup>
  ```bash OpenAI theme={null}
  pip install composio-openai
  ```

  ```bash OpenAI Agents theme={null}
  pip install composio-openai-agents
  ```

  ```bash Anthropic theme={null}
  pip install composio-anthropic
  ```

  ```bash LangChain theme={null}
  pip install composio-langchain
  ```

  ```bash LangGraph theme={null}
  pip install composio-langgraph
  ```

  ```bash LlamaIndex theme={null}
  pip install composio-llamaindex
  ```

  ```bash CrewAI theme={null}
  pip install composio-crewai
  ```

  ```bash AutoGen theme={null}
  pip install composio-autogen
  ```

  ```bash Google Gemini theme={null}
  pip install composio-gemini
  ```

  ```bash Google ADK theme={null}
  pip install composio-google-adk
  ```
</CodeGroup>

## Quick Start Example

Here's a complete example using OpenAI Agents:

<Steps>
  <Step title="Install dependencies">
    ```bash theme={null}
    pip install composio-openai-agents openai-agents
    ```
  </Step>

  <Step title="Create your agent">
    ```python theme={null}
    import asyncio
    import os
    from agents import Agent, Runner
    from composio import Composio
    from composio_openai_agents import OpenAIAgentsProvider

    # Initialize Composio client with OpenAI Agents Provider
    composio = Composio(provider=OpenAIAgentsProvider())

    user_id = "user@acme.org"
    tools = composio.tools.get(user_id=user_id, toolkits=["HACKERNEWS"])

    # Create an agent with the tools
    agent = Agent(
        name="Hackernews Agent",
        instructions="You are a helpful assistant.",
        tools=tools,
    )

    # Run the agent
    async def main():
        result = await Runner.run(
            starting_agent=agent,
            input="What's the latest Hackernews post about?",
        )
        print(result.final_output)

    asyncio.run(main())
    ```
  </Step>
</Steps>

## Virtual Environment (Recommended)

It's recommended to use a virtual environment for your Python projects:

<CodeGroup>
  ```bash venv theme={null}
  # Create virtual environment
  python -m venv .venv

  # Activate (Linux/macOS)
  source .venv/bin/activate

  # Activate (Windows)
  .venv\Scripts\activate

  # Install Composio
  pip install composio
  ```

  ```bash poetry theme={null}
  # Initialize poetry project
  poetry init

  # Add Composio
  poetry add composio

  # Activate shell
  poetry shell
  ```
</CodeGroup>

## Next Steps

* Learn about [authentication](/guides/authentication) for connecting external services
* Explore [available tools](/tools/overview) and toolkits
* Build your first [AI agent](/guides/quickstart)
* Check out [Python examples](https://github.com/ComposioHQ/composio/tree/next/python/examples)
