Disclaimer
This repository was created quickly using AI for personal testing purposes. It will most likely not receive updates or maintenance.
DO NOT USE FOR COMMERCIAL OR PRODUCTION PURPOSES
The GitHub Copilot CLI has full filesystem access to the server directory. This means the AI can read, modify, or delete any files on the system. This is a significant security risk. Example of what the AI can do:
User: "read the files list" AI: *reads and returns contents of all files in the directory*Use this project at your own risk and only in isolated, non-sensitive environments.
An OpenAI-compatible REST API server powered by the GitHub Copilot SDK. Expose GitHub Copilot's capabilities through a standard OpenAI API interface, enabling seamless integration with existing tools and applications.
- Full OpenAI API compatibility (
/v1/chat/completions,/v1/completions,/v1/models) - Streaming and non-streaming responses
- Multiple model support (GPT-4o, Claude, O1, Gemini, and more)
- Optional API key authentication
- CORS support with configurable origins
- Health check endpoint
- Configurable timeouts
- Node.js >= 18.0.0
- GitHub Copilot subscription
- GitHub Copilot CLI
npm install -g @github/copilotgithub-copilot-cli authFollow the prompts to authenticate with your GitHub account. Make sure your account has an active GitHub Copilot subscription.
git clone https://github.com/Houloude9IOfficial/CopAPI.git
cd CopAPI
npm installcp .env.example .envEdit .env with your preferred settings.
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
DEFAULT_MODEL |
Default model when not specified | gpt-4o |
API_KEY |
API key for authentication (leave empty to disable) | - |
LOG_LEVEL |
Logging level (debug, info, warn, error) |
info |
REQUEST_TIMEOUT |
Request timeout in milliseconds | 300000 |
CORS_ORIGIN |
Allowed origins (* for all, or comma-separated URLs) |
* |
CORS_CREDENTIALS |
Allow credentials in CORS requests | false |
COPILOT_CLI_PATH |
Custom path to Copilot CLI (optional) | - |
COPILOT_CLI_URL |
URL of existing CLI server (optional) | - |
npm startnpm run devGET /v1/modelsGET /v1/models/:modelPOST /v1/chat/completions
Content-Type: application/json
{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"stream": false
}POST /v1/completions
Content-Type: application/json
{
"model": "gpt-4o",
"prompt": "Write a poem about coding",
"stream": false
}GET /health| Model | Description |
|---|---|
gpt-4o |
GPT-4o (default) |
gpt-4o-mini |
GPT-4o Mini |
gpt-4 |
GPT-4 |
gpt-4-turbo |
GPT-4 Turbo |
gpt-3.5-turbo |
GPT-3.5 Turbo |
gpt-5 |
GPT-5 |
claude-sonnet-4.5 |
Claude Sonnet 4.5 |
claude-sonnet-4 |
Claude Sonnet 4 |
o1 |
O1 |
o1-mini |
O1 Mini |
o1-pro |
O1 Pro |
o3-mini |
O3 Mini |
gemini-2.0-flash-001 |
Gemini 2.0 Flash |
CORS is enabled by default to allow requests from any origin. Configure it using environment variables:
CORS_ORIGIN=*CORS_ORIGIN=https://example.com,https://app.example.comIf your client needs to send cookies or authentication headers:
CORS_ORIGIN=https://example.com
CORS_CREDENTIALS=trueNote: When
CORS_CREDENTIALS=true, you cannot useCORS_ORIGIN=*. You must specify explicit origins.
If API_KEY is configured, include it in all requests:
Authorization: Bearer your-api-key-herecurl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'from openai import OpenAI
client = OpenAI(
base_url="http://localhost:3000/v1",
api_key="your-api-key"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)const response = await fetch("http://localhost:3000/v1/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }]
})
});
const data = await response.json();
console.log(data.choices[0].message.content);Ensure the GitHub Copilot CLI is installed globally and accessible in your PATH:
npm install -g @github/copilotRe-authenticate with the Copilot CLI:
github-copilot-cli authIncrease the REQUEST_TIMEOUT value in your .env file.
MIT