Skip to content

About

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

Topics

Resources

Stars

1.1k stars

Watchers

8 watching

Forks

Latest commit

 

History

1,589 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copilot API

Copilot API - Universal AI Gateway

Universal AI Gateway
One Gateway. Any Client. Multiple AI Providers.
Chat Completions · OpenAI Responses · Anthropic Messages

npm version License GitHub stars Bun >= 1.4.0 Node >= 22.13.0

English | 简体中文

Copilot API is a local AI gateway that connects Claude Code, OpenCode, Codex, 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: Serve OpenAI-compatible Chat Completions (/v1/chat/completions), the OpenAI Responses API (/v1/responses), and Anthropic-compatible Messages (/v1/messages) from one local endpoint.
  • Multi-Provider: Route GitHub Copilot, the built-in codex and xai providers, 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: First-class setups for Claude Code, OpenCode, and Codex, including settings.json gateway model discovery and a merged model catalog for Codex.
  • Streaming & WebSocket: SSE streaming on all three client-facing protocols. Upstream Copilot Responses traffic selects WebSocket or HTTP from each model's advertised endpoints; streamed Responses traffic for the built-in codex provider uses WebSocket by default and uses HTTP when useResponsesApiWebSocket is disabled.
  • Desktop App: Electron GUI with GitHub Copilot sign-in, Codex and xAI OAuth, provider configuration, token usage, logs, and one-click start/stop.

Quick Start

Requires Node.js >= 22.13.0 (npx) or Bun >= 1.4.0. A Copilot subscription is needed only for the GitHub Copilot provider; other configured providers can run independently.

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.0, 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

To trust system-installed CA certificates (for example, behind a corporate HTTPS proxy), npx needs no extra configuration: Node.js >= 22.19.0 merges the system CA store at startup through tls.setDefaultCACertificates(). Only Bun requires NODE_USE_SYSTEM_CA=1 before bunx --bun: export NODE_USE_SYSTEM_CA=1 in bash/zsh, or $env:NODE_USE_SYSTEM_CA="1" in PowerShell (Bun >= 1.4.0). Desktop enables the variable for server subprocesses by default, preserving explicit environment settings.

Verify the gateway is up:

curl http://localhost:4141/v1/models

Note

Token usage storage requires Node.js >= 22.13.0 or Bun. See Using with npx for details.

From here, jump to the guide for your client: Claude Code, OpenCode, Codex, DeepSeek Harness, or run it with 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

Client Chat Completions Responses Anthropic Messages Recommended
Claude Code — — ✅ Native / Adapter Anthropic Messages
OpenCode ✅ Native ✅ Native / Adapter ✅ Native / Adapter via @ai-sdk/anthropic Anthropic Messages
Codex — ✅ Native / Adapter — Responses
DeepSeek Harness — ✅ via dsh-copilot-api ✅ via dsh-copilot-api 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, while Responses and Messages can use supported adapters. The built-in codex provider uses Responses natively; third-party providers can use anthropic, openai-compatible, or openai-responses, with per-model overrides.

Desktop App

Prefer a GUI? The Electron desktop app in desktop/ covers GitHub Copilot sign-in, OpenAI Codex and xAI OAuth, and API-key configuration for Kimi, DeepSeek, DashScope, OpenRouter, or a custom provider from models.dev — with one-click start/stop of the local server, and the local endpoint, auth header, available models, usage, and logs in one window.

Copilot API desktop app dashboard Copilot API desktop app token usage view

Windows x64 (.exe), macOS Apple Silicon (.dmg), and Linux x64 (.AppImage) packages are published in GitHub Releases. See Electron Desktop App for full setup and advanced configuration.

Documentation

Guide Contents
Installation and Startup Prerequisites, project overview, npx and source runs, provider-only mode without 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
DeepSeek Harness Install dsh-copilot-api, save the gateway API key, and choose Responses or Messages
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
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 subagent marker plugin
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.

About

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

Topics

Resources

Stars

1.1k stars

Watchers

8 watching

Forks

Releases

Packages

Contributors

Languages