caozhiyuan/copilot-api

GitHub Copilot, OpenAI Codex, OpenCode Go, and third-party AI provider gateway with OpenAI and Anthropic API compatibility.

Copilot API – A Local Gateway for Multiple Coding‑AI Providers

What it is

  • An open‑source Node.js/Bun server that runs on your machine (default http://localhost:4141).
  • It presents a single, OpenAI‑compatible HTTP API that client tools (Claude Code, OpenCode, Codex, generic OpenAI or Anthropic SDKs) can talk to.
  • Behind the scenes the gateway forwards each request to the appropriate backend: GitHub Copilot, the built‑in codex/xai services, or third‑party model providers such as Kimi, DeepSeek, DashScope, OpenRouter, OpenCode Go, or any custom provider listed on models.dev.

Why it matters

  • Developers who use AI‑powered coding assistants often have to juggle different client‑side extensions and each one expects a different endpoint (Chat Completions, Responses, Anthropic Messages). Copilot API normalises these into one local endpoint, eliminating configuration friction.
  • It also lets you mix and match providers – e.g., fall back to an open‑source model when you run out of Copilot quota, or compare costs across providers without changing your editor settings.

Key features (as described in the README)

  • Unified API: Supports three public‑facing routes – /v1/chat/completions (OpenAI style), /v1/responses (GitHub Copilot style), and /v1/messages (Anthropic style). All routes stream results via Server‑Sent Events.
  • Multi‑provider routing: Built‑in support for Copilot, codex, xai, plus adapters for many external services. Providers can be enabled via a simple config.json file; if no Copilot token is supplied the server still works in “provider‑only” mode.
  • Coding‑agent ready: Pre‑configured setups for Claude Code, OpenCode, and Codex, including automatic model discovery and a merged model catalog for Codex.
  • Streaming & WebSocket: Uses SSE for client‑side streaming; upstream traffic may use WebSocket or HTTP depending on the provider’s capabilities.
  • Desktop GUI: An Electron app (Windows, macOS, Linux) that handles OAuth sign‑ins, API‑key entry, one‑click start/stop, and shows token usage, logs, and available models.
  • Docker support: Official Docker Compose recipe for containerised deployment, with persistent /data volume for config and usage logs.
  • CLI: npx @jeffreycao/copilot-api@latest start to launch, auth login to set up Copilot credentials, plus a debug sub‑command.

Typical workflow

  1. Install via npx (or Docker/Bun).
  2. Optionally run auth login to link your GitHub Copilot account.
  3. Start the server – it listens on localhost:4141.
  4. Point your coding‑assistant extension (e.g., Claude Code) to http://localhost:4141/v1/messages.
  5. The gateway forwards the request to the selected provider, streams the response back, and records token usage.

Who should use it

  • Developers who rely on multiple AI coding assistants and want a single local endpoint.
  • Teams that need to enforce usage‑monitoring or quota‑aware routing across providers.
  • Anyone who wants a self‑hosted, configurable alternative to hard‑coded cloud endpoints.

Where to learn more

  • Full guides live under docs/guides/en/ (Getting Started, Provider‑specific docs, Docker, Desktop App, Usage Monitoring, etc.).
  • The repository includes a MIT‑licensed codebase, npm package @jeffreycao/copilot-api, and pre‑built Electron binaries.

All information above is taken directly from the repository’s README; no external assumptions have been added.

Related

  • Project
  • Project
  • Project
  • Project
  • Project