|
1 | 1 | # Copilot API Pro |
2 | 2 |
|
3 | | -> [!NOTE] |
4 | | -> This is a fork of [ericc-ch/copilot-api](https://github.com/ericc-ch/copilot-api). The package/CLI name is **copilot-api-pro** (`npx copilot-api-pro@latest start`). |
5 | | -> Highlights of this fork: |
6 | | -> - Native OpenAI `/v1/responses` support (latest GPT models such as gpt-5.1-codex). |
7 | | -> - Persisted Claude Code model selection, daemon start/stop commands, non-interactive startup. |
8 | | -> - Improved error handling for Copilot responses and daemon management. |
9 | | -> - bug fixes |
10 | | -
|
11 | | -> [!WARNING] |
12 | | -> This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk. |
13 | | -
|
14 | | -> [!WARNING] |
15 | | -> **GitHub Security Notice:** |
16 | | -> Excessive automated or scripted use of Copilot (including rapid or bulk requests, such as via automated tools) may trigger GitHub's abuse-detection systems. |
17 | | -> You may receive a warning from GitHub Security, and further anomalous activity could result in temporary suspension of your Copilot access. |
18 | | -> |
19 | | -> GitHub prohibits use of their servers for excessive automated bulk activity or any activity that places undue burden on their infrastructure. |
20 | | -> |
21 | | -> Please review: |
22 | | -> |
23 | | -> - [GitHub Acceptable Use Policies](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies#4-spam-and-inauthentic-activity-on-github) |
24 | | -> - [GitHub Copilot Terms](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot) |
25 | | -> |
26 | | -> Use this proxy responsibly to avoid account restrictions. |
27 | | -
|
28 | | -CLI: `npx copilot-api-pro@latest start` |
29 | | - |
30 | | -Quick start |
31 | | -```sh |
32 | | -npx copilot-api-pro@latest start # 前台 |
33 | | -npx copilot-api-pro@latest start --daemon # 后台 |
34 | | -npx copilot-api-pro@latest stop # 停止后台 |
35 | | -npx copilot-api-pro@latest start --claude-code # 生成 Claude Code 命令并保存模型 |
36 | | -npx copilot-api-pro@latest start --codex # 生成 Codex 命令 (responses) |
37 | | -npx copilot-api-pro@latest check-usage # 查看用量 |
38 | | -``` |
| 3 | +Fork of [ericc-ch/copilot-api](https://github.com/ericc-ch/copilot-api) that adds OpenAI `/v1/responses`, persistent Claude Code model selection, daemon-friendly start/stop, and tighter error handling. CLI name: `copilot-api-pro`. |
| 4 | + |
| 5 | +> This is a reverse-engineered proxy of GitHub Copilot. It is unofficial and may break at any time. |
| 6 | +
|
| 7 | +## Highlights |
| 8 | +- OpenAI-compatible endpoints (including `/v1/responses` for GPT-4.1 / gpt-5.1-codex) and Anthropic-compatible `/v1/messages`. |
| 9 | +- One-shot Claude Code setup: select models once, persist them, and reuse with `--daemon`. |
| 10 | +- Codex CLI helper: generates `wire_api=responses` command for Codex. |
| 11 | +- Manual approval and rate-limit guard rails to reduce Copilot abuse flags. |
| 12 | +- Background daemon with `start --daemon` and `stop`. |
| 13 | + |
| 14 | +## Requirements |
| 15 | +- Bun 1.0+ recommended. |
| 16 | +- A GitHub Copilot account (individual, business, or enterprise). |
| 17 | +- Files are stored under `~/.local/share/copilot-api` (tokens, Claude Code config, daemon pid). |
39 | 18 |
|
40 | | -Quick start |
| 19 | +## Quick start |
41 | 20 | ```sh |
42 | | -# 前台 / 后台 |
| 21 | +# Foreground / background |
43 | 22 | npx copilot-api-pro@latest start |
44 | 23 | npx copilot-api-pro@latest start --daemon |
45 | 24 | npx copilot-api-pro@latest stop |
46 | 25 |
|
47 | | -# Claude Code(选择并保存模型,复制命令) |
| 26 | +# Claude Code (select & persist models, copy command) |
48 | 27 | npx copilot-api-pro@latest start --claude-code |
49 | 28 |
|
50 | | -# Codex(生成 wire_api=responses 命令) |
| 29 | +# Reset Claude Code selection |
| 30 | +npx copilot-api-pro@latest start --claude-code --reset |
| 31 | + |
| 32 | +# Codex (generate wire_api=responses command) |
51 | 33 | npx copilot-api-pro@latest start --codex |
52 | 34 |
|
53 | | -# 查看用量 |
| 35 | +# Show usage |
54 | 36 | npx copilot-api-pro@latest check-usage |
55 | | -``` |
| 37 | +``` |
| 38 | + |
| 39 | +## Help |
| 40 | +`npx copilot-api-pro@latest --help` shows the command list (command name is `copilot-api-pro`): |
| 41 | +``` |
| 42 | +USAGE copilot-api-pro auth|start|stop|check-usage|debug |
| 43 | +
|
| 44 | +COMMANDS |
| 45 | + auth Run GitHub auth flow without running the server |
| 46 | + start Start the Copilot API server |
| 47 | + stop Stop the background Copilot API server started with --daemon |
| 48 | + check-usage Show current GitHub Copilot usage/quota information |
| 49 | + debug Print debug information about the application |
| 50 | +``` |
| 51 | + |
| 52 | +## CLI |
| 53 | +- `start` – start the server. Common flags: `-p/--port` (default 4141), `-a/--account-type` (`individual|business|enterprise`), `--manual`, `-r/--rate-limit <sec>`, `--wait`, `-g/--github-token <token>`, `--proxy-env`, `--claude-code`, `--reset`, `--codex`, `--daemon`, `--show-token`, `-v/--verbose`. |
| 54 | +- `auth` – run GitHub auth flow only (writes token). |
| 55 | +- `stop` – stop the `--daemon` background process. |
| 56 | +- `check-usage` – print Copilot usage/quotas. |
| 57 | +- `debug` – print version/runtime/path info (`--json` available). |
| 58 | + |
| 59 | +## API surface |
| 60 | +- OpenAI: `/v1/chat/completions`, `/v1/embeddings`, `/v1/models`, `/v1/responses`. |
| 61 | +- Anthropic: `/v1/messages`, `/v1/messages/count_tokens`. |
| 62 | +- Usage: `/usage`, token debug: `/token`. |
| 63 | +- Usage Viewer: `https://ericc-ch.github.io/copilot-api?endpoint=http://localhost:4141/usage`. |
| 64 | + |
| 65 | +## Tips |
| 66 | +- Rate-limit safety: `--manual` or `--rate-limit 30 --wait` helps avoid abuse flags. |
| 67 | +- Proxy: `--proxy-env` reads `HTTP_PROXY` / `HTTPS_PROXY` env vars. |
| 68 | +- Reset Claude Code selection: `start --claude-code --reset`. |
| 69 | + |
| 70 | +## Caveats & safety |
| 71 | +- This tool depends on unofficial Copilot endpoints; GitHub can change or block them at any time. |
| 72 | +- Heavy or automated use may trigger GitHub security/abuse protections; use at your own risk. |
| 73 | +- Please comply with: |
| 74 | + - [GitHub Acceptable Use Policies](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies#4-spam-and-inauthentic-activity-on-github) |
| 75 | + - [GitHub Copilot Terms](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot) |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +README structure inspired by [smart-suggestion](https://github.com/yetone/smart-suggestion). |
0 commit comments