🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

xc-copilot-api

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xc-copilot-api

Turn GitHub Copilot into OpenAI/Anthropic API compatible server. Usable with Claude Code and Codex

Source
npmnpm
Version
1.2.4
Version published
Weekly downloads
29
-53.97%
Maintainers
1
Weekly downloads
 
Created
Source

Copilot API Proxy

Fork Notice:
The original project by ericc-ch is no longer actively maintained. This fork by billxc updates the project for personal use, adding native passthrough support for the Responses API and Claude API.

[!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:
Excessive automated or scripted use of Copilot (including rapid or bulk requests, such as via automated tools) may trigger GitHub's abuse-detection systems. Use this proxy responsibly to avoid account restrictions.

爱发电

A reverse-engineered proxy for the GitHub Copilot API that exposes it as an OpenAI and Anthropic compatible service. Use GitHub Copilot with Claude Code, Codex CLI, or any tool that supports the OpenAI / Anthropic API.

Note: If you are using opencode, you do not need this project. Opencode supports GitHub Copilot provider out of the box.

Quick Start

# 1. Start the server
npx xc-copilot-api@latest start

# 2. Configure your tool
npx xc-copilot-api@latest config --claude    # Claude Code (Opus 4.7)
npx xc-copilot-api@latest config --codex     # Codex CLI (GPT-5.5)

That's it. Your tool is now powered by GitHub Copilot.

Demo

https://github.com/user-attachments/assets/7654b383-669d-4eb9-b23c-06d7aefee8c5

Features

  • OpenAI & Anthropic Compatibility/v1/chat/completions, /v1/responses, /v1/messages, /v1/embeddings, /v1/models
  • Native Passthrough — Claude and GPT models are forwarded directly to upstream with full protocol fidelity (tool use, streaming, thinking blocks, vision)
  • One-command Setupconfig --claude / config --codex writes the right settings automatically
  • Usage Dashboard — Web UI to monitor quotas and usage statistics
  • Rate Limiting--rate-limit and --wait to stay within GitHub's limits
  • Background Service — Run as a system service via easy-service
  • Multiple Account Types — Individual, business, and enterprise Copilot plans

Using with Claude Code

# Opus 4.7 (default)
npx xc-copilot-api@latest config --claude

# Opus 4.6
npx xc-copilot-api@latest config --claude -m 4.6

A backup of your existing config is saved as settings.json.bak.

Manual configuration

Opus 4.7 (default):

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:4141",
    "ANTHROPIC_AUTH_TOKEN": "Powered by xc copilot",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4.7-1m-internal",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}

Opus 4.6:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:4141",
    "ANTHROPIC_AUTH_TOKEN": "Powered by xc copilot",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4.6-1m",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}

More options: Claude Code settings · IDE integration

Using with Codex CLI

npx xc-copilot-api@latest config --codex
Manual configuration

Add to ~/.codex/config.toml:

model = "gpt-5.5"
model_provider = "copilot-api"

[model_providers.copilot-api]
name = "copilot-api"
base_url = "http://localhost:4141/v1"
wire_api = "responses"

Command Reference

Commands

CommandDescription
startStart the API server (handles auth automatically)
authRun GitHub auth flow only (for generating tokens for CI/CD)
configConfigure Claude Code or Codex CLI to use this proxy
check-usageShow Copilot usage and quota in the terminal
debugDisplay version, runtime, file paths, and auth status

start Options

OptionDescriptionDefaultAlias
--portPort to listen on4141-p
--verboseEnable verbose loggingfalse-v
--account-typeAccount type (individual, business, enterprise)individual-a
--manualManually approve each requestfalse
--rate-limitMinimum seconds between requests-r
--waitWait instead of error when rate limitedfalse-w
--github-tokenProvide GitHub token directly-g
--show-tokenShow tokens on fetch and refreshfalse
--proxy-envInitialize proxy from environment variablesfalse

config Options

OptionDescriptionDefaultAlias
--claudeConfigure Claude Code (~/.claude/settings.json)false-c
--codexConfigure Codex CLI (~/.codex/config.toml)false-x
--claude-modelClaude Opus model version (4.7 or 4.6)4.7-m

API Endpoints

EndpointDescription
POST /v1/chat/completionsOpenAI Chat Completions API
POST /v1/responsesOpenAI Responses API (native passthrough)
POST /v1/messagesAnthropic Messages API (native passthrough)
POST /v1/messages/count_tokensAnthropic token counting
GET /v1/modelsList available models
POST /v1/embeddingsCreate embedding vectors
GET /usageCopilot usage statistics and quota
GET /tokenCurrent Copilot token

Running as a Background Service

# Install easy-service
uv tool install git+https://github.com/billxc/easy-service.git

# Install and start
easy-service install copilot-api -- npx -y xc-copilot-api@latest start

# Manage
easy-service status copilot-api
easy-service logs copilot-api -f
easy-service restart copilot-api
easy-service stop copilot-api
easy-service uninstall copilot-api

Running from Source

bun install        # install dependencies
bun run dev        # development mode
bun run start      # production mode

Prerequisites: Bun >= 1.2.x, GitHub account with Copilot subscription.

Usage Tips

  • Use --rate-limit 30 --wait to stay within Copilot's rate limits without client errors.
  • Use --account-type business or enterprise if you have a business/enterprise Copilot plan. See official docs.
  • Use --manual to approve each request individually for fine-grained control.

Using with Docker

Pre-built Image

docker pull ghcr.io/billxc/copilot-api:latest
mkdir -p ./copilot-data
docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api ghcr.io/billxc/copilot-api:latest

Available tags: latest, v*.*.*, master, <sha>

Build from Source

docker build -t copilot-api .
mkdir -p ./copilot-data
docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api copilot-api

Environment Variables

docker run -p 4141:4141 -e GH_TOKEN=your_token copilot-api

Docker Compose

version: "3.8"
services:
  copilot-api:
    image: ghcr.io/billxc/copilot-api:latest
    ports:
      - "4141:4141"
    environment:
      - GH_TOKEN=your_github_token_here
    volumes:
      - ./copilot-data:/root/.local/share/copilot-api
    restart: unless-stopped

Note: Token data is persisted in copilot-data on your host, mapped to /root/.local/share/copilot-api inside the container.

Update Log

v1.2.3 — Claude Model Selection & Codex 5.5

  • Claude model version selection: New --claude-model (-m) option for config --claude. Choose between Opus 4.7 (default) and Opus 4.6.
  • Codex default model updated: config --codex now defaults to gpt-5.5.
  • Filter unsupported tools in Responses API: Automatically strips image_generation and other unsupported tool types before forwarding to upstream, preventing errors from Codex CLI.
  • Bun idle timeout fix: Increased idleTimeout to 255s to prevent streaming responses from being cut off after 10 seconds.
  • README restructured: Quick Start first, collapsible Docker/Update Log sections, consolidated command reference.

v1.2.1 — easy-service & Config Command

  • New config subcommand: One-command setup for Claude Code (config --claude) and Codex CLI (config --codex).
  • Background service: Replaced built-in daemon with easy-service for cross-platform service management.

v1.1.x — Anthropic 1M Models

  • Anthropic 1M model support: Enhanced beta header handling for claude-opus-4.6-1m and other 1M context models.

v1.0.x — Native Passthrough

  • Native passthrough for Responses API and Claude API: Claude models forward the entire Anthropic Messages request directly to upstream. GPT models forward Responses API requests without transformation.
  • Full protocol fidelity: Tool use, streaming, thinking blocks, vision — all preserved without translation loss.
  • Fallback translation: Non-Claude models hitting /v1/messages still use the Anthropic-to-OpenAI translation layer.

Keywords

proxy

FAQs

Package last updated on 11 May 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