caozhiyuan/copilot-api
Über uns
Universelles lokales KI-Gateway und Desktop-App für Claude Code, Codex, OpenCode und Antigravity (AGY). Vereinheitlicht GitHub Copilot, Codex, xAI, Gemini und Drittanbieter über die APIs von OpenAI, Anthropic und Gemini.
EntwicklerwerkzeugeWhat you can do
- Unified API Gateway serving OpenAI-compatible Chat Completions (/v1/chat/completions), OpenAI Responses (/v1/responses), Anthropic-compatible Messages (/v1/messages), and Gemini REST (under /v1beta/models) from one local address.
- Coding Agent Ready with one-click desktop setup and guides for Claude Code, OpenCode, Codex, Antigravity CLI, and DeepSeek Harness, including model discovery, merged model catalogs, and installable web-search / image / video Agent Skills.
- Streaming & WebSocket: SSE streaming for all four client-facing protocols, with WebSocket used upstream automatically where supported.
- Desktop App, Web Console & Cost Control: Electron GUI plus a built-in browser Web Console (/console) for Docker, NAS, and CLI deployments — manage providers, subscription quotas, API keys with USD spending limits, token usage analytics, advanced config, live logs, and coding agent setup without editing config.json by hand.
Gemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- +8
- in 15 days
- +16
- in 1 month
- +31
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalCopilot API
Universal AI Gateway
One Gateway. Any Client. Multiple AI Providers.
Chat Completions · OpenAI Responses · Anthropic Messages · Gemini REST
English | 简体中文 · Documentation
Copilot API is a local AI gateway that connects Claude Code, OpenCode, Codex, Antigravity CLI (agy), and other clients to GitHub Copilot, the built-in Codex and xAI providers, and third-party model providers through a unified API.
Highlights
- Unified API Gateway serving OpenAI-compatible Chat Completions (
/v1/chat/completions), OpenAI Responses (/v1/responses), Anthropic-compatible Messages (/v1/messages), and Gemini REST (under/v1beta/models) from one local address. - Multi-Provider: Route GitHub Copilot, the built-in
codexandxaiproviders, and third-party providers (Kimi, DeepSeek, DashScope, OpenRouter, OpenCode Go, Google Gemini, or a custom provider from models.dev) behind the same gateway. GitHub Copilot is optional — with at least one enabled provider, the server starts in provider-only mode without a GitHub token. - Coding Agent Ready with one-click desktop setup and guides for Claude Code, OpenCode, Codex, Antigravity CLI, and DeepSeek Harness, including model discovery, merged model catalogs, and installable web-search / image / video Agent Skills.
- Streaming & WebSocket: SSE streaming for all four client-facing protocols, with WebSocket used upstream automatically where supported.
- Desktop App, Web Console & Cost Control: Electron GUI plus a built-in browser Web Console (
/console) for Docker, NAS, and CLI deployments — manage providers, subscription quotas, API keys with USD spending limits, token usage analytics, advanced config, live logs, and coding agent setup without editingconfig.jsonby hand.
Desktop App
Prefer a GUI? Download the Electron desktop app to sign in to GitHub Copilot, OpenAI Codex, or xAI, configure API-key providers (Kimi, DeepSeek, DashScope, OpenRouter, or a custom provider from models.dev), connect your coding agents in one click, and track subscriptions, token usage, API key spending limits, media creation, and logs in one window.
https://github.com/user-attachments/assets/c1d32e76-2e16-42a0-8599-0a4eb07ddbc4
Screenshots (Dashboard, Client Integrations, Token Usage, API Keys)
Windows x64 (.exe), macOS Apple Silicon (.dmg), and Linux x64 (.AppImage) packages are published in GitHub Releases. Later updates use differential downloads when possible. See Electron Desktop App for full setup and advanced configuration.
Built-in Web Console
Open the built-in Web Console at http://localhost:4141/console on the same machine as the gateway. For remote access, including Docker and NAS deployments, use an HTTPS reverse proxy such as https://gateway.example.com/console with your own domain. The console displays a warning on remote HTTP connections because the Admin Key travels in plaintext.
- Admin Key login (fail-closed): Sign in with
auth.adminApiKeyfrom your gatewayconfig.json(in Docker, inside the mounted/datavolume). All/admin/*endpoints require a valid Admin API Key. - Full remote management: Configure providers and model visibility, view subscription quotas and token usage analytics, manage client API keys and USD budgets, edit
config.jsonvisually or in JSON with live reload, and stream gateway logs. - Coding Agent config generator: Visually generate copyable and downloadable configs and cross-platform terminal commands (
macOS / LinuxandWindows PowerShell) for Codex, Claude Code, OpenCode, DeepSeek Harness, and AGY CLI — without touching server files. To use the optional Agent Skills, run the generated environment commands before starting Codex or Claude Code. - Pre-built & source runs: npm packages and Docker images ship with the Web Console pre-built. When running from source, use
bun run start:web(or runbun run build:webonce beforebun run start start). For read-only token usage viewing without Admin Key access,/usage-viewerremains available as before.
Quick Start
Use Node.js 22.x, 24.x, or 26.x with the security updates below (npx) or Bun >= 1.4.4. A Copilot subscription is needed only for the GitHub Copilot provider; other configured providers can run independently.
[!WARNING] CVE-2026-111497: The Brotli decoder in affected Node.js and Bun runtimes can corrupt memory and allow remote code execution. Upgrade Node.js 22.x to 22.23.4 or later, 24.x to 24.22.1 or later, or 26.x to 26.12.1 or later; upgrade Bun to 1.4.4 or later. Restart the gateway after upgrading. For Docker deployments, rebuild and redeploy the image with a patched runtime. See the Node.js security release and Bun security advisory.
npx @jeffreycao/copilot-api@latest start
The server listens on http://localhost:4141 by default. Optionally authenticate with GitHub Copilot or configure a third-party provider first:
npx @jeffreycao/copilot-api@latest auth login
Alternatively, run with Bun >= 1.4.4, which can offer better performance:
bunx --bun @jeffreycao/copilot-api start
Use --bun to select the Bun runtime and omit @latest for routine starts to reuse the cache. See Bun setup for global installation and upgrades.
[!NOTE] Behind a corporate HTTPS proxy?
npxtrusts system CA certificates automatically. With Bun, setNODE_USE_SYSTEM_CA=1beforebunx --bun(export NODE_USE_SYSTEM_CA=1in bash/zsh, or$env:NODE_USE_SYSTEM_CA="1"in PowerShell). Desktop sets it for you.
Verify the gateway is up:
curl http://localhost:4141/v1/models
Continue with Claude Code, OpenCode, Codex, Antigravity CLI, DeepSeek Harness, or Docker.
Compatibility
Every client talks to the same local endpoint. The gateway routes each request to GitHub Copilot, the built-in codex or xai provider, or a configured third-party provider, translating between protocols when the provider speaks a different one.
Client / Protocol Matrix (documented setups)
| Client | Chat Completions | Responses | Anthropic Messages | Gemini REST | Recommended |
|---|---|---|---|---|---|
| Claude Code | — | — | ✅ Native / Adapter | — | Anthropic Messages |
| OpenCode | ✅ Native | ✅ Native / Adapter | ✅ Native / Adapter | — | v2: Responses; v1: Messages |
| Codex | — | ✅ Native / Adapter | — | — | Responses |
| Antigravity CLI (agy) | — | — | — | ✅ Native / Adapter | Gemini REST |
| DeepSeek Harness | — | ✅ Native / Adapter | ✅ Native / Adapter | — | Responses |
| OpenAI-compatible clients | ✅ Native | ✅ Native / Adapter | — | — | Chat Completions |
| Anthropic-compatible clients | — | — | ✅ Native / Adapter | — | Anthropic Messages |
Providers and protocols. Protocol support is model-specific. Chat Completions requires a native endpoint. Responses, Messages, and Gemini REST can use supported adapters. The built-in codex provider uses Responses natively. Third-party providers can use anthropic, openai-compatible, openai-responses, or google (native Gemini REST), with per-model overrides.
Documentation
| Guide | Contents |
|---|---|
| Installation and Startup | Prerequisites, project overview, npx and source runs, running without GitHub Copilot, and gateway API key setup |
| Claude Code | settings.json, gateway model discovery, model mappings, auto-compact window, and WebSearch behavior |
| OpenCode | v2 Responses plugin and automatic model discovery, native compaction, model capabilities and pricing, context limits, and v1 Anthropic SDK setup |
| Codex | A full config.toml provider block, GITHUB_COPILOT_API_KEY environment variable setup, auto-review model mapping, generating model_catalog.json, and the merged model picker catalog with protocol adapters |
| AGY CLI | Gemini gateway setup, cross-platform settings, and AGY CLI Statusline |
| DeepSeek Harness | Install dsh-copilot-api, save the gateway API key, and choose Responses or Messages |
| Docker | Docker Compose quick start, the /data persistent mount and its ownership repair, supported environment variables, and host interface binding |
| Desktop App | Copilot sign-in, Codex OAuth account switching, API-key providers, one-click start / stop, shared model mappings, advanced settings, and per-platform installers |
| Plugins and Tool Search | The Responses tool_search MCP bridge (not needed on opencode v2, which already defers tools through Code Mode), Claude Code agent-inject and tool-search marketplace plugins, and the OpenCode session context plugin |
| Agent Skills | Install web search, image, and video skills in your user directory |
| Gateway event plugins | Observe request state, timing, and usage with server-side plugins |
| Usage Monitoring | The usage viewer URL and query parameters, period selectors, Copilot quota progress, token and cost metric cards, trend charts, and paginated request events |
| CLI Reference | Command structure, global options, and the full option sets for the start, auth, and debug subcommands with example usage |
| Configuration Reference | Every config.json field: gateway and admin API keys, provider definitions, model mappings, WebSocket and HTTP transport, timeouts, and context management |
| API and Authentication | Allowed auth headers and CORS rules, OpenAI, Codex backend, and Anthropic endpoints, usage monitoring routes, and admin configuration endpoints |
| Troubleshooting | Fixes for Claude models missing from the Copilot model list |
Before using GitHub Copilot, read the GitHub Copilot Security Notice.
Support
If Copilot API makes your AI coding workflow better, consider giving it a ⭐ on GitHub!
Ähnliche Projekte entdecken
Wird geladen…