xc-copilot-api
v1.2.5
Published
Turn GitHub Copilot into OpenAI/Anthropic API compatible server. Usable with Claude Code and Codex
Maintainers
Readme
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 Setup —
config --claude/config --codexwrites the right settings automatically - Usage Dashboard — Web UI to monitor quotas and usage statistics
- Rate Limiting —
--rate-limitand--waitto 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.6A backup of your existing config is saved as settings.json.bak.
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 --codexAdd 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
| Command | Description |
| ------------- | ------------------------------------------------------------------ |
| start | Start the API server (handles auth automatically) |
| auth | Run GitHub auth flow only (for generating tokens for CI/CD) |
| config | Configure Claude Code or Codex CLI to use this proxy |
| check-usage | Show Copilot usage and quota in the terminal |
| debug | Display version, runtime, file paths, and auth status |
start Options
| Option | Description | Default | Alias | | -------------- | ------------------------------------------------------ | ---------- | ----- | | --port | Port to listen on | 4141 | -p | | --verbose | Enable verbose logging | false | -v | | --account-type | Account type (individual, business, enterprise) | individual | -a | | --manual | Manually approve each request | false | | | --rate-limit | Minimum seconds between requests | | -r | | --wait | Wait instead of error when rate limited | false | -w | | --github-token | Provide GitHub token directly | | -g | | --show-token | Show tokens on fetch and refresh | false | | | --proxy-env | Initialize proxy from environment variables | false | |
config Options
| Option | Description | Default | Alias |
| -------------- | ------------------------------------------------- | ------- | ----- |
| --claude | Configure Claude Code (~/.claude/settings.json) | false | -c |
| --codex | Configure Codex CLI (~/.codex/config.toml) | false | -x |
| --claude-model | Claude Opus model version (4.7 or 4.6) | 4.7 | -m |
API Endpoints
| Endpoint | Description |
| -------------------------------- | ---------------------------------------------- |
| POST /v1/chat/completions | OpenAI Chat Completions API |
| POST /v1/responses | OpenAI Responses API (native passthrough) |
| POST /v1/messages | Anthropic Messages API (native passthrough) |
| POST /v1/messages/count_tokens | Anthropic token counting |
| GET /v1/models | List available models |
| POST /v1/embeddings | Create embedding vectors |
| GET /usage | Copilot usage statistics and quota |
| GET /token | Current 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-apiRunning from Source
bun install # install dependencies
bun run dev # development mode
bun run start # production modePrerequisites: Bun >= 1.2.x, GitHub account with Copilot subscription.
Usage Tips
- Use
--rate-limit 30 --waitto stay within Copilot's rate limits without client errors. - Use
--account-type businessorenterpriseif you have a business/enterprise Copilot plan. See official docs. - Use
--manualto approve each request individually for fine-grained control.
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:latestAvailable 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-apiEnvironment Variables
docker run -p 4141:4141 -e GH_TOKEN=your_token copilot-apiDocker 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-stoppedNote: Token data is persisted in
copilot-dataon your host, mapped to/root/.local/share/copilot-apiinside the container.
v1.2.3 — Claude Model Selection & Codex 5.5
- Claude model version selection: New
--claude-model(-m) option forconfig --claude. Choose between Opus 4.7 (default) and Opus 4.6. - Codex default model updated:
config --codexnow defaults togpt-5.5. - Filter unsupported tools in Responses API: Automatically strips
image_generationand other unsupported tool types before forwarding to upstream, preventing errors from Codex CLI. - Bun idle timeout fix: Increased
idleTimeoutto 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
configsubcommand: 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-1mand 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/messagesstill use the Anthropic-to-OpenAI translation layer.
