Sign inSign up

liuzhuogood/github-copilot-openai-api

By liuzhuogood

•Updated over 1 year ago

Turn GitHub Copilot into OpenAI API

Image
API management
Machine learning & AI
Web servers
0

1.3K

liuzhuogood/github-copilot-openai-api repository overview

⁠GitHub Copilot OpenAI API

Docker Pulls Docker Image Size GitHub License

🔥 Turn GitHub Copilot into OpenAI API | 将 GitHub Copilot 转换为 OpenAI API

English⁠ | 中文⁠

⁠🐳 Docker Hub Quick Start | Docker Hub 快速开始

# Pull and run the image | 拉取并运行镜像
docker run -d -p 8000:8000 liuzhuogood/github-copilot-openai-api:latest

# With API key authentication | 使用 API 密钥认证
docker run -d -p 8000:8000 -e API_KEY=your_secret_key liuzhuogood/github-copilot-openai-api:latest

First time setup | 首次使用:

  1. Visit/访问:http://localhost:8000/auth/device⁠
  2. Follow GitHub device auth flow | 按照 GitHub 设备认证流程操作
  3. Start using the API | 开始使用 API

For detailed documentation, please visit our GitHub Repository⁠. 更多详细文档,请访问我们的 GitHub 仓库⁠。

⁠🌟 English

⁠Introduction

This project provides an OpenAI API-compatible interface by reverse engineering the GitHub Copilot API. It allows you to use GitHub Copilot's capabilities through a standard OpenAI API interface, supporting streaming output and multiple models.

⁠🚀 Features
  • OpenAI API compatibility
  • Streaming response support
  • Multiple model support
  • Device authentication flow
  • Docker deployment support
  • API key authentication (optional)
⁠🛠 Tech Stack
  • FastAPI: High-performance web framework
  • Python 3.12+: Latest Python features
  • Docker: Containerization
  • Uvicorn: ASGI server
  • aiohttp: Async HTTP client
  • Jinja2: Template engine
⁠📝 Quick Start
docker run -d -p 8000:8000 liuzhuogood/github-copilot-openai-api:latest

With API key authentication:

docker run -d -p 8000:8000 -e API_KEY=your_secret_key liuzhuogood/github-copilot-openai-api:latest
⁠Building from Source
# Clone the repository
git clone https://github.com/liuzhuogood/github-copilot-openai-api.git
cd github-copilot-openai-api

# Build Docker image
docker build -t github-copilot-openai-api .

# Run container
docker run -d -p 8000:8000 github-copilot-openai-api
⁠🔧 Configuration

Environment variables:

  • HOST: Server host (default: 0.0.0.0)
  • PORT: Server port (default: 8000)
  • API_KEY: Optional API key for authentication
⁠📚 API Usage
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_API_KEY" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {
        "role": "user",
        "content": "Hello, who are you?"
      }
    ],
    "stream": true
  }'
⁠🎯 Supported Models
  • gpt-4
  • o3-mini
  • o1
  • gemini-2.0-flash-001
  • claude-3.5-sonnet
  • claude-3.7-sonnet
⁠🔐 First-time Setup
  1. Visit http://localhost:8000/auth/device⁠
  2. Follow the GitHub device authentication flow
  3. Once authorized, the service will automatically use the GitHub Copilot token

⁠🌟 中文

⁠简介

本项目通过逆向工程 GitHub Copilot API,提供了一个与 OpenAI API 兼容的接口。它允许你通过标准的 OpenAI API 接口使用 GitHub Copilot 的功能,支持流式输出和多种模型。

⁠🚀 特性
  • OpenAI API 兼容
  • 支持流式响应
  • 支持多种模型
  • 设备认证流程
  • Docker 部署支持
  • API 密钥认证(可选)
⁠🛠 技术栈
  • FastAPI:高性能 Web 框架
  • Python 3.12+:使用最新的 Python 特性
  • Docker:容器化部署
  • Uvicorn:ASGI 服务器
  • aiohttp:异步 HTTP 客户端
  • Jinja2:模板引擎
⁠📝 快速开始
⁠使用 Docker(推荐)
docker run -d -p 8000:8000 liuzhuogood/github-copilot-openai-api:latest

使用 API 密钥认证:

docker run -d -p 8000:8000 -e API_KEY=your_secret_key liuzhuogood/github-copilot-openai-api:latest
⁠从源码构建
# 克隆仓库
git clone https://github.com/liuzhuogood/github-copilot-openai-api.git
cd github-copilot-openai-api

# 构建 Docker 镜像
docker build -t github-copilot-openai-api .

# 运行容器
docker run -d -p 8000:8000 github-copilot-openai-api
⁠🔧 配置

环境变量:

  • API_KEY:可选的 API 密钥认证
⁠📚 API 使用
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_API_KEY" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {
        "role": "user",
        "content": "你好,请问你是谁?"
      }
    ],
    "stream": true
  }'
⁠🎯 支持的模型(免费订阅有限)
  • gpt-4
  • o3-mini
  • o1
  • gemini-2.0-flash-001
  • claude-3.5-sonnet
  • claude-3.7-sonnet
⁠🔐 首次使用
  1. 访问 http://localhost:8000/auth/device⁠
  2. 按照 GitHub 设备认证流程进行操作
  3. 认证成功后,服务将自动使用 GitHub Copilot 令牌

Tag summary

Content type

Image

Digest

sha256:7255c20b0…

Size

40.8 MB

Last updated

over 1 year ago

docker pull liuzhuogood/github-copilot-openai-api