Use GitHub Copilot with any OpenAI-compatible client
A local proxy server that exposes OpenAI-compatible API endpoints, forwarding requests to the GitHub Copilot Chat API. Use GitHub Copilot with any client that supports the OpenAI API — Open WebUI, Chatbox, BoltAI, Elephas, Cline, Aider, and more.
Getting Started · Configuration · Client Setup · API Reference
- 🔄 OpenAI-compatible API — drop-in replacement for
api.openai.com - 🌊 Streaming support — real-time SSE streaming, just like OpenAI
- 🔐 Automatic auth — GitHub OAuth Device Flow, no tokens to manage
- 🧠 40+ models — GPT-4o, Claude, Gemini, o3-mini, and more via Copilot
- ⚡ Fast & lightweight — async Python with FastAPI + uvicorn
- 🔌 Zero config — works out of the box, just run and go
- Python 3.11+
- An active GitHub Copilot subscription
Note: The GitHub CLI (
gh) is not required. The server uses its own OAuth Device Flow.
git clone https://github.com/trsdn/github_copilot_openai_api_wrapper.git
cd github_copilot_openai_api_wrapper
python3 -m venv .venv
source .venv/bin/activate
pip install -e .copilot-wrapperOn first launch, the server will guide you through GitHub authentication:
- A one-time code is displayed (e.g.
ABCD-1234) - Your browser opens to https://github.com/login/device
- Enter the code and authorize
- Done! Your token is saved to
~/.config/copilot-wrapper/github_token
The server is now running at http://127.0.0.1:8080 🚀
Configure via environment variables or a .env file:
cp .env.example .env| Variable | Default | Description |
|---|---|---|
HOST |
127.0.0.1 |
Server bind address |
PORT |
8080 |
Server port |
LOG_LEVEL |
info |
Log level (debug, info, warning, error) |
GITHUB_TOKEN |
— | Optional: skip Device Flow by providing a token directly |
Point your OpenAI-compatible client at the local server:
| Setting | Value |
|---|---|
| API Base URL | http://127.0.0.1:8080/v1 |
| API Key | anything (e.g. x) — not validated |
| Model | gpt-4o, claude-3.5-sonnet, o3-mini, etc. |
💡 Tip: Some clients (like Elephas) automatically append
/v1to the base URL. In that case, usehttp://127.0.0.1:8080without the/v1suffix.
| Client | Status | Notes |
|---|---|---|
| Open WebUI | ✅ | Set base URL to http://127.0.0.1:8080/v1 |
| Chatbox | ✅ | Works out of the box |
| Elephas | ✅ | Use http://127.0.0.1:8080 (no /v1) |
| BoltAI | ✅ | Works out of the box |
| Aider | ✅ | Set --openai-api-base |
| Cline | ✅ | Use OpenAI-compatible provider |
| curl | ✅ | See examples below |
OpenAI-compatible chat completions. Supports both streaming and non-streaming.
# Non-streaming
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'
# Streaming (SSE)
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'Supported parameters: model, messages, temperature, top_p, max_tokens, stream, stop, n
List all available models from GitHub Copilot.
curl http://localhost:8080/v1/modelsHealth check endpoint.
curl http://localhost:8080/health
# → {"status": "ok"}┌──────────────────┐ ┌─────────────────────┐ ┌──────────────────────────┐
│ Chat Client │────▶│ Copilot Gateway │────▶│ api.githubcopilot.com │
│ (any OpenAI- │◀────│ localhost:8080 │◀────│ GitHub Copilot API │
│ compatible) │ │ FastAPI + uvicorn │ │ │
└──────────────────┘ └─────────────────────┘ └──────────────────────────┘
│
▼
OAuth Device Flow
(first run only)
src/
├── main.py # FastAPI app, endpoints, startup
├── config.py # Configuration (pydantic-settings)
├── auth.py # GitHub OAuth Device Flow + Copilot token management
├── copilot_client.py # Async HTTP client for Copilot API
├── models.py # Pydantic request/response models
└── middleware.py # CORS, logging, error handling
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is for educational and personal use. It relies on internal GitHub Copilot API endpoints that are not officially documented. Use at your own risk and ensure compliance with GitHub's Terms of Service.