◉ Pulse
cszf1 avatar
#27 today

cszf1/keel-code-switch

TypeScript Other

Local Anthropic-compatible proxy for keelcode with multi-account pool and web UI

Created Jul 29, 2026
Stars
8
Today
+8
Forks
0
Quality
80/100
Momentum
17

README

Fetched from GitHub on Oct 30, 2026, 10:15 PM UTC · README.md

View original on GitHub

Third-party content — Open Source Pulse is not the owner of this repository.

This README belongs to cszf1/keel-code-switch and its contributors. We fetch it directly from the project’s public GitHub repository and display it for reference only. All text, code, images and trademarks remain the property of their respective authors. See the repository for its license terms. Copyright / takedown policy.

keelcode-proxy

本地 Anthropic 兼容代理:让 Claude Code / 其它标准 Anthropic 客户端走 keelcode 托管 API,支持多账号轮换与网页管理。

为什么需要

keelcode API 兼容 Anthropic Messages,但和 Claude Code 直连仍有差异:

  • 认证:keelcode 要 Authorization: Bearer,客户端常发 x-api-key
  • content:keelcode 要 [{type:"text",text}],客户端可能发字符串
  • 模型名:keelcode 自定义名(kimi-k3、deepseek-v4-pro 等)
  • stream:keelcode 只支持 stream:true
  • max_tokens:各模型上限不同
  • 部分字段会被拒绝:cache_control、thinking.type=adaptive、tool 的 $schema / defer_loading 等
  • tool description 过长会被拒

本代理自动做协议适配与字段清洗。

依赖

快速开始

# 安装 Bun 后
bun run proxy.ts
# 或指定端口
bun run proxy.ts --port 8082

Windows 后台启动:

.\start-hidden.ps1

默认监听:http://127.0.0.1:8082(仅本机)

网页管理

浏览器打开:http://127.0.0.1:8082/

  • 网页 OAuth 登录(device code,无需安装 keelcode CLI)
  • 账号池状态 / 启用禁用 / 删除 / 重置 / 日额度
  • 粘贴 token 或完整 JSON 添加账号
  • 导入 ~/.keelcode/credentials.json(若本机曾用过 CLI)
  • 热加载、模型列表、调试日志

配置客户端(示例)

任意 Anthropic Messages 兼容客户端:

Base URL:  http://127.0.0.1:8082
API Key:   任意非空字符串(真实 token 在账号池)

Claude Code 环境变量示例:

set ANTHROPIC_BASE_URL=http://127.0.0.1:8082
set ANTHROPIC_API_KEY=keelcode

常用模型:kimi-k3、deepseek-v4-pro、deepseek-v4-flash、glm-5.2 等。也支持部分标准 Anthropic 名,代理会映射。

Free 额度下 Open models 通常更稳;Claude / GPT 可能出现 provider_unavailable。

多账号

把多个凭证放到 credentials/:

credentials/
  account1.json
  account2.json

格式与 keelcode 原生 ~/.keelcode/credentials.json 一致:

{
  "accessToken": "…",
  "expiresAt": "2026-08-01T12:00:00.000Z"
}

轮换策略:

  • 请求级 round-robin
  • 401 → 标坏并跳过
  • 429 → 冷却 60s 后换号
  • 过期 / disabled → 跳过
  • ~/.keelcode/credentials.json 可作为 fallback(token 去重)

添加账号:

python add-account.py work

或在网页 UI 里粘贴 / 导入。

管理 API

curl http://127.0.0.1:8082/api/status
curl -X POST http://127.0.0.1:8082/api/pool/reload
curl http://127.0.0.1:8082/api/models

兼容旧路径:/pool/status、/pool/reload。

启动参数

bun run proxy.ts [--port 8082] [--creds-dir <path>]
  • --port 默认 8082
  • --creds-dir 默认 ./credentials

目录结构

.
├── proxy.ts           # 代理 + 管理 API
├── public/index.html  # 管理 UI
├── add-account.py     # CLI 加号
├── start.ps1          # 前台启动
├── start-hidden.ps1   # 后台启动
└── credentials/       # 本地凭证(勿提交)

安全

  • 默认只绑定 127.0.0.1
  • 不要把 credentials/*.json、日志提交到 Git
  • Token / 邮箱等敏感信息不会出现在公开 README;UI 对邮箱做匿名显示

调试

  • 运行日志:stderr 或 logs/
  • 请求详情:proxy-debug.log(本地,已 gitignore)

常见问题:

现象 处理
400 invalid_request 看 debug 日志;代理会清洗 adaptive thinking / $schema 等
503 provider_unavailable 换 Open 模型或稍后重试
401 token 过期,重新 keelcode login 并导入
EADDRINUSE 端口被占,结束占用进程或换 --port

License

以原仓库为准。本仓库为协议适配与本地管理增强。

Rendered by GitHub from the repository’s README. Scroll to read the full file.
First trending

Jul 30, 2026

first spotted on the list

Best rank

#27

highest position reached

Appearances

1

times on the trending list

Quality score

80

out of 100

Momentum

17

trend strength indicator

Star velocity

0.09

stars per day since creation

Activity — last 60 days

daily counts, collected every 6 hours
  • Stars
  • Forks
  • Merged PRs
  • Issues
  • Closed issues

Collecting activity data since launch — check back in a few days.

Star history

total stars per snapshot

Not enough snapshots yet — check back soon.

Rank history

position on trending · lower is better

Not enough snapshots yet — check back soon.

3D card for your website

Live HTML card with a glass surface and pointer tilt. Paste the iframe on any website.

<iframe src="https://www.notionpulse.cc/embed/cszf1/keel-code-switch" width="420" height="240" style="border:0;max-width:100%;background:transparent" loading="lazy" title="cszf1/keel-code-switch — trending on Open Source Pulse"></iframe>

Stars badge

Show current stars in your README or profile. Auto-updates every 6 hours.

cszf1/keel-code-switch stars badge
Markdown
[![cszf1/keel-code-switch](https://www.notionpulse.cc/api/badge/cszf1/keel-code-switch.svg)](https://www.notionpulse.cc/repo/cszf1/keel-code-switch)
HTML
<a href="https://www.notionpulse.cc/repo/cszf1/keel-code-switch"><img src="https://www.notionpulse.cc/api/badge/cszf1/keel-code-switch.svg" alt="cszf1/keel-code-switch stars badge" /></a>

Repository of the Day

#27 Repository of the Day

Repository of the Week

#27 Repository of the Week

Repository of the Month

#27 Repository of the Month