Universal AI Gateway
One Gateway. Any Client. Multiple AI Providers.
Chat Completions · OpenAI Responses · Anthropic Messages
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.
- 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
codexandxaiproviders, 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
codexprovider uses WebSocket by default and uses HTTP whenuseResponsesApiWebSocketis disabled. - Desktop App: Electron GUI with GitHub Copilot sign-in, Codex and xAI OAuth, provider configuration, token usage, logs, and one-click start/stop.
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 startThe 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 loginVerify the gateway is up:
curl http://localhost:4141/v1/modelsNote
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.
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.
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.
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.
| 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.

