# How to Install the GitHub Copilot SDK for Python: Complete Setup Guide

> Learn how to install the GitHub Copilot SDK for Python with our easy setup guide. Get started with `pip install github-copilot-sdk` and import CopilotClient.

- Repository: [GitHub/copilot-sdk](https://github.com/github/copilot-sdk)
- Tags: how-to-guide
- Published: 2026-07-18

---

**Install the GitHub Copilot SDK for Python by running `pip install github-copilot-sdk` in a Python ≥3.8 environment, then import `CopilotClient` from the `copilot` package to begin making requests.**

The **GitHub Copilot SDK for Python** is officially distributed through PyPI under the package name `github-copilot-sdk`. As implemented in the `github/copilot-sdk` repository, this SDK bundles the Copilot CLI runtime and manages its lifecycle automatically, enabling direct Python-native access to Copilot completions and agentic capabilities without manual binary management.

## Prerequisites

Before installing, ensure your environment meets the baseline requirements.

- **Python version 3.8 or higher**. The SDK relies on modern `asyncio` and typing features introduced in Python 3.8.
- **`pip` package manager** (version 20.0+ recommended for reliable dependency resolution).

Verify your Python version:

```bash
python --version

```

## Installation Steps

### Step 1: Install from PyPI

Run the installation command to pull the latest stable release. This command automatically downloads the SDK and its dependencies, including logic in [`python/copilot/_cli_download.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/_cli_download.py) that handles bundling the Copilot CLI binary for your platform.

```bash
pip install github-copilot-sdk

```

### Step 2: Verify the Installation

Confirm the package is correctly installed by checking the version string exposed in [`python/copilot/__init__.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/__init__.py):

```bash
python -c "import copilot; print(copilot.__version__)"

```

If installed correctly, this prints the SDK version number without import errors.

## Authentication Configuration

The SDK supports multiple authentication mechanisms. By default, it uses tokens stored by the Copilot CLI (`copilot login`), but you can override this behavior.

### Using Environment Variables

Set one of the following environment variables to authenticate without the CLI:

- `COPILOT_GITHUB_TOKEN`
- `GH_TOKEN`
- `GITHUB_TOKEN`

```bash
export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"
python your_script.py

```

### Using a BYOK Provider

For Bring-Your-Own-Key (BYOK) scenarios, configure a custom provider via the `BYOKProvider` class. This is useful when integrating with alternative model endpoints:

```python
import os
from copilot import CopilotClient, BYOKProvider

os.environ["OPENAI_API_KEY"] = "sk-..."

byok = BYOKProvider(
    provider="openai",
    model="gpt-4o-mini",
    api_key=os.getenv("OPENAI_API_KEY"),
)

client = CopilotClient(auth=byok)

```

Detailed authentication flows are documented in [`docs/auth/README.md`](https://github.com/github/copilot-sdk/blob/main/docs/auth/README.md) within the repository.

## First SDK Usage

Once installed, create a client instance. The `CopilotClient` class (exposed in [`python/copilot/__init__.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/__init__.py)) automatically launches the bundled Copilot CLI in the background and manages JSON-RPC communication via the transport layer implemented in [`python/copilot/_jsonrpc.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/_jsonrpc.py).

```python
from copilot import CopilotClient

client = CopilotClient()
response = client.completions.create(
    prompt="Write a function that returns the factorial of n.",
    max_tokens=100,
)
print(response.choices[0].text)

```

The client handles streaming results, tool invocation, and lifecycle management without additional setup code.

## Internal Architecture

Understanding the key source files helps troubleshoot installation issues:

- **[`python/copilot/_cli_download.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/_cli_download.py)**: Manages downloading and caching the Copilot CLI binary for environments where it is not pre-installed.
- **[`python/copilot/_jsonrpc.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/_jsonrpc.py)**: Implements the JSON-RPC transport layer that the client uses to communicate with the Copilot CLI process.
- **[`python/copilot/_telemetry.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/_telemetry.py)**: Manages optional telemetry collection (can be disabled via client options).

## Summary

- **PyPI Package**: Install `github-copilot-sdk` via `pip` in Python ≥3.8 environments.
- **Automatic CLI Management**: The SDK bundles and manages the Copilot CLI runtime; no separate binary installation is required.
- **Flexible Auth**: Supports CLI tokens, environment variables (`GITHUB_TOKEN`, `GH_TOKEN`), or BYOK providers.
- **Entry Point**: Use `CopilotClient` from the `copilot` package to begin making API calls immediately after installation.

## Frequently Asked Questions

### What Python versions are supported by the GitHub Copilot SDK?

The SDK requires **Python 3.8 or higher**. This requirement is enforced because the SDK uses modern `asyncio` patterns and type hinting features that are not available in earlier Python versions.

### Do I need to install the GitHub Copilot CLI separately?

No. The SDK bundles the Copilot CLI runtime and automatically handles its installation and lifecycle. The logic in [`python/copilot/_cli_download.py`](https://github.com/github/copilot-sdk/blob/main/python/copilot/_cli_download.py) downloads the appropriate binary for your platform the first time you instantiate `CopilotClient`.

### Can I use the SDK in an air-gapped environment?

Yes, but you must configure a **BYOK (Bring-Your-Own-Key) provider** rather than relying on the default GitHub Copilot service. Configure this via the `BYOKProvider` class and provide your own model endpoint credentials, as the default mode requires internet access to GitHub's Copilot API.

### How do I uninstall the GitHub Copilot SDK?

Run the standard pip uninstall command:

```bash
pip uninstall github-copilot-sdk

```

This removes the Python package and the cached CLI binary downloaded by [`_cli_download.py`](https://github.com/github/copilot-sdk/blob/main/_cli_download.py), though it will not affect global Copilot CLI installations made separately by the user.