{"repo": "caozhiyuan/copilot-api", "files": {"README.md": {"f85b0ba46a963386713123a74ce49d0220c29fc4": {"t": 1785746548.776482, "n": 51345, "h": "7addb396a41c2c85", "c": "# Copilot API Proxy\n\nEnglish | [简体中文](./README.zh-CN.md)\n\n## Important Notes\n\n> [!IMPORTANT]\n> **Before using, please be aware of the following:**\n>\n> 1. **Claude Code configuration:** When using with Claude Code, please configure the model ID as `claude-opus-4-8`. Example claude `settings.json` see [Manual Configuration with `settings.json`](#manual-configuration-with-settingsjson). \n>\n> 2. **Built-in `copilot`, `codex` and third-party providers:** Run `npx @jeffreycao/copilot-api@latest auth` and choose `copilot`, `codex`, `deepseek`, `custom`, or other providers.\n>\n> 3. **Note:** See [GitHub Copilot Security Notice](./NOTICE.md#github-copilot-security-notice) for the warning removed from the README header.\n\n---\n\n## Project Overview\n\nA small AI gateway that can use GitHub Copilot, the built-in `codex` provider, or configured third-party providers such as DashScope. GitHub Copilot is optional: if no GitHub token is available, the server can still start in provider-only mode as long as at least one enabled provider is configured.\n\nThe gateway exposes OpenAI- and Anthropic-compatible APIs from one local endpoint, so tools like [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview), OpenCode, Codex, and OpenAI-compatible clients can share the same local server.\n\nOn the GitHub Copilot path, the gateway prefers Copilot's native Anthropic-style Messages API when available, preserving more Claude-native behavior for tool-heavy workflows.\n\n## Features\n\n- **OpenAI and Anthropic compatibility**: Serve `/v1/responses`, `/v1/chat/completions`, `/v1/models`, `/v1/embeddings`, and `/v1/messages` from one local gateway.\n- **Copilot is optional**: Use GitHub Copilot when credentials are present, or run the server with only configured providers.\n- **One gateway for Copilot, `codex`, and external providers**: Route GitHub Copilot, the built-in `codex` provider, and configured third-party providers behind the same endpoint.\n- **Standalone third-party providers**: Configure providers such as DashScope, DeepSeek, OpenRouter, or a custom provider and start the gateway without a GitHub Copilot login.\n- **OpenAI-compatible providers on chat and Messages APIs**: `openai-compatible` providers can serve top-level `/v1/chat/completions` through `model: \"provider/model\"` and Anthropic-style `/v1/messages` through request/response translation.\n- **Agent-friendly Claude handling on Copilot**: Prefer native `/v1/messages` when available, preserve Claude-style tool flows, support Anthropic beta features, Claude WebSearch through Responses-capable models, and keep subagent/session markers intact.\n- **Claude Code and OpenCode integration**: Works with Claude Code and OpenCode, including direct Anthropic-compatible usage through `@ai-sdk/anthropic`.\n- **Flexible auth and deployment options**: Supports interactive login or direct tokens, individual/business/enterprise plans, GitHub Enterprise, opencode OAuth, and custom data directories.\n- **Multi-provider routing**: Expose provider-specific `/:provider/...` routes or use `model: \"provider/model\"` on the top-level API.\n\n## Prerequisites\n\n- Bun (>= 1.2.x)\n- Node.js if you plan to run the published CLI with `npx`\n- GitHub account with Copilot subscription only if you want to use the GitHub Copilot provider\n- An API key or OAuth login for at least one configured provider if you want to run without GitHub Copilot\n\n## Installation\n\nTo install dependencies, run:\n\n```sh\nbun install\n```\n\nTo start the server directly from source:\n\n```sh\nbun run start start\n```\n\n## Running from Source\n\nThe project can be run from source in several ways:\n\n### Development Mode\n\n```sh\nbun run dev start\n```\n\n### Production Mode\n\n```sh\nbun run start start\n```\n\n## Using with npx\n\nYou can run the project directly using npx:\n\n> [!IMPORTANT]\n> Token usage storage uses Node's built-in `node:sqlite` module when running with `npx`. It is enabled on Node.js >= 22.13.0. On Node.js < 22.13.0, the CLI still starts, but token usage storage is disabled.\n>\n> If you want token usage storage without upgrading Node.js, run the published CLI with Bun instead: `bunx --bun @jeffreycao/copilot-api@latest start`.\n\n```sh\nnpx @jeffreycao/copilot-api@latest start\n```\n\nWith options:\n\n```sh\nnpx @jeffreycao/copilot-api@latest start --port 8080\n```\n\nFor authentication or provider configuration only:\n\n```sh\nnpx @jeffreycao/copilot-api@latest auth\n```\n\nTo run without GitHub Copilot, configure at least one provider first, then start the server normally:\n\n```sh\nnpx @jeffreycao/copilot-api@latest auth login --provider dashscope\nnpx @jeffreycao/copilot-api@latest start\n```\n\n## Using with Docker\n\nBuild the image:\n\n```sh\ndocker build -t copilot-api .\n```\n\nRun the container with a bind mount so auth data survives restarts:\n\n```sh\nmkdir -p ./copilot-data\ndocker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api copilot-api\n```\n\nThis stores GitHub auth data, provider config, and other gateway state in `./copilot-data` on the host, mapped to `/root/.local/share/copilot-api` in the container.\n\nOr pass a GitHub token directly:\n\n```sh\ndocker run -p 4141:4141 -e GH_TOKEN=your_github_token_here copilot-api\n```\n\n## Electron Desktop App\n\nIf you prefer a GUI, this repository also includes an Electron desktop app in `desktop/`. It supports GitHub Copilot sign-in, OpenAI Codex OAuth, and API-key configuration for DeepSeek, DashScope, OpenRouter, or a custom provider. After authorization or provider configuration, it can start and stop the local proxy with one click and shows the local endpoint, auth header, available models, usage, and logs in the app.\n\nThe settings screen also exposes `OAuth App`, `API Home`, `Enterprise URL`, verbose logging, and minimize-to-tray. Windows x64 (`.exe`), macOS Apple Silicon (`.dmg`), and Linux x64 (`.AppImage`) packages are published in GitHub Releases:\n\nhttps://github.com/caozhiyuan/copilot-api/releases\n\nOn Linux, make the downloaded AppImage executable before launching it:\n\n```sh\nchmod +x Copilot-API-*-linux-x86_64.AppImage\n./Copilot-API-*-linux-x86_64.AppImage\n```\n\nDownload the installer for your platform, authorize or configure a provider inside the app, choose a port, start the server, then point your client at the local endpoint shown in the app. Packaged desktop builds use the bundled Electron runtime, so normal desktop usage does not require installing Node.js separately. Token usage history is enabled when that bundled runtime supports SQLite.\n\nThe desktop app's Advanced Config page reads and writes the shared model mappings through `GET/POST /admin/config/model-mappings`. The same mappings apply across `POST /v1/messages`, `POST /v1/messages/count_tokens`, `POST /v1/responses`, and `POST /v1/chat/completions` instead of being split per interface. It uses `auth.adminApiKey` instead of the regular `auth.apiKeys`, and the app reads that key directly from `config.json` after the server has generated it on startup.\n\n### Desktop App Screenshots\n\nMain dashboard, token usage breakdown in the bundled Electron app:\n\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n