@onklave/copilot-api
v0.1.5
Published
Expose a GitHub Copilot account (github.com or *.ghe.com) as an OpenAI/Anthropic-compatible API server. Connect Claude Code to GitHub Enterprise Cloud Copilot.
Maintainers
Readme
@onklave/copilot-api
Expose a GitHub Copilot subscription as an OpenAI/Anthropic-compatible API server — including Copilot accounts on GitHub Enterprise Cloud with data residency (*.ghe.com). Point Claude Code (or any OpenAI/Anthropic-compatible client) at it and use your Copilot entitlement as the model backend.
This is an Onklave-maintained derivative of ericc-ch/copilot-api (forked at v0.7.0, commit 0ea08feb, MIT — see NOTICE). What it adds over upstream:
--github-host/$GH_HOST— authenticate against a GHE Cloud data-residency tenant (acme.ghe.com) instead of github.com. Device-flow login, the Copilot token exchange, and usage queries all route to the tenant.- Self-configuring inference endpoint — the Copilot token exchange returns per-tenant service endpoints; the server honours
endpoints.api(e.g.https://copilot-api.acme.ghe.com) instead of assumingapi.githubcopilot.com, so data-residency traffic stays regional. - Per-host credential storage — a github.com login and a tenant login coexist under
~/.local/share/onklave-copilot-api/.
Quickstart
npx @onklave/copilot-api startFirst run walks you through GitHub device-flow login, then serves on http://localhost:4141.
GitHub Enterprise Cloud (*.ghe.com)
# One-time login against your tenant
npx @onklave/copilot-api auth --github-host acme.ghe.com
# Run the server against the tenant (or: export GH_HOST=acme.ghe.com)
npx @onklave/copilot-api start --github-host acme.ghe.comIf your tenant blocks the device flow, generate an OAuth token on the tenant and pass it with --github-token instead.
Corporate proxies: the standard HTTPS_PROXY/HTTP_PROXY/NO_PROXY environment variables are honoured automatically by every command — no flag needed. If auth times out connecting to your tenant on a managed machine, check env | grep -i proxy and make sure your proxy variables are set in that shell.
Connecting Claude Code
Interactive — pick models and get a ready-to-paste launch command:
npx @onklave/copilot-api start --github-host acme.ghe.com --claude-codeManual:
export ANTHROPIC_BASE_URL=http://localhost:4141
export ANTHROPIC_AUTH_TOKEN=dummy
# Optional — pin models; without these, unknown claude-* IDs are
# auto-mapped to your account's models (see Model mapping below)
export ANTHROPIC_MODEL=claude-sonnet-5
export ANTHROPIC_SMALL_FAST_MODEL=claude-haiku-4.5
claudeThe server implements Anthropic's /v1/messages (streaming and count_tokens included) plus OpenAI-style /v1/chat/completions, /v1/models, and /v1/embeddings.
Model mapping: Claude Code's default settings request Anthropic's own model IDs (e.g. claude-haiku-4-5-20251001 for background calls), which Copilot serves under different names (claude-haiku-4.5). When a requested claude-* model isn't in your account's model list, the server automatically substitutes the same family — haiku-class requests get the available haiku model, everything else gets the strongest non-haiku Claude — and logs the substitution. Claude Code therefore works with no model configuration at all; pin exact models with the --claude-code picker or the ANTHROPIC_MODEL/ANTHROPIC_SMALL_FAST_MODEL env vars if you want control.
Commands and flags
| Command | Purpose |
| --- | --- |
| start | Run the API server (default port 4141) |
| auth | Device-flow login only |
| check-usage | Show Copilot quota/usage for the account |
| debug | Print version, paths, and token status |
Key start flags (see --help for all): --port, --github-host, --account-type individual|business|enterprise, --github-token, --claude-code, --rate-limit <s> (+ --wait), --manual (approve each request), --proxy-env.
All commands accept --github-host; when omitted, $GH_HOST is used, then github.com.
Quota/usage for the signed-in account is served as JSON at http://localhost:4141/usage (same data as check-usage).
Caveats
- This uses Copilot's internal editor API (reverse-engineered, as upstream). It is not a GitHub-supported integration surface; use it with your own account, within your organization's policies and GitHub's terms.
- Excessive automated traffic can trip Copilot abuse detection — consider
--rate-limitfor agent workloads. - Requires Node >= 20.
Development
Self-contained package (own package-lock.json, not part of the monorepo's Nx graph):
npm install
npm run typecheck && npm test && npm run build
node dist/main.js startPublished to npm by .github/workflows/publish-libs.yaml on merge to main.
License
Apache-2.0 (see LICENSE). Derived from MIT-licensed ericc-ch/copilot-api; the original license and copyright are preserved in NOTICE.
