An OpenAI-compatible API server that wraps the GitHub Copilot AI SDK provider, allowing you to use GitHub Copilot models with any OpenAI-compatible client. Depending on what you're trying to do you may be better off just using the Copilot SDK.
✨ Interactive Swagger/OpenAPI documentation at /api-docs
- ✅ Full OpenAI API compatibility
- ✅ Interactive Swagger/OpenAPI documentation at
/api-docs - ✅ Streaming and non-streaming responses
- ✅ Chat completions (
/v1/chat/completions) - ✅ Legacy completions (
/v1/completions) - ✅ Model listing (
/v1/models) - ✅ Optional Bearer token authentication
- ✅ Auto-managed GitHub Copilot authentication
- ✅ CORS enabled
- Node.js 18+
- GitHub Copilot subscription
- No manual authentication required! The server will:
- Use existing GitHub Copilot CLI credentials if available
- Automatically trigger device flow if no credentials found
npm installWhen you start the server for the first time, it will check for existing GitHub Copilot credentials:
npm run dev
# ✓ GitHub Copilot provider initialized with existing credentials
# 🚀 Server starts immediatelynpm run dev
# ⚠ No existing GitHub Copilot credentials found
# 🔐 Starting device flow authentication...
#
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# GitHub Copilot Authentication Required
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
#
# 1. Visit: https://github.com/login/device
# 2. Enter code: XXXX-XXXX
#
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# ⏳ Waiting for authentication...Just visit the URL, enter the code, and the server will automatically continue once authenticated!
npm run devnpm run build
npm startPORT- Server port (default: 3000)API_KEY- Optional API key for Bearer token authentication. If not set, authentication is disabled.
Example:
PORT=8080 API_KEY=your-secret-key npm run devOnce the server is running, visit http://localhost:3000/api-docs for interactive Swagger/OpenAPI documentation.
The Swagger UI provides:
- 📖 Complete API reference
- 🧪 Interactive "Try it out" functionality
- 📋 Request/response examples
- 🔐 Authentication testing
GET /healthOr visit the interactive docs: http://localhost:3000/api-docs
GET /v1/models
Authorization: Bearer your-api-key # Optional if API_KEY is setPOST /v1/chat/completions
Authorization: Bearer your-api-key # Optional if API_KEY is set
Content-Type: application/json
{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "Hello!" }
],
"stream": false,
"temperature": 0.7,
"max_tokens": 1000
}POST /v1/chat/completions
Authorization: Bearer your-api-key # Optional if API_KEY is set
Content-Type: application/json
{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "Write a long story" }
],
"stream": true
}POST /v1/completions
Authorization: Bearer your-api-key # Optional if API_KEY is set
Content-Type: application/json
{
"model": "gpt-4o",
"prompt": "Once upon a time",
"stream": false
}All models available through your GitHub Copilot subscription:
gpt-4ogpt-4o-minigpt-4.1gpt-5gpt-5.1gpt-5.2claude-3.5-sonnetclaude-3.7-sonnetclaude-sonnet-4claude-sonnet-4.5gemini-2.0-flash-001gemini-3-pro-previewo1-previewo1-minio3-mini
Model availability depends on your Copilot subscription tier.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:3000/v1",
api_key="your-api-key" # or omit if no API_KEY set
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'http://localhost:3000/v1',
apiKey: 'your-api-key', // or omit if no API_KEY set
});
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);curl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'The server supports optional Bearer token authentication:
- Development mode (no API_KEY): All requests allowed
- Production mode (API_KEY set): Requires
Authorization: Bearer <API_KEY>header
Set the API_KEY environment variable to enable authentication:
API_KEY=my-secret-key npm run dev- On startup, the server checks for GitHub Copilot credentials
- If found, uses existing credentials from
~/.config/github-copilot/apps.json - If not found, automatically initiates device flow authentication
- Once authenticated, exchanges OAuth token for Copilot API token
- Auto-refreshes tokens before expiration (30 min lifetime)
- All requests are translated to OpenAI-compatible format
- Embeddings (
/v1/embeddings) are not supported (GitHub Copilot doesn't provide embedding models) - Token usage statistics depend on what the GitHub Copilot API returns
- Some OpenAI-specific parameters may not be supported by all models
MIT