Skip to content

Commit 3079450

Browse files
authored
Merge pull request #36 from cuipengfei/czy-all
Sync caozhiyuan/dev: README and desktop app screenshots
2 parents edaeb01 + 14f2cba commit 3079450

5 files changed

Lines changed: 196 additions & 166 deletions

File tree

README.md

Lines changed: 97 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ https://github.com/caozhiyuan/copilot-api/releases
176176

177177
Download the installer for your platform, sign in 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.
178178

179+
### Desktop App Screenshots
180+
181+
Main dashboard, token usage breakdown in the bundled Electron app:
182+
183+
<p align="center">
184+
<img src="./docs/screenshots/desktop-dashboard.png" alt="Copilot API desktop app dashboard" width="49%" />
185+
<img src="./docs/screenshots/desktop-token-usage.png" alt="Copilot API desktop app token usage view" width="49%" />
186+
</p>
187+
179188
## Using with Docker
180189

181190
Build image
@@ -500,6 +509,65 @@ npx @jeffreycao/copilot-api@latest --api-home=/custom/path --oauth-app=opencode
500509
bunx --bun @jeffreycao/copilot-api@latest start
501510
```
502511

512+
## Using with Claude Code
513+
514+
This proxy can be used to power [Claude Code](https://docs.anthropic.com/en/claude-code), an experimental conversational AI assistant for developers from Anthropic.
515+
516+
There are two ways to configure Claude Code to use this proxy:
517+
518+
### Interactive Setup with `--claude-code` flag
519+
520+
To get started, run the `start` command with the `--claude-code` flag:
521+
522+
```sh
523+
npx @jeffreycao/copilot-api@latest start --claude-code
524+
```
525+
526+
You will be prompted to select a primary model and a "small, fast" model for background tasks. After selecting the models, a command will be copied to your clipboard. This command sets the necessary environment variables for Claude Code to use the proxy.
527+
528+
Paste and run this command in a new terminal to launch Claude Code.
529+
530+
### Manual Configuration with `settings.json`
531+
532+
Alternatively, you can configure Claude Code by creating a `.claude/settings.json` file in your project's root directory. This file should contain the environment variables needed by Claude Code. This way you don't need to run the interactive setup every time.
533+
534+
Here is an example `.claude/settings.json` file:
535+
536+
```json
537+
{
538+
"env": {
539+
"ANTHROPIC_BASE_URL": "http://localhost:4141",
540+
"ANTHROPIC_AUTH_TOKEN": "dummy",
541+
"ANTHROPIC_MODEL": "gpt-5.4",
542+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-5.4",
543+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-5-mini",
544+
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
545+
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
546+
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
547+
"CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false",
548+
"CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "true",
549+
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0",
550+
"CLAUDE_PLUGIN_ENABLE_QUESTION_RULES": "true"
551+
},
552+
"permissions": {
553+
"deny": [
554+
"WebSearch",
555+
"mcp__ide__executeCode"
556+
]
557+
}
558+
}
559+
```
560+
561+
- Replace `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` according to your needs. After configuration, please install the claude code plugin [Plugin Integrations](#plugin-integrations). If configuring the claude model, it is recommended to set all model configurations the same, so as to remain consistent with github-copilot claude agent behavior.
562+
- Setting CLAUDE_CODE_ATTRIBUTION_HEADER to 0 can prevent Claude code from adding billing and version information in system prompts, thereby avoiding prompt cache invalidation.
563+
- Turning off CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION and CLAUDE_CODE_ENABLE_AWAY_SUMMARY can prevent quota from being consumed unnecessarily.
564+
- Permissions deny WebSearch because the GitHub Copilot API does not support natie websearch (some gpt models support websearch, but the current project has not adapted websearch); it is recommended to install the mcp mcp_server_fetch tool or other search tools as alternatives..
565+
- If using a non-Claude model, do not enable ENABLE_TOOL_SEARCH. If using the Claude model, can enable ENABLE_TOOL_SEARCH. The current Claude Code uses the client tool search mode. In this mode, loading defer tools requires an additional request each time.
566+
567+
You can find more options here: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
568+
569+
You can also read more about IDE integration here: [Add Claude Code to your IDE](https://docs.anthropic.com/en/docs/claude-code/ide-integrations)
570+
503571
## Using with OpenCode
504572

505573
OpenCode already has a direct GitHub Copilot provider. Use this section when you want OpenCode to point at this proxy through `@ai-sdk/anthropic` and reuse the agent behaviors described earlier in this README.
@@ -590,88 +658,6 @@ Why these fields matter:
590658
- `model`, `small_model`, and `agent.*.model` let you keep `gpt-5.4` for build/plan work while routing exploration and background work to `gpt-5-mini`.
591659
- If you enable `auth.apiKeys` in this proxy, replace `dummy` with a real key. Otherwise any placeholder value is fine.
592660

593-
## Using the Usage Viewer
594-
595-
After starting the server, a URL to the Copilot Usage Dashboard will be displayed in your console. This dashboard is a web interface for monitoring your API usage.
596-
597-
1. Start the server. For example, using npx:
598-
```sh
599-
npx @jeffreycao/copilot-api@latest start
600-
```
601-
2. The server will output a URL to the usage viewer. Copy and paste this URL into your browser. It will look something like this:
602-
`http://localhost:4141/usage-viewer?endpoint=http://localhost:4141/usage`
603-
- If you use the `start.bat` script on Windows, this page will open automatically.
604-
605-
The dashboard provides a user-friendly interface to view your Copilot usage data:
606-
607-
> Token usage history requires Bun or Node.js >= 22.13.0. On Node.js < 22.13.0, the server runs normally but token usage storage is disabled.
608-
609-
- **API Endpoint URL**: The dashboard is pre-configured to fetch data from your local server endpoint via the URL query parameter. You can change this URL to point to any other compatible API endpoint.
610-
- **Fetch Data**: Click the "Fetch" button to load or refresh the usage data. The dashboard will automatically fetch data on load.
611-
- **Usage Quotas**: View a summary of your usage quotas for different services like Chat and Completions, displayed with progress bars for a quick overview.
612-
- **Detailed Information**: See the full JSON response from the API for a detailed breakdown of all available usage statistics.
613-
- **URL-based Configuration**: You can also specify the API endpoint directly in the URL using a query parameter. This is useful for bookmarks or sharing links. For example:
614-
`http://localhost:4141/usage-viewer?endpoint=http://your-api-server/usage`
615-
616-
## Using with Claude Code
617-
618-
This proxy can be used to power [Claude Code](https://docs.anthropic.com/en/claude-code), an experimental conversational AI assistant for developers from Anthropic.
619-
620-
There are two ways to configure Claude Code to use this proxy:
621-
622-
### Interactive Setup with `--claude-code` flag
623-
624-
To get started, run the `start` command with the `--claude-code` flag:
625-
626-
```sh
627-
npx @jeffreycao/copilot-api@latest start --claude-code
628-
```
629-
630-
You will be prompted to select a primary model and a "small, fast" model for background tasks. After selecting the models, a command will be copied to your clipboard. This command sets the necessary environment variables for Claude Code to use the proxy.
631-
632-
Paste and run this command in a new terminal to launch Claude Code.
633-
634-
### Manual Configuration with `settings.json`
635-
636-
Alternatively, you can configure Claude Code by creating a `.claude/settings.json` file in your project's root directory. This file should contain the environment variables needed by Claude Code. This way you don't need to run the interactive setup every time.
637-
638-
Here is an example `.claude/settings.json` file:
639-
640-
```json
641-
{
642-
"env": {
643-
"ANTHROPIC_BASE_URL": "http://localhost:4141",
644-
"ANTHROPIC_AUTH_TOKEN": "dummy",
645-
"ANTHROPIC_MODEL": "gpt-5.4",
646-
"ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-5.4",
647-
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-5-mini",
648-
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
649-
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
650-
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
651-
"CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false",
652-
"CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "true",
653-
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0",
654-
"CLAUDE_PLUGIN_ENABLE_QUESTION_RULES": "true"
655-
},
656-
"permissions": {
657-
"deny": [
658-
"WebSearch",
659-
"mcp__ide__executeCode"
660-
]
661-
}
662-
}
663-
```
664-
665-
- Replace `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` according to your needs. After configuration, please install the claude code plugin [Plugin Integrations](#plugin-integrations). If configuring the claude model, it is recommended to set all model configurations the same, so as to remain consistent with github-copilot claude agent behavior.
666-
- Setting CLAUDE_CODE_ATTRIBUTION_HEADER to 0 can prevent Claude code from adding billing and version information in system prompts, thereby avoiding prompt cache invalidation.
667-
- Turning off CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION and CLAUDE_CODE_ENABLE_AWAY_SUMMARY can prevent quota from being consumed unnecessarily.
668-
- Permissions deny WebSearch because the GitHub Copilot API does not support natie websearch (some gpt models support websearch, but the current project has not adapted websearch); it is recommended to install the mcp mcp_server_fetch tool or other search tools as alternatives..
669-
- If using a non-Claude model, do not enable ENABLE_TOOL_SEARCH. If using the Claude model, can enable ENABLE_TOOL_SEARCH. The current Claude Code uses the client tool search mode. In this mode, loading defer tools requires an additional request each time.
670-
671-
You can find more options here: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
672-
673-
You can also read more about IDE integration here: [Add Claude Code to your IDE](https://docs.anthropic.com/en/docs/claude-code/ide-integrations)
674-
675661
## Plugin Integrations
676662

677663
Plugin integrations are available for Claude Code and opencode.
@@ -726,6 +712,35 @@ Or manually create the file at `~/.config/opencode/plugins/subagent-marker.js` w
726712

727713
The plugin hooks into `session.created`, `session.deleted`, `chat.message`, and `chat.headers` events to provide seamless subagent marker functionality.
728714

715+
## Using the Usage Viewer
716+
717+
After starting the server, a URL to the Copilot Usage Dashboard will be displayed in your console. This dashboard is a web interface for monitoring your API usage.
718+
719+
1. Start the server. For example, using npx:
720+
```sh
721+
npx @jeffreycao/copilot-api@latest start
722+
```
723+
2. The server will output a URL to the usage viewer. Copy and paste this URL into your browser. It will look something like this:
724+
`http://localhost:4141/usage-viewer?endpoint=http://localhost:4141/usage`
725+
- If you use the `start.bat` script on Windows, this page will open automatically.
726+
727+
The dashboard provides a user-friendly interface to view your Copilot usage data:
728+
729+
> Token usage history requires Bun or Node.js >= 22.13.0. On Node.js < 22.13.0, the server runs normally but token usage storage is disabled.
730+
731+
- **API Endpoint URL**: The dashboard is pre-configured to fetch data from your local server endpoint via the URL query parameter. You can change this URL to point to any other compatible API endpoint.
732+
- **Fetch Data**: Click the "Fetch" button to load or refresh the usage data. The dashboard will automatically fetch data on load.
733+
- **Usage Quotas**: View a summary of your usage quotas for different services like Chat and Completions, displayed with progress bars for a quick overview.
734+
- **Detailed Information**: See the full JSON response from the API for a detailed breakdown of all available usage statistics.
735+
- **URL-based Configuration**: You can also specify the API endpoint directly in the URL using a query parameter. This is useful for bookmarks or sharing links. For example:
736+
`http://localhost:4141/usage-viewer?endpoint=http://your-api-server/usage`
737+
738+
### Usage Viewer Screenshot
739+
740+
<p align="center">
741+
<img src="./docs/screenshots/usage-viewer.png" alt="Copilot API usage viewer" width="900" />
742+
</p>
743+
729744
## Running from Source
730745

731746
The project can be run from source in several ways:

0 commit comments

Comments
 (0)