Trea国际国内多账号反代网关,Trae 国际/国内双区多账号 OpenAI 兼容网关 — 直连推理、账号池、模型目录、额度预警/自动降级、API Key 配额与白名单、图形化看板、Docker 零依赖
Available after the catalog security scan passes.
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
# Add to your Claude Code skills
git clone https://github.com/shuishuipingan/trae2api-hubGuides for using api integration skills like trae2api-hub.
See how trae2api-hub compares with popular alternatives.
Trae2API-Hub 把 Trae 国际版与国内版的原生模型服务封装成标准 OpenAI 兼容 API,支持 Chat Completions、Responses(Codex / Claude Code)与 Anthropic Messages。项目提供双区账号池、自动换区、模型目录、流式推理、工具调用,以及一套完整的 Web 监控看板。
1.1.5 的核心变化:模型状态更准确。 官方客户端可用、但网关 raw_chat 未接入的模型标为「仅 App」,不再误显示为「不可用」;同 Key 模型行自动去重。 看板现在直接读取 Trae v2 entitlement 的 usage_summary,并同时展示国内版与国际版账号。 看板检测到新版本后会显示顶部徽标与「一键更新」按钮,点击即可下载、备份、替换并自动重启。
1.0.0 的基础:国际版不再需要 Trae 桌面版。
修复了旧版本头导致的4015和错误鉴权方案导致的4023,国际版现在使用当前客户端版本头 +Authorization: Bearer <access_token>直接调用官方llm_raw_chat。Docker / Linux 无桌面环境可以直接运行,不需要启动 Trae、调试端口或websocket-client。
网关总览 — 双区状态、账号池、调度器与实时请求:

模型库 — 双区模型、上下文/最大输出/思考档位、Free / 升级标记:

API Key 用量 — 按 Key 的 Token 趋势、模型分布、延迟、日配额与最近请求:

设置 — API Key、模型白名单、日配额、自动降级、配置备份:

