TypeScript MIT

copilot-api

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

C

caozhiyuan

Dernière activité 28 sept. 2026
caozhiyuan/copilot-api

1,1 k

étoiles

236

forks

0

issues ouvertes

ai-gatewayanthropic-compatiblecodexgithub-copilotopenai-responsesopencode

Ce README est souvent en anglais.

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.2.x 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, 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.2.x. 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

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

Projets similaires

Turn GitHub Copilot into OpenAI/Anthropic API compatible server. Usable with Claude Code!

TypeScriptgithub-copilotopenai-apiopenai-compatible-api
Eericc-ch
4,1 k étoiles667

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

TypeScriptai-gatewayai-toolsanthropic
Llidge-jun
16,6 k étoiles1,2 k

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Davin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini Series, GPT Series, Grok Series, Claude model through API

Goantigravityclaude-codecluade
Rrouter-for-me
53,5 k étoiles8,1 k