{"id":27105164,"url":"https://github.com/yuchanns/copilot-openai-api","last_synced_at":"2025-10-15T06:00:15.087Z","repository":{"id":286461237,"uuid":"961476595","full_name":"yuchanns/copilot-openai-api","owner":"yuchanns","description":"A FastAPI proxy server that seamlessly turns GitHub Copilot's chat completion/embeddings capabilities into OpenAI compatible API service.","archived":false,"fork":false,"pushed_at":"2025-08-27T09:27:48.000Z","size":37,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-11T03:07:27.612Z","etag":null,"topics":["chat-completion","copilot","openai-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuchanns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-06T15:50:57.000Z","updated_at":"2025-10-06T13:13:38.000Z","dependencies_parsed_at":"2025-04-09T21:19:18.911Z","dependency_job_id":"692e30e8-994e-4f39-9da7-c8c32f75a4ff","html_url":"https://github.com/yuchanns/copilot-openai-api","commit_stats":null,"previous_names":["yuchanns/copilot-openai-api"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/yuchanns/copilot-openai-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchanns%2Fcopilot-openai-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchanns%2Fcopilot-openai-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchanns%2Fcopilot-openai-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchanns%2Fcopilot-openai-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuchanns","download_url":"https://codeload.github.com/yuchanns/copilot-openai-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchanns%2Fcopilot-openai-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279056871,"owners_count":26094789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat-completion","copilot","openai-api"],"created_at":"2025-04-06T18:37:24.950Z","updated_at":"2025-10-15T06:00:15.080Z","avatar_url":"https://github.com/yuchanns.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 Copilot OpenAI API\n\n[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)\n[![FastAPI](https://img.shields.io/badge/FastAPI-modern-green.svg)](https://fastapi.tiangolo.com/)\n[![Docker](https://img.shields.io/badge/docker-ready-blue.svg)](https://www.docker.com/)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n[![Image Tags](https://ghcr-badge.yuchanns.xyz/yuchanns/copilot-openai-api/tags?ignore=latest)](https://ghcr.io/yuchanns/copilot-openai-api)\n![Image Size](https://ghcr-badge.yuchanns.xyz/yuchanns/copilot-openai-api/size)\n\nA FastAPI proxy server that seamlessly turns GitHub Copilot's chat completion/embeddings capabilities into OpenAI compatible API service.\n\n## ✨ Key Features\n\n🚀 **Advanced Integration**\n- Seamless GitHub Copilot chat completion API proxy\n- Real-time streaming response support\n- High-performance request handling\n\n🔐 **Security \u0026 Reliability**\n- Secure authentication middleware\n- Automatic token management and refresh\n- Built-in CORS support for web applications\n\n💻 **Universal Compatibility**\n- Cross-platform support (Windows and Unix-based systems)\n- Docker containerization ready\n- Flexible deployment options\n\n## 🧪 Experimental Features\n\n- Anthropic API compatibility\n\n## 🚀 Prerequisites\n\n- Python 3.10+\n- pip (Python package manager)\n- GitHub Copilot subscription\n- GitHub authentication token\n\n## 📦 Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yuchanns/copilot-openai-api.git\ncd copilot_provider\n```\n\n2. Install dependencies:\n```bash\n# Install PDM first if you haven't\npip install -U pdm\n\n# Install project dependencies using PDM\npdm install --prod\n```\n\n## ⚙️ Configuration\n\n1. Set up environment variables:\n```bash\n# Windows\nset COPILOT_TOKEN=your_access_token_here\nset COPILOT_SERVER_PORT=9191          # Optional: Server port (default: 9191)\nset COPILOT_SERVER_WORKERS=4          # Optional: Number of workers (default: min(CPU_COUNT, 4))\n\n# Unix/Linux/macOS\nexport COPILOT_TOKEN=your_access_token_here\nexport COPILOT_SERVER_PORT=9191       # Optional: Server port (default: 9191)\nexport COPILOT_SERVER_WORKERS=4       # Optional: Number of workers (default: min(CPU_COUNT, 4))\n```\n\n📝 **Note**: \n- `COPILOT_TOKEN`: Required for authentication. If not set, a random token will be generated.\n- `COPILOT_SERVER_PORT`: Optional. Controls which port the server listens on.\n- `COPILOT_SERVER_WORKERS`: Optional. Controls the number of worker processes.\n\n2. Configure GitHub Copilot:\n   - Windows users: Check `%LOCALAPPDATA%/github-copilot/`\n   - Unix/Linux/macOS users: Check `~/.config/github-copilot/`\n\nRequired configuration files:\n- `apps.json` or `hosts.json` (containing GitHub OAuth token)\n- `token.json` (will be created automatically)\n\n\u003e **💡 How to get a valid Github Copilot configuration?**\n\u003e\n\u003e Choose any of these official GitHub Copilot plugins:\n\u003e\n\u003e - [GitHub Copilot for VS Code](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot)\n\u003e - [GitHub Copilot for Visual Studio](https://marketplace.visualstudio.com/items?itemName=GitHub.copilotvs)\n\u003e - [GitHub Copilot for Vim](https://github.com/github/copilot.vim)\n\u003e - [GitHub Copilot for JetBrains IDEs](https://plugins.jetbrains.com/plugin/17718-github-copilot)\n\u003e\n\u003e After installing and signing in, configuration files will be automatically created in your system's config directory.\n\n## 🚀 Usage\n\nChoose between local or Docker deployment:\n\n### 🖥️ Local Run\n\nStart the server with:\n```bash\npdm dev\n```\n\n### 🐳 Docker Run\n\nLaunch the containerized version:\n```bash\n# Unix/Linux/macOS\ndocker run --rm -p 9191:9191 \\\n    -v ~/.config/github-copilot:/home/appuser/.config/github-copilot \\\n    ghcr.io/yuchanns/copilot-openai-api\n\n# Windows\ndocker run --rm -p 9191:9191 ^\n    -v %LOCALAPPDATA%/github-copilot:/home/appuser/.config/github-copilot ^\n    ghcr.io/yuchanns/copilot-openai-api\n```\n\nThe Docker setup:\n- Maps port 9191 to your host\n- Mounts your Copilot configuration\n- Provides identical functionality to local deployment\n\n### 🔄 Making API Requests\n\nAccess the chat completion endpoint:\n```bash\ncurl -X POST http://localhost:9191/v1/chat/completions \\\n  -H \"Authorization: Bearer your_access_token_here\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello, Copilot!\"}]\n  }'\n```\n\nAccess the embeddings endpoint:\n```bash\ncurl -X POST http://localhost:9191/v1/embeddings \\\n  -H \"Authorization: Bearer your_access_token_here\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"copilot-text-embedding-ada-002\",\n    \"input\": [\"The quick brown fox\", \"Jumped over the lazy dog\"]\n  }'\n```\n\n## 🔌 API Reference\n\n### POST /v1/chat/completions\nProxies requests to GitHub Copilot's Completions API.\n\n**Required Headers:**\n- `Authorization: Bearer \u003cyour_access_token\u003e`\n- `Content-Type: application/json`\n\n**Request Body:**\n- Follow GitHub Copilot chat completion API format\n\n**Response:**\n- Streams responses directly from GitHub Copilot's API\n- Supports both streaming and non-streaming modes\n\n---\n\n### POST /v1/embeddings\nProxies requests to Github Copilot's Embeddings API.\n\n**Required Headers:**\n- `Authorization: Bearer \u003cyour_access_token\u003e`\n- `Content-Type: application/json`\n\n**Request Body:**\n- Follow GitHub Copilot embeddings API format\n\n**Response:**\n- JSON response from GitHub Copilot's embeddings API\n\n---\n\n### POST /v1/messages\nConverts Anthropic API format to GitHub Copilot chat completion format.\n\n***Required Headers:*\n- `Authorization: Bearer \u003cyour_access_token\u003e`\n- `Content-Type: application/json`\n\n**Request Body:**\n- Follow Anthropic API message format\n**Response:**\n- Follow Anthropic API response format\n\n**✨Integrate with Claude Code** (experimental):\n\n```bash\nexport ANTHROPIC_BASE_URL=\"http://localhost:9191\" # Your Copilot OpenAI API server URL\nexport ANTHROPIC_AUTH_TOKEN=\"\u003cyour_access_token\u003e\"  # Your access token\nexport ANTHROPIC_MODEL=\"claude-sonnet-4\"\nexport ANTHROPIC_SMALL_FAST_MODEL=\"claude-sonnet-4\"\n```\n\n## 🔒 Authentication\n\nSecure your endpoints:\n\n1. Set `COPILOT_TOKEN` in your environment\n2. Include in request headers:\n   ```\n   Authorization: Bearer your_access_token_here\n   ```\n\n## ⚠️ Error Handling\n\nThe server provides clear error responses:\n- 401: Missing/invalid authorization header\n- 403: Invalid access token\n- Other errors are propagated from GitHub Copilot API\n\n## 🛡️ Security Best Practices\n\n- Configure CORS for your specific domains (default: `*`)\n- Safeguard your `COPILOT_TOKEN` and GitHub OAuth token\n- Built-in token management with concurrent access protection\n\n## 📄 License\n\nLicensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuchanns%2Fcopilot-openai-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuchanns%2Fcopilot-openai-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuchanns%2Fcopilot-openai-api/lists"}