core-normal.traeapi.us,直接 HTTP,不依赖桌面版api.trae.com.cn,沿用成熟链路?realm= / X-Realm 永远优先upgrade_required=true,不会伪装成“风控”notify_usage,提供 /quota、/v1/quotaX-Trae-DegradedGemini-*、Kimi-* 等 fnmatch 通配daily_requests / daily_tokens,0 = 不限制/v1/chat/completions/v1/responses(Codex / Claude Code)/v1/messagesreasoning_content、工具调用、DSML 回退解析GET /config/export、POST /config/restoreWindows:
§bat start-trae2api-hub.bat §
Linux / macOS:
§bash chmod +x start-trae2api-hub.sh ./start-trae2api-hub.sh §
http://127.0.0.1:8791/v1http://127.0.0.1:8791/admin(登录后请立即修改)§bash git clone https://github.com/shuishuipingan/trae2api-hub.git cd trae2api-hub docker compose up -d --build docker compose logs -f §
8791./accounts(凭证 / 设置)、./usage(用量流水)§bash docker compose logs trae2api-hub | grep -i "api key" §
`§bash docker pull ghcr.io/shuishuipingan/trae2api-hub:latest
docker run -d --name trae2api-hub --restart unless-stopped
-p 8791:8791
-v $(pwd)/accounts:/app/accounts
-v $(pwd)/usage:/app/usage
-e TZ=Asia/Shanghai
ghcr.io/shuishuipingan/trae2api-hub:latest
`§
§bash curl http://127.0.0.1:8791/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "model": "Gemini-3.1-Pro-Preview", "messages": [{"role": "user", "content": "用三句话介绍 Trae"}], "stream": true }' §
`§python from openai import OpenAI
client = OpenAI( base_url="http://127.0.0.1:8791/v1", api_key="YOUR_API_KEY", )
resp = client.chat.completions.create( model="Doubao-1.5-pro", messages=[{"role": "user", "content": "你好"}], ) print(resp.choices[0].message.content) `§
§bash curl "http://127.0.0.1:8791/v1/models?realm=intl" curl "http://127.0.0.1:8791/v1/models?realm=cn" §
国际版 /v1/models 当前目录 10 个,其中 6 个 Free 可用:
| 模型 | 状态 |
|---|---|
| Gemini-3.1-Pro-Preview | ✅ Free |
| Gemini-3-Flash-Preview | ✅ Free |
| Gemini-2.5-Pro | ✅ Free |
| Gemini-2.5-Flash | ✅ Free |
| Kimi-K2-0905 | ✅ Free |
| Grok-4 | ✅ Free |
| Claude-Opus-4.7 | ⬆️ 需升级 |
| Claude-Sonnet-4.6 | ⬆️ 需升级 |
| GPT-5.5 | ⬆️ 需升级 |
| GPT-6-Astra | ⬆️ 需升级 |
官方免费额度用尽时返回 4008 quota exceeded,网关统一转成 HTTP 429 + Retry-After: 60,不会冷却账号,也不会伪装成 4015 风控。
`§http HTTP/1.1 429 Too Many Requests Retry-After: 60
{ "error": { "type": "quota_exceeded", "message": "Trae 免费额度已用尽(4008 quota exceeded)..." } } `§
查看剩余额度:
§bash curl -H "X-Panel-Token: $PANEL_TOKEN" http://127.0.0.1:8791/quota §
设置页「API Key 与出口绑定」每个 Key 支持:
§json { "name": "Cursor", "realm": "intl", "models": ["Gemini-*", "Kimi-*"], "daily_requests": 200, "daily_tokens": 2000000 } §
models:大小写不敏感,支持 * 通配;空 = 不限制daily_requests:当日成功请求数;0 = 不限制daily_tokens:当日成功请求 token;0 = 不限制usage.jsonl,10 秒缓存,不增加上游调用设置页可配置:
§json { "enabled": true, "fallback_model": "Doubao-1.5-pro", "fallback_realm": "cn", "on_quota": true, "on_upgrade": true, "warn_below": 10 } §
触发后自动换模型/出口:
§http X-Trae-Degraded: Gemini-3.1-Pro-Preview -> Doubao-1.5-pro (quota) §
INTL 额度已用尽设置页「配置备份 / 恢复」:
settings(面板密码、API Key、limits、auto_degrade)+ 双区账号凭证accounts/config-backup-<时间>.json接口:
§http GET /config/export?download=1 POST /config/restore §
两者都需要 面板 token,不接受普通 API Key。
update-backups/ → 替换代码 → 重启网关。/health,检测到新版本后自动刷新;进度与错误写入 update.log。accounts/、usage/、.git/、update-backups/。回滚:停止网关,解压最近的 update-backups/update-*.tar.gz 覆盖项目目录,再重新启动。
Docker 部署不支持容器内自更新(重建后文件会丢失)。请使用
docker compose pull && docker compose up -d。
0.0.0.0:8791/app/accounts 和 /app/usageHOST / PORT / API_KEY / TZ 环境变量可覆盖GET /ping.gitignore 已排除§text trae2api-hub/ ├── trae_proxy.py # HTTP 网关、路由、看板 API、SSE ├── trae_client.py # CN / INTL 上游协议与流式解析 ├── trae_accounts.py # 账号池、凭证、冷却、导出 ├── trae_catalog.py # 双区模型目录与元数据 ├── trae_anthropic.py # Anthropic Messages 适配 ├── trae_pricing.py # 成本估算 ├── trae_scheduler.py # 定时任务 ├── trae_tasks.py # 签到 / 保活 / 刷新 ├── dashboard.html # 看板(8 页签) ├── dashboard-v3.js/.css # 看板交互与玻璃拟态主题 ├── dashboard-charts.js # 零依赖 Canvas 图表 ├── Dockerfile ├── docker-compose.yml ├── docs/img/ # 看板截图 └── .github/workflows/ # 测试 + GHCR 多架构构建 §
§bash python _test_trae.py §
当前基线:
§text PASS=204 FAIL=0 SKIP=0 §
诊断:
§bash python _diag_gateway.py --chat §
accounts/ 内含 token、refresh token、面板密码哈希、API Key;绝不要提交usage/ 含请求流水;同样不要提交CN 的 SOLO/Agent 模型通过纯 HTTP 通道执行:
POST https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat
function = solo_work_lite
这条通道只需要:
Authorization: Cloud-IDE-JWT <accessToken>
X-Cloudide-Token / X-Ide-Token / X-Uid
X-Machine-Id / X-Device-Id
不需要 SQLCipher、不需要 AHA、不需要本机 Trae CN 进程。
/v1/chat/completions -> 自动识别 20 个 SOLO 模型
/v1/agent/chat -> 显式 Agent 入口
示例:
curl -X POST http://127.0.0.1:8791/v1/chat/completions \
-H "Content-Type: application/json" \
-d "{\"model\":\"deepseek-v4.1-flash\",\"messages\":[{\"role\":\"user\",\"content\":\"只回答好\"}]}"
每个账号需要自己有效的 accessToken,以及该账号登录设备的:
machine_id
device_id
网关优先从账号 extra 的 machine_id/device_id 读取,其次读环境变量:
TRAE_DEVICE_ID
TRAE_MACHINE_ID
因此换设备时把该设备的 device_id/machine_id 写进账号或环境变量即可;换账号时导入该账号自己的 accessToken。不会再依赖本机 App 或 SQLCipher。
旧的 UI/AHA 桥还保留在 tools/trae_ui_agent.mjs,只有在设置:
TRAE_AGENT_UI_FALLBACK=1
且本机 Trae CN 以 CDP 9335 启动时才作为 fallback 使用。
没有有效 CN accessToken,或 device_id/machine_id 与该账号设备不匹配时,SOLO 通道会被上游拒绝。这不是无账号方案。
Trae 是其所属公司的商标。本项目为个人学习与自托管网关实践,与官方无隶属关系;请遵守你所在地法律及官方服务条款,仅使用你拥有合法访问权的账号。
trae2api-hub is an open-source api integration skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by shuishuipingan. Trea国际国内多账号反代网关,Trae 国际/国内双区多账号 OpenAI 兼容网关 — 直连推理、账号池、模型目录、额度预警/自动降级、API Key 配额与白名单、图形化看板、Docker 零依赖. It has 50 GitHub stars.
trae2api-hub's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/shuishuipingan/trae2api-hub" and add it to your Claude Code skills directory (see the Installation section above).
trae2api-hub is primarily written in Python. It is open-source under shuishuipingan on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other API Integration skills you can browse and compare side by side. Open the API Integration category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh trae2api-hub against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars