copilot-gateway
v0.10.20
Published
Turn GitHub Copilot into an OpenAI/Anthropic compatible gateway. Usable with Claude Code!
Maintainers
Readme
Copilot Gateway
[!WARNING] This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk.
[!WARNING] GitHub Security Notice: Use this proxy responsibly to avoid account restrictions. Excessive automated or scripted use of Copilot (including rapid or bulk requests, such as via automated tools) may trigger GitHub's abuse-detection systems. You may receive a warning from GitHub Security, and further anomalous activity could result in temporary suspension of your Copilot access. Please review:
Note: If you are using opencode, you do not need this project. Opencode supports GitHub Copilot provider out of the box.
Project Overview
A reverse-engineered proxy for the GitHub Copilot API that exposes it as an OpenAI and Anthropic compatible service. This allows you to use GitHub Copilot with any tool that supports the OpenAI Chat Completions API or the Anthropic Messages API, including to power Claude Code.
- OpenAI (
/v1/chat/completions,/v1/responses,/v1/models,/v1/embeddings) and Anthropic (/v1/messages) compatible endpoints - One-command Claude Code setup via
--claude-code - Web-based usage dashboard for monitoring quotas
- Rate limiting (
--rate-limit,--wait) and manual request approval (--manual) - Interactive or token-based auth, with individual / business / enterprise account support
- GitHub Enterprise Server & Cloud compatible
Quick Start
Prerequisites: A GitHub account with Copilot subscription.
1. Start the server (will prompt for GitHub auth on first run):
npx copilot-gateway@latest start2. Use with Claude Code — run with --claude-code to get a ready-to-paste launch command:
npx copilot-gateway@latest start --claude-codeOr manually configure Claude Code by creating .claude/settings.json in your project:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:4141",
"ANTHROPIC_AUTH_TOKEN": "sk-dummy",
"ANTHROPIC_MODEL": "claude-opus-4.6",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-sonnet-4.5",
"ENABLE_TOOL_SEARCH": "true",
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}More options: Claude Code settings · IDE integration
Docker
Pre-built images are published to ghcr.io/feiskyer/copilot-gateway on every release.
docker run -p 4141:4141 ghcr.io/feiskyer/copilot-gateway:latestPass a GitHub token via environment variable:
docker run -p 4141:4141 -e GH_TOKEN=your_github_token_here ghcr.io/feiskyer/copilot-gateway:latestPersist auth across restarts with a bind mount:
mkdir -p ./copilot-data
docker run -p 4141:4141 \
-v $(pwd)/copilot-data:/root/.local/share/copilot-gateway \
ghcr.io/feiskyer/copilot-gateway:latestDocker Compose:
services:
copilot-gateway:
image: ghcr.io/feiskyer/copilot-gateway:latest
ports:
- "4141:4141"
environment:
- GH_TOKEN=your_github_token_here
restart: unless-stoppedTo build from source instead, use docker build -t copilot-gateway .
CLI Options
Subcommands: start, auth, check-usage, debug. Run npx copilot-gateway@latest <command> --help for details.
Commands
start: Start the server (handles auth if needed).auth: Run GitHub auth flow without starting the server.check-usage: Show Copilot usage/quota in the terminal (no server required).debug: Display diagnostic info for troubleshooting.
Start Command Options
| Option | Description | Default | Alias |
| -------------- | ----------------------------------------------------------------------------- | ---------- | ----- |
| --port | Port to listen on | 4141 | -p |
| --verbose | Enable verbose logging | false | -v |
| --account-type | Account type to use (individual, business, enterprise) | individual | -a |
| --manual | Enable manual request approval | false | none |
| --rate-limit | Rate limit in seconds between requests | none | -r |
| --wait | Wait instead of error when rate limit is hit | false | -w |
| --github-token | Provide GitHub token directly (must be generated using the auth subcommand) | none | -g |
| --claude-code | Generate a command to launch Claude Code with Copilot Gateway config | false | -c |
| --show-token | Show GitHub and Copilot tokens on fetch and refresh | false | none |
| --proxy-env | Initialize proxy from environment variables (Node.js runtime only) | false | none |
| --enterprise-url | GitHub Enterprise host to use (eg. https://ghe.example.com) | none | none |
| --api-key | API keys for authentication. Can be specified multiple times | none | none |
Auth Command Options
| Option | Description | Default | Alias | | ------------ | ------------------------- | ------- | ----- | | --verbose | Enable verbose logging | false | -v | | --show-token | Show GitHub token on auth | false | none | | --enterprise-url | GitHub Enterprise host (eg. https://ghe.example.com) | none | none |
Debug Command Options
| Option | Description | Default | Alias | | ------ | ------------------------- | ------- | ----- | | --json | Output debug info as JSON | false | none |
Configuration
Stored at ~/.local/share/copilot-gateway/config.json. Edit to customize prompts, models, and reasoning efforts.
Related files in the same directory:
github_token,enterprise_url, andlogs/.Default shape:
{ "extraPrompts": { "gpt-5-mini": "<built-in exploration prompt>", "gpt-5.1-codex-max": "<built-in exploration prompt>" }, "smallModel": "gpt-5-mini", "modelReasoningEfforts": { "gpt-5-mini": "low" } }extraPrompts: Map of
model -> promptappended to the first system prompt when translating Anthropic-style requests to Copilot. Missing default entries are auto-added without overwriting your custom prompts.smallModel: Fallback model used for tool-less warmup messages (e.g., Claude Code probe requests) to avoid spending premium requests; defaults to
gpt-5-mini.modelReasoningEfforts: Per-model
reasoning.effortsent to the Copilot Responses API. Allowed values arenone,minimal,low,medium,high, andxhigh. If a model isn't listed,highis used by default.
Restart the server after changes so the cached config is refreshed.
Endpoints
OpenAI and Anthropic compatible API endpoints, plus usage monitoring.
OpenAI Compatible
| Endpoint | Method | Description |
| --------------------------- | ------ | ---------------------------------------------------------------- |
| POST /v1/responses | POST | Advanced OpenAI response interface for generating model responses. |
| POST /v1/chat/completions | POST | Creates a model response for the given chat conversation. |
| GET /v1/models | GET | Lists the currently available models. |
| POST /v1/embeddings | POST | Creates an embedding vector representing the input text. |
Aliases without /v1 prefix: /responses, /chat/completions, /models, /embeddings.
Anthropic Compatible
| Endpoint | Method | Description |
| -------------------------------- | ------ | ------------------------------------------------------------ |
| POST /v1/messages | POST | Creates a model response for a given conversation. |
| POST /v1/messages/count_tokens | POST | Calculates the number of tokens for a given set of messages. |
| POST /api/event_logging/batch | POST | Anthropic telemetry log (returns 200). |
Monitoring
| Endpoint | Method | Description |
| ------------ | ------ | ------------------------------------------------------------ |
| GET /usage | GET | Get detailed Copilot usage statistics and quota information. |
| GET /token | GET | Get the current Copilot token being used by the API. |
Authentication
Restrict access with API keys via --api-key. Supports both Authorization: Bearer and x-api-key headers.
- OpenAI format:
Authorization: Bearer your_api_key_here - Anthropic format:
x-api-key: your_api_key_here
# Single API key
npx copilot-gateway@latest start --api-key your_secret_key
# Multiple API keys
npx copilot-gateway@latest start --api-key key1 --api-key key2 --api-key key3When API keys are configured:
- All API endpoints require authentication
- Requests without valid API keys will receive a 401 Unauthorized response
- The root endpoint
/remains accessible without authentication
Examples
Common usage patterns for different account types, rate limiting, and enterprise setups.
# Basic usage with start command
npx copilot-gateway@latest start
# Run on custom port with verbose logging
npx copilot-gateway@latest start --port 4141 --verbose
# Use with a business plan GitHub account
npx copilot-gateway@latest start --account-type business
# Use with an enterprise plan GitHub account
npx copilot-gateway@latest start --account-type enterprise
# Enable manual approval for each request
npx copilot-gateway@latest start --manual
# Set rate limit to 30 seconds between requests
npx copilot-gateway@latest start --rate-limit 30
# Wait instead of error when rate limit is hit
npx copilot-gateway@latest start --rate-limit 30 --wait
# Provide GitHub token directly
npx copilot-gateway@latest start --github-token ghp_YOUR_TOKEN_HERE
# Enable API key authentication with a single key
npx copilot-gateway@latest start --api-key your_secret_key_here
# Enable API key authentication with multiple keys
npx copilot-gateway@latest start --api-key key1 --api-key key2 --api-key key3
# Run only the auth flow
npx copilot-gateway@latest auth
# Show your Copilot usage/quota in the terminal (no server needed)
npx copilot-gateway@latest check-usage
# Display debug information for troubleshooting
npx copilot-gateway@latest debug
# Use GitHub Enterprise / GitHub Enterprise Server
npx copilot-gateway@latest start --account-type enterprise --enterprise-url https://ghe.example.com
# Authenticate with GitHub Enterprise using CLI flag (for scripting)
npx copilot-gateway@latest auth --enterprise-url ghe.example.comUsage Dashboard
A web-based dashboard for monitoring your Copilot API usage and quotas.
After starting the server, a URL to the dashboard will be displayed in your console:
https://feiskyer.github.io/copilot-gateway?endpoint=http://localhost:4141/usage
The dashboard shows usage quotas with progress bars, detailed JSON statistics, and supports custom API endpoint URLs via query parameter.
Development
Build and run from source using Bun.
bun install # Install dependencies
bun run dev # Development mode with watch
bun run start # Production mode
bun run lint # ESLint
bun run typecheck # TypeScript strict checking
bun test # Run all testsTips
Best practices for rate limiting, account types, and enterprise configuration.
- Use
--rate-limit <seconds>with--waitto throttle requests instead of getting errors. - Use
--manualfor full control over when each request is sent. - For business/enterprise Copilot plans, set
--account-type businessor--account-type enterprise. See the official documentation for more details. - For GitHub Enterprise Server/Cloud: use
--enterprise-urlto specify your enterprise host.
Credits
Fork of ericc-ch/copilot-api. Thanks to @ericc-ch and all contributors.
License
This project is licensed under the MIT License.
