> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/cloud-cost-management/integrations/ai-providers/github-copilot.md).

# GitHub Copilot

Connect GitHub Copilot to bring your AI coding spend into Cloud & AI Cost Management alongside your cloud costs.

Connecting GitHub Copilot brings your GitHub Copilot spend into Harness Cloud & AI Cost Management alongside your cloud costs. The connector uses an Admin key with read-only access to pull usage and cost data from your GitHub Copilot account. You can analyze AI spend in Cost Explorer, attribute it with Views and Cost Categories, and govern it with budgets and anomaly detection, the same way you manage cloud costs.

## Before You Begin <a href="#before-you-begin" id="before-you-begin"></a>

**GitHub Copilot Admin key:** An Admin key with read-only access from your GitHub organization. The key enables Harness to ingest billing and usage data. Go to the [GitHub Copilot metrics API documentation](https://docs.github.com/en/rest/copilot/copilot-metrics) to review the required scopes.

## Create the GitHub Copilot Admin Key <a href="#create-the-github-copilot-admin-key" id="create-the-github-copilot-admin-key"></a>

Harness retrieves Copilot usage and billing data through a GitHub personal access token (classic).

1. In GitHub, go to **Settings** > **Developer settings** > **Personal access tokens** > **Tokens (classic)**, or open [github.com/settings/tokens](https://github.com/settings/tokens) directly.
2. Click **Generate new token** > **Generate new token (classic)**, then provide a descriptive name, for example, `Harness CCM Integration`.
3. Set the **Expiration** to **No expiration** (or the longest available option) so ingestion does not stop when the token expires.
4. Select the scope that matches your account type:
   * **Organization:** `read:org`
   * **Enterprise:** `manage_billing:copilot` or `read:enterprise`
5. Click **Generate token**, then copy it and store it securely. GitHub does not display the token again after creation.

{% hint style="info" %}
You must be an organization or enterprise **owner** or **billing manager** (or hold the fine-grained **View Copilot Metrics** permission), and the **Copilot usage metrics** policy must be enabled for the account before the metrics endpoints return data.
{% endhint %}

## Set Up the GitHub Copilot Connector <a href="#set-up-the-github-copilot-connector" id="set-up-the-github-copilot-connector"></a>

To connect GitHub Copilot, go to **Cloud & AI Cost Management** > **Account Settings** > **AI Providers**, click **AI Provider**, and then select **GitHub Copilot**.

### Step 1: Name the Connector <a href="#step-1-name-the-connector" id="step-1-name-the-connector"></a>

1. On the **Overview** panel, enter a **Name** for the connector.
2. Optionally, add a **Description** and **Tags** to organize and filter connectors.

<figure><img src="https://1217180450-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO2HVWkYMptNUG08jo8hr%2Fuploads%2Fgit-blob-7d36c6a781704a9b457236f7d5ce62cf378e096d%2Fgithub-copilot-one.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

3. Click **Continue**.

### Step 2: Add the API Key <a href="#step-2-add-the-api-key" id="step-2-add-the-api-key"></a>

On the **Connector Details** panel, provide the GitHub Copilot Admin key you created in [Create the GitHub Copilot Admin Key](#create-the-github-copilot-admin-key) as a Harness secret. Do the following:

<figure><img src="https://1217180450-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO2HVWkYMptNUG08jo8hr%2Fuploads%2Fgit-blob-4c4f9fa35ba4c02458ceb3e0fee4562824156aad%2Fgithub-copilot-two.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

1. In the **API Key** field, click **Create or Select a Secret**.
   * To use an existing secret that contains your GitHub Copilot Admin key, select it from the list, then click **Apply Selected**.
   * To add a new secret, click **New Secret Text**, enter a **Secret Name**, and provide the GitHub Copilot Admin key you created as the **Secret Value**.

     <figure><img src="https://1217180450-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO2HVWkYMptNUG08jo8hr%2Fuploads%2Fgit-blob-b3216f7bb7e3376c22d32b547d88e6118e4e6a0a%2Fgithub-copilot-three.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

     Go to [Add and reference text secrets](https://developer.harness.io/harness-ai/use-harness-platform/secrets/add-use-text-secrets) to review all secret creation options.
2. Click **Continue**.

### Step 3: Verify the Connection <a href="#step-3-verify-the-connection" id="step-3-verify-the-connection"></a>

On the **Connection Test** panel, Harness validates the API key against your GitHub Copilot account. Once the verification is successful, click **Finish** to create the connector.

<figure><img src="https://1217180450-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FO2HVWkYMptNUG08jo8hr%2Fuploads%2Fgit-blob-43dfaadc3bec061d31a6c8c8d3aa77c30a1a87ba%2Fgithub-copilot-five.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

{% @harness-feedback/feedback %}
