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:
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:
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
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
- Open RewriteBar and go to Settings -> AI Providers.
- Choose your OpenAI-compatible provider setup.
- Set API Key to your Copilot token.
- Set Base URL to
https://api.githubcopilot.com. - In advanced/custom headers, add
Copilot-Integration-Id: vscode-chat. - 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
- Typical local endpoints:
- Node server:
http://localhost:3000/v1 - Python server:
http://localhost:5000/v1
- Node server:
- 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
- Default local endpoint:
http://localhost:3000/v1 - In RewriteBar:
- Base URL:
http://localhost:3000/v1 - API Key: placeholder value (for example
n/a)
- Base URL:
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-chatis set for direct endpoint usage. - Connection refused: local proxy is not running, or the port/base URL is wrong.