OpenAI-compatible API server powered by the GitHub Copilot SDK.
It exposes the classic OpenAI endpoints so you can use standard OpenAI clients (including the official Python OpenAI SDK) against a local Copilot-backed proxy.
- Authentication UI via GitHub OAuth device flow (
GET /auth) - Token dashboard (
GET /auth/dashboard) with quota and session management - OpenAI-compatible endpoints:
GET /v1/modelsPOST /v1/chat/completions
- Streaming and non-streaming chat completions
- Multi-turn conversation support
- Tool calling support (including multi-step tool loops)
- Multimodal image input (
image_urlcontent parts) - FastAPI server with CORS enabled
- Python 3.11+
- GitHub Copilot CLI available/authenticated on host, or a valid GitHub token with Copilot access
server/main.py: FastAPI app, root UI, and endpointsserver/auth.py: Auth UI, dashboard UI, and auth/dashboard APIsserver/state.py: Per-tokenCopilotClientcache and session retention pruningserver/handlers.py: Copilot session orchestrationserver/converters.py: OpenAI <-> Copilot conversion logicserver/models.py: OpenAI-compatible request/response modelstest_proxy.py: end-to-end tests using the official OpenAI Python SDKDockerfile: container image for running the proxy
GET /: centralized home UI (navigation)GET /auth: authentication pageGET /auth/dashboard: token dashboard
The proxy supports two authentication methods.
Pass your GitHub token in the Authorization header with the Bearer scheme:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8081/v1",
api_key="ghp_your_github_token"
)Open http://localhost:8081/auth and complete GitHub device flow. A token is shown after authentication.
POST /auth/device/start: start GitHub device flowPOST /auth/device/poll: poll for device flow completionGET /auth/status: check token auth status
Open http://localhost:8081/auth/dashboard to:
- paste/select the GitHub token to inspect
- view Copilot quota snapshots (
account.getQuota) including used and remaining requests - list persisted sessions for that token
- delete a single session
- prune old sessions keeping only the latest 10
The proxy prunes persisted Copilot sessions automatically to avoid unbounded growth.
- Keeps the 10 most recently modified sessions per token by default
- Deletes older sessions through the SDK (
client.delete_session) - Pruning is throttled (default once every 120 seconds per token)
Environment variables:
COPILOT_SESSION_KEEP_COUNT(default:10)COPILOT_SESSION_PRUNE_INTERVAL_SECONDS(default:120)
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -e .
python -m server.main --host 0.0.0.0 --port 8081curl http://localhost:8081/health
curl http://localhost:8081/auth/status \
-H "Authorization: Bearer ghp_your_github_token"
curl http://localhost:8081/v1/models \
-H "Authorization: Bearer ghp_your_github_token"
curl http://localhost:8081/v1/chat/completions \
-H "Authorization: Bearer ghp_your_github_token" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5-mini",
"messages": [{"role": "user", "content": "Say hello in one word."}]
}'Run server:
source .venv/bin/activate
python -m server.main --port 8081In another terminal:
source .venv/bin/activate
export GITHUB_TOKEN=ghp_your_github_token
python test_proxy.pyDocker Compose (recommended):
docker-compose up -dor standalone Docker
Build:
docker build -t copilot-sdk-openai-proxy .Run:
docker run --rm -p 8081:8081 \
-e PORT=8081 \
copilot-sdk-openai-proxyThen open:
- Home UI:
http://localhost:8081/ - Auth UI:
http://localhost:8081/auth - Dashboard UI:
http://localhost:8081/auth/dashboard
- The proxy keeps compatibility with OpenAI request/response shapes for chat completions.
- Tool execution follows the OpenAI flow: model requests tool calls, client executes tools, then client sends tool results back in follow-up messages.
- Each GitHub token gets its own cached
CopilotClient, so multiple tokens can be used concurrently.
