New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

copilot-gateway

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copilot-gateway

Turn GitHub Copilot into an OpenAI/Anthropic compatible gateway. Usable with Claude Code!

latest
Source
npmnpm
Version
0.10.6
Version published
Weekly downloads
94
-30.37%
Maintainers
1
Weekly downloads
 
Created
Source

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:

  • GitHub Acceptable Use Policies
  • GitHub Copilot Terms

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 start

2. Use with Claude Code — run with --claude-code to get a ready-to-paste launch command:

npx copilot-gateway@latest start --claude-code

Or 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.

View Docker usage details
docker run -p 4141:4141 ghcr.io/feiskyer/copilot-gateway:latest

Pass a GitHub token via environment variable:

docker run -p 4141:4141 -e GH_TOKEN=your_github_token_here ghcr.io/feiskyer/copilot-gateway:latest

Persist 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:latest

Docker Compose:

services:
  copilot-gateway:
    image: ghcr.io/feiskyer/copilot-gateway:latest
    ports:
      - "4141:4141"
    environment:
      - GH_TOKEN=your_github_token_here
    restart: unless-stopped

To 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.

View all commands and flags

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

OptionDescriptionDefaultAlias
--portPort to listen on4141-p
--verboseEnable verbose loggingfalse-v
--account-typeAccount type to use (individual, business, enterprise)individual-a
--manualEnable manual request approvalfalsenone
--rate-limitRate limit in seconds between requestsnone-r
--waitWait instead of error when rate limit is hitfalse-w
--github-tokenProvide GitHub token directly (must be generated using the auth subcommand)none-g
--claude-codeGenerate a command to launch Claude Code with Copilot Gateway configfalse-c
--show-tokenShow GitHub and Copilot tokens on fetch and refreshfalsenone
--proxy-envInitialize proxy from environment variables (Node.js runtime only)falsenone
--enterprise-urlGitHub Enterprise host to use (eg. https://ghe.example.com)nonenone
--api-keyAPI keys for authentication. Can be specified multiple timesnonenone

Auth Command Options

OptionDescriptionDefaultAlias
--verboseEnable verbose loggingfalse-v
--show-tokenShow GitHub token on authfalsenone
--enterprise-urlGitHub Enterprise host (eg. https://ghe.example.com)nonenone

Debug Command Options

OptionDescriptionDefaultAlias
--jsonOutput debug info as JSONfalsenone

Configuration

Stored at ~/.local/share/copilot-gateway/config.json. Edit to customize prompts, models, and reasoning efforts.

View config format and options
  • Related files in the same directory: github_token, enterprise_url, and logs/.

  • 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 -> prompt appended 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.effort sent to the Copilot Responses API. Allowed values are none, minimal, low, medium, high, and xhigh. If a model isn't listed, high is used by default.

Restart the server after changes so the cached config is refreshed.

Endpoints

OpenAI and Anthropic compatible API endpoints, plus usage monitoring.

View all endpoints

OpenAI Compatible

EndpointMethodDescription
POST /v1/responsesPOSTAdvanced OpenAI response interface for generating model responses.
POST /v1/chat/completionsPOSTCreates a model response for the given chat conversation.
GET /v1/modelsGETLists the currently available models.
POST /v1/embeddingsPOSTCreates an embedding vector representing the input text.

Aliases without /v1 prefix: /responses, /chat/completions, /models, /embeddings.

Anthropic Compatible

EndpointMethodDescription
POST /v1/messagesPOSTCreates a model response for a given conversation.
POST /v1/messages/count_tokensPOSTCalculates the number of tokens for a given set of messages.
POST /api/event_logging/batchPOSTAnthropic telemetry log (returns 200).

Monitoring

EndpointMethodDescription
GET /usageGETGet detailed Copilot usage statistics and quota information.
GET /tokenGETGet 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.

View authentication details
  • 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 key3

When 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.

View example commands
# 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.com

Usage Dashboard

A web-based dashboard for monitoring your Copilot API usage and quotas.

View dashboard setup

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.

View development commands
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 tests

Tips

Best practices for rate limiting, account types, and enterprise configuration.

View tips
  • Use --rate-limit <seconds> with --wait to throttle requests instead of getting errors.
  • Use --manual for full control over when each request is sent.
  • For business/enterprise Copilot plans, set --account-type business or --account-type enterprise. See the official documentation for more details.
  • For GitHub Enterprise Server/Cloud: use --enterprise-url to 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.

Keywords

proxy

FAQs

Package last updated on 25 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts