How alorse/copilot-to-api works
The repository offers two ways to use Copilot: command-line clients and OpenAI-compatible web APIs, with Node.js and Python implementations. Web requests are handled either by servers that translate model/chat operations or by a Node.js transparent proxy; both obtain short-lived Copilot tokens using a configured GitHub access token. The README also documents manual device authorization and direct API usage, but the device-code flow is not implemented in the sampled runtime files. Edges reflect the excerpts and README; the Python web server and proxy excerpts are partial.
Main entry points: copilot-client.js Node Copilot client · copilot_client.py Python Copilot client · server.js Node Copilot API · server.py Python Copilot API
Components 15
CLI clients
- Node CLI
copilot-client.js - Node Copilot client
copilot-client.js - Python CLI
copilot_client.py - Python Copilot client
copilot_client.py
Web API servers
- Node API routes
server.js - Node Copilot API
server.js - Python API routes
server.py - Python Copilot API
server.py
Proxy server
- Proxy routes
server-proxy.js - Token manager
server-proxy.js
GitHub Copilot
- GitHub token endpoint
- Copilot models API
- Copilot chat API
Other components
- CLI user
- API caller
Connections 25
- CLI user → Node CLI: runs commands
README.md - Node CLI → Node Copilot client: calls
copilot-client.js - Node Copilot client → GitHub token endpoint: refreshes token
copilot-client.js - Node Copilot client → Copilot models API: requests models
copilot-client.js - Node Copilot client → Copilot chat API: sends completions
copilot-client.js - CLI user → Python CLI: runs commands
README.md - Python CLI → Python Copilot client: calls
copilot_client.py - Python Copilot client → GitHub token endpoint: refreshes token
copilot_client.py - Python Copilot client → Copilot models API: requests models
copilot_client.py - Python Copilot client → Copilot chat API: sends completions
copilot_client.py - API caller → Node API routes: sends HTTP requests
README.md - Node API routes → Node Copilot API: dispatches operations
server.js - Node Copilot API → GitHub token endpoint: refreshes token
server.js - Node Copilot API → Copilot models API: requests models
server.js - Node Copilot API → Copilot chat API: sends completions
server.js - API caller → Python API routes: sends HTTP requests
README.md - Python API routes → Python Copilot API: dispatches operations
server.py - Python Copilot API → GitHub token endpoint: refreshes token
server.py - Python Copilot API → Copilot models API: requests models
server.py - Python Copilot API → Copilot chat API: sends completions
server.py - API caller → Proxy routes: sends HTTP requests
README.md - Proxy routes → Token manager: gets valid token
server-proxy.js - Token manager → GitHub token endpoint: refreshes token
server-proxy.js - Proxy routes → Copilot models API: proxies requests
server-proxy.js - Proxy routes → Copilot chat API: proxies requests
server-proxy.js