Skip to main content

Local GitHub Copilot API proxy โ€” use GPT-4o, Claude, Gemini via OpenAI/Anthropic compatible APIs

Project description

๐Ÿš€ CopilotX

Local GitHub Copilot API proxy โ€” use GPT-4o, Claude, Gemini and more via OpenAI/Anthropic compatible APIs.

Turn your GitHub Copilot subscription into a local AI API server. Use any model available through Copilot with any tool that supports OpenAI or Anthropic SDKs.

โœจ Features

  • ๐Ÿ” GitHub OAuth โ€” One-command login via Device Flow, or use existing token
  • ๐Ÿ”„ Auto Token Refresh โ€” Copilot JWT refreshed transparently before expiry
  • ๐Ÿ”Œ Dual API Format โ€” OpenAI /v1/chat/completions + Anthropic /v1/messages
  • ๐ŸŒŠ SSE Streaming โ€” Real-time streaming responses for both formats
  • ๐Ÿ“‹ Model Discovery โ€” Auto-fetch available models from Copilot
  • โšก Zero Config โ€” pip install โ†’ auth login โ†’ serve โ†’ done

๐Ÿš€ Quick Start

1. Install

pip install copilotx
# or
uv pip install copilotx

2. Authenticate

# Option A: OAuth Device Flow (recommended)
copilotx auth login
# โ†’ Opens browser for GitHub authorization

# Option B: Use existing GitHub token
copilotx auth login --token ghp_xxxxx
# or
export GITHUB_TOKEN=ghp_xxxxx && copilotx auth login

3. Start Server

copilotx serve

Output:

๐Ÿš€ CopilotX v1.0.0
โœ… Copilot Token valid (28m remaining, auto-refresh)
๐Ÿ“‹ Models: gpt-4o, gpt-4o-mini, o3-mini, claude-sonnet-4, gemini-2.0-flash

๐Ÿ”— OpenAI API:    http://127.0.0.1:24680/v1/chat/completions
๐Ÿ”— Anthropic API: http://127.0.0.1:24680/v1/messages
๐Ÿ”— Models:        http://127.0.0.1:24680/v1/models

Press Ctrl+C to stop

4. Use It

Python (OpenAI SDK):

from openai import OpenAI

client = OpenAI(base_url="http://localhost:24680/v1", api_key="copilotx")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")

Python (Anthropic SDK):

from anthropic import Anthropic

client = Anthropic(base_url="http://localhost:24680", api_key="copilotx")

message = client.messages.create(
    model="claude-sonnet-4",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)

Claude Code:

# Set environment variables
export ANTHROPIC_BASE_URL=http://localhost:24680
export ANTHROPIC_API_KEY=copilotx
claude

Codex:

export OPENAI_BASE_URL=http://localhost:24680/v1
export OPENAI_API_KEY=copilotx
codex

cURL:

curl http://localhost:24680/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

๐Ÿ“ก API Endpoints

Endpoint Method Description
/v1/chat/completions POST OpenAI-compatible chat completions
/v1/messages POST Anthropic-compatible messages
/v1/models GET List available models
/health GET Server health + token status

๐Ÿ”ง CLI Commands

copilotx auth login              # OAuth Device Flow login
copilotx auth login --token XXX  # Quick login with existing token
copilotx auth status             # Show auth status
copilotx auth logout             # Clear credentials

copilotx models                  # List available models
copilotx serve                   # Start server (default: 127.0.0.1:24680)
copilotx serve --port 9090       # Custom port (strict โ€” fails if in use)
copilotx --version               # Show version

๐Ÿ—๏ธ How It Works

Your Tool (Claude Code / Codex / Python script)
    โ”‚
    โ”‚  OpenAI or Anthropic format
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  CopilotX (localhost:24680)  โ”‚
โ”‚                              โ”‚
โ”‚  โ€ข Anthropic โ†’ OpenAI        โ”‚
โ”‚    format translation        โ”‚
โ”‚  โ€ข Token auto-refresh        โ”‚
โ”‚  โ€ข SSE stream forwarding     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚  OpenAI format
               โ–ผ
  api.githubcopilot.com/chat/completions
  (GPT-4o, Claude, Gemini, o3-mini, ...)

CopilotX uses your GitHub Copilot subscription to access models. The Copilot backend natively speaks OpenAI format, so OpenAI requests are direct passthrough. Anthropic requests are translated on-the-fly.

๐Ÿ” Port Discovery

When CopilotX starts, it writes ~/.copilotx/server.json:

{
  "host": "127.0.0.1",
  "port": 24680,
  "pid": 12345,
  "started_at": "2026-02-09T12:00:00+00:00",
  "base_url": "http://127.0.0.1:24680"
}

Other scripts can read this to discover the actual port:

# Bash/Zsh
PORT=$(python -c "import json; print(json.load(open('$HOME/.copilotx/server.json'))['port'])")
curl http://localhost:$PORT/health

# PowerShell
$info = Get-Content "$HOME\.copilotx\server.json" | ConvertFrom-Json
curl http://localhost:$($info.port)/health

The file is automatically cleaned up when the server stops.

โš ๏ธ Disclaimer

This tool is for personal local use only. Please comply with GitHub Copilot Terms of Service. The author is not responsible for any account restrictions resulting from misuse.

๐Ÿ“„ License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copilotx-1.0.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

copilotx-1.0.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file copilotx-1.0.0.tar.gz.

File metadata

  • Download URL: copilotx-1.0.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for copilotx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 40cecf8e09472d591189870b4b3bd3b2d193d71144f06ea1a4698aedfb593f52
MD5 8ff73f6b082ef75af8c30b577647d2a2
BLAKE2b-256 5d7358945eb5799296245ff0b7da7dffaf8d7ab7db32b759edb96519146f3818

See more details on using hashes here.

File details

Details for the file copilotx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: copilotx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for copilotx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b403e4cc059f7805d2ba9901e3f9dd5e4ff5f0a01889def9b51098ea92bc6ed9
MD5 1054dbf034a616dca796cc70a1ae559d
BLAKE2b-256 3e44fe3f2f2e05595c648bccc4047e6d0ce0b3de624752d7415b313a920dbbc7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page