A Node.js API for interacting with the GitHub Copilot API, allowing you to authenticate, fetch available models, and send chat completion requests.
- Authentication via GitHub token or device code flow
- Fetch available Copilot models
- Send chat completion requests with streaming responses
- Web UI for testing the API
- Clone the repository
- Install dependencies:
npm install
- Create a
.env
file based on the provided example:PORT=3000 GITHUB_CLIENT_ID=Iv1.b507a08c87ecfe98 TOKEN_FILE_PATH=.token
npm start
For development with auto-restart:
npm run dev
POST /api/auth/github
- Authenticate with a GitHub tokenGET /api/auth/device
- Start device code flow for authenticationPOST /api/auth/device/check
- Check device code flow statusGET /api/auth/status
- Check authentication status
GET /api/models
- Get available models
POST /api/chat/completions
- Send a chat completion request
The application includes a web UI for testing the API. Access it by navigating to the root URL in your browser:
http://localhost:3000
The UI allows you to:
- Authenticate using either a GitHub token or device code flow
- Fetch and view available models
- Send chat completion requests and view streaming responses
- Obtain a GitHub Personal Access Token with appropriate permissions
- Enter it in the web UI or send it to the
/api/auth/github
endpoint
- Start the flow by accessing the device code endpoint
- Visit the GitHub device activation page and enter the provided code
- The application will poll GitHub until authentication is complete
MIT