# GitHub Copilot (BYOK)

> Create an API key for GitHub Copilot and add it to AnyRouter.


# GitHub Copilot — Bring Your Own Key

Use your own GitHub Copilot subscription for inference ([BYOK](/features/byok)); no AnyRouter credits are charged. Copilot does not issue a reusable inference key, so you sign in with GitHub or paste a GitHub token and AnyRouter renews the short-lived Copilot session for you.

## Get your API key

1. In the add-key form, choose **Sign in with GitHub**, enter the code at [github.com/login/device](https://github.com/login/device), and approve with the account that has your Copilot plan. The token is filled in for you.
2. Or create a [fine-grained PAT](https://github.com/settings/personal-access-tokens) with the **Copilot Requests** permission and paste it. GitHub's menu path is **Settings > Developer settings > Fine-grained personal access tokens**.
3. Save the key. AnyRouter stores it encrypted and uses it only on requests you route to a Copilot model.

## Gotchas

An active Copilot plan (Free, Pro, Business or Enterprise) is required. Classic `ghp_` tokens are rejected by GitHub. Model availability follows your plan. Individual plans are supported today; Copilot Enterprise proxy endpoints are rejected with an actionable error. This is your own subscription injected into your own requests, never a shared or resold pool.

## How the token is used

Your GitHub token never reaches the inference upstream. AnyRouter exchanges it at `api.github.com/copilot_internal/v2/token` for a short-lived Copilot session token, caches that session in KV, and sends the Copilot-required editor headers with each request. When the session expires it is refreshed automatically. If you paste a `tid=` session token directly it works until it expires, but a GitHub token is strongly preferred because it can be renewed.

## Troubleshooting

| Error | Cause | Fix |
|---|---|---|
| Token exchange returned HTTP 403 | No Copilot plan, or the token lacks Copilot Requests | Check the account and token permissions |
| `401 unauthorized` from the inference API | Session token was minted for a different integration | Re-save the key so a fresh session is minted |
| Enterprise plan error | `proxy-ep` points at a dedicated host | Use an individual plan for now |

## Add it to AnyRouter

1. Open **[Dashboard → BYOK](https://anyrouter.dev/dashboard/byok)**, find **GitHub Copilot** under **Available** and click **Add key**.
2. Paste the key.
3. Click **Save**. AnyRouter validates the key against GitHub Copilot first; on failure the dialog shows the upstream error and nothing is saved.

- Create key: [GitHub Copilot console](https://github.com/settings/tokens)



## Related

- [BYOK Provider Setup Guide](/docs/features/byok-providers.md)
- [Bring Your Own Key (BYOK)](/docs/features/byok.md)
