---
title: "GitHub Copilot Setup Guide for RewriteBar"
description: "Connect GitHub Copilot to RewriteBar with a compatible endpoint and use your Copilot subscription for AI writing tasks on macOS."
url: "https://rewritebar.com/docs/ai-providers/github"
---

# GitHub Copilot

GitHub Copilot provides an OpenAI-compatible endpoint that is used by the VS Code extension. This means you can use your GitHub Copilot subscription with RewriteBar without consuming any extra API tokens.

## Before You Start

- You need an active GitHub Copilot subscription.
- This setup uses unofficial or community-maintained integrations.

## Option 1: Direct GitHub Copilot Endpoint

Use this if you want to call GitHub Copilot directly.

### 1\. Get an access token (device flow)

Request a device code:

```bash
curl -X POST 'https://github.com/login/device/code' \
  -H 'accept: application/json' \
  -H 'content-type: application/json' \
  -d '{"client_id":"Iv1.b507a08c87ecfe98","scope":"read:user"}'

```

Open the `verification_uri` from the response, enter the `user_code`, and approve.

Then exchange the device code for an access token:

```bash
curl -X POST 'https://github.com/login/oauth/access_token' \
  -H 'accept: application/json' \
  -H 'content-type: application/json' \
  -d '{"client_id":"Iv1.b507a08c87ecfe98","device_code":"YOUR_DEVICE_CODE","grant_type":"urn:ietf:params:oauth:grant-type:device_code"}'

```

### 2\. Exchange access token for Copilot token

```bash
curl -X GET 'https://api.github.com/copilot_internal/v2/token' \
  -H 'authorization: token YOUR_ACCESS_TOKEN'

```

Copy the `token` value from the response.

### 3\. Configure RewriteBar

1. Open RewriteBar and go to **Settings** \-> **AI Providers**.
2. Choose your OpenAI-compatible provider setup.
3. Set **API Key** to your Copilot token.
4. Set **Base URL** to `https://api.githubcopilot.com`.
5. In advanced/custom headers, add `Copilot-Integration-Id: vscode-chat`.
6. Fetch models, pick one, then click **Verify and Enable**.

## Option 2: Use a Local Proxy

Use this if you want a local OpenAI-compatible `/v1` endpoint.

### A) `copilot-to-api`

- Repo: [github.com/Alorse/copilot-to-api](https://github.com/Alorse/copilot-to-api)
- Typical local endpoints:  
  - Node server: `http://localhost:3000/v1`
  - Python server: `http://localhost:5000/v1`
- In RewriteBar:  
  - **Base URL**: one of the local URLs above
  - **API Key**: placeholder value (for example `dummy-key`)

### B) `copilot-proxy` (VS Code extension)

- Repo: [github.com/lutzleonhardt/copilot-proxy](https://github.com/lutzleonhardt/copilot-proxy)
- Default local endpoint: `http://localhost:3000/v1`
- In RewriteBar:  
  - **Base URL**: `http://localhost:3000/v1`
  - **API Key**: placeholder value (for example `n/a`)

## Troubleshooting

- **401 Unauthorized**: Copilot token is expired. Generate a new token.
- **403 Forbidden**: check Copilot subscription/account permissions.
- **No models / request fails**: ensure `Copilot-Integration-Id: vscode-chat` is set for direct endpoint usage.
- **Connection refused**: local proxy is not running, or the port/base URL is wrong.

## References

- [Alorse/copilot-to-api](https://github.com/Alorse/copilot-to-api)
- [lutzleonhardt/copilot-proxy](https://github.com/lutzleonhardt/copilot-proxy)
- [Aider Docs - GitHub Copilot](https://aider.chat/docs/llms/github.html)
