Fork from ericc-ch/copilot-api (MIT License)
OpenAI Codex CLI 配置 wire_api = "responses" 时,会调用 /v1/responses(OpenAI Responses API)端点。而原版 copilot-api 只实现了 /v1/chat/completions 和 /v1/messages,没有实现 /v1/responses。
这意味着:
- gpt-5.4、gpt-5.3-codex 等新模型,GitHub Copilot 后端只允许通过 Responses API 访问,拒绝
/chat/completions请求(返回unsupported_api_for_model) - 原版 copilot-api 没有
/v1/responses端点 → Codex CLI 请求直接 404 - 即使把 Codex CLI 配成
wire_api = "chat",gpt-5.4 也会被上游拒绝
结果:通过原版 copilot-api 反代,Codex CLI 无法使用 gpt-5.4。
新增了 /v1/responses 和 /responses 路由,直接透传到 GitHub Copilot 后端的 /responses 端点:
Codex CLI ──(Responses API)──> copilot-api-fixed ──(/responses)──> GitHub Copilot 后端
不做格式转换,请求和响应直接透传,流式 SSE 事件也原样转发。
| 文件 | 说明 |
|---|---|
src/services/copilot/create-responses.ts |
新增:调用 Copilot 后端 /responses 端点 |
src/routes/responses/handler.ts |
新增:处理请求,透传响应(含流式 SSE) |
src/routes/responses/route.ts |
新增:注册 POST 路由 |
src/server.ts |
修改:注册 /v1/responses 和 /responses 路由 |
brew tap sq-lai/tap
brew install copilot-api安装完成后:
copilot-api auth # 首次认证 GitHub Copilot
copilot-api start # 启动服务器,默认端口 4141需要先安装 Bun(curl -fsSL https://bun.sh/install | bash)
git clone https://github.com/sq-lai/copilot-api-fixed.git
cd copilot-api-fixed
bun install
bun run src/main.ts auth # 首次认证
bun run src/main.ts start # 启动,默认端口 4141从 Releases 页面下载对应平台的二进制文件:
# macOS Apple Silicon (arm64)
tar -xzf copilot-api-darwin-arm64.tar.gz
chmod +x copilot-api
./copilot-api auth # 首次认证
./copilot-api start # 启动编辑 ~/.codex/config.toml:
model_provider = "custom"
model = "gpt-5.4"
model_reasoning_effort = "high"
disable_response_storage = true
[model_providers]
[model_providers.custom]
name = "custom"
wire_api = "responses"
requires_openai_auth = false
base_url = "http://localhost:4141"然后直接使用:
codex "你好"通过 /v1/responses 端点可以使用包括但不限于:
- gpt-5.4 (OpenAI)
- gpt-5.3-codex (OpenAI)
- gpt-5.2-codex (OpenAI)
- claude-sonnet-4.6 (Anthropic)
- gemini-3.1-pro-preview (Google)
所有模型列表可通过 curl http://localhost:4141/v1/models 查看。
- ericc-ch/copilot-api — 原始项目,MIT 协议
MIT License — 见 LICENSE 文件