Casually/dsh-trae-api

Project Overview项目介绍

This repository is a native DeepSeek Harness (DSH) plugin that can also be run as a standalone service. Its core function is to expose existing Trae IDE credits as a local API service compatible with OpenAI and Anthropic’s interface standards. This allows popular third-party AI coding agents including Claude Code, Cursor, Cline, and Windsurf to directly call underlying models hosted by Trae, including GLM, DeepSeek, Qwen, Kimi, and MiniMax. It supports all four current versions of Trae: Trae CN, TRAE SOLO CN, Trae SG, and TRAE SOLO SG, and automatically decrypts authentication tokens stored in local Trae files.

Before installation, users must first install and log into a supported version of Trae IDE on their local machine. There are two installation paths available: the recommended method is to install it as a DSH plugin, which only requires running dsh plugin --profile web add @casually/dsh-trae-api and restarting DSH to automatically activate the proxy. The alternative is to run it standalone by cloning the repo, installing dependencies with npm install, and launching it with the included start script. On first run, it automatically extracts and decrypts Trae authentication data and saves it to a local .env file. It is built for developers who already have Trae credits and want to use Trae’s models in third-party AI coding tools.

This project requires Node.js 18 or newer, and is released under the open source MIT license. By default, the service only listens on 127.0.0.1, which blocks access from external networks. If you need to open access to devices on the local area network, you must change the host setting and set a strong custom API key to prevent unauthorized use. CORS restrictions only allow cross-origin requests from localhost, which prevents third-party web pages from misusing your Trae credits. The tool is for educational and research use only, and users are responsible for any costs or compliance issues that arise from use.

本项目是 DeepSeek Harness(DSH)原生插件,也可独立运行,作用是将 Trae IDE 的积分额度转化为本地兼容 OpenAI/Anthropic 标准的 API 服务,让 Claude Code、Cursor、Cline、Windsurf 等第三方 AI 编程工具直接调用 Trae 底层模型。它支持 Trae CN、TRAE SOLO CN、Trae 国际版、TRAE SOLO 国际版四个版本,可自动从本地 Trae 存储文件中解密认证 Token。

用户需先在本机安装并登录对应版本的 Trae IDE,之后可选择两种部署方式:作为 DSH 插件安装时,执行 dsh plugin --profile web add @casually/dsh-trae-api 后重启 DSH 即可自动启动代理服务;也可拉取源码后独立运行,首次启动会自动解密 Trae 认证数据并保存。它适合已有 Trae 可用积分,想在第三方 AI 编程工具中调用 Trae 底层模型的开发者使用。

本项目要求 Node.js 版本不低于 18,采用 MIT 许可证开源。使用时默认监听 127.0.0.1,仅允许本地访问,如需开放局域网需自行修改配置并设置强 API Key。工具仅作学习研究使用,使用产生的费用与合规问题由用户自行承担,需遵守 Trae 平台的使用条款。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add @casually/dsh-trae-api

把 Casually/dsh-trae-api 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

原项目:https://github.com/Wang-JQ77/dsh-trae-api

dsh-trae-api (Trae Local API)

将 Trae Work CN 的积分/额度转化为本地 OpenAI/Anthropic 兼容 API 服务,让 Claude Code、Cursor、Cline、Windsurf 等第三方 AI 编程工具直接调用 Trae 底层模型(GLM、DeepSeek、Qwen、Kimi、MiniMax 等)。

本项目是一个 DeepSeek Harness (DSH) 插件(npm 包名 @casually/dsh-trae-api),安装后随 dsh 启动自动运行代理服务;也可以独立运行。

npm 上的无 scope 包名 dsh-trae-api 归原项目作者所有;本 fork 以 @casually/dsh-trae-api 发布。

v1.1.0 新增:DSH Web 设置页面(设置 → Trae API 代理)——实时状态、请求统计、Token 管理(刷新/重新解密)、上游连通性测试、配置热更新(保存即生效,无需重启 DSH)。

原理

  1. 本机已安装并登录 Trae Work CN(或 TRAE SOLO CN / Trae SG / TRAE SOLO)
  2. 脚本自动从本地 storage.json 中解密认证 Token(支持 tc 加密和明文两种格式)
  3. 启动一个本地 Express 服务器,提供 OpenAI/Anthropic 兼容的 API 端点
  4. 第三方 Agent 将请求发送到本地服务器,本地服务器转发到 Trae 上游 API
  5. 消耗的是 Trae 的积分,无需额外付费

支持的 Trae 版本

版本 IDE 名称 加密格式 上游端点
cn Trae CN 国内版 tc 加密 trae-api-cn.mchost.guru
solo TRAE SOLO CN 独立部署版 tc 加密 trae-api-cn.mchost.guru
sg Trae 国际版 明文 JSON a0ai-api-sg.byteintlapi.com
solo-sg TRAE SOLO 国际版 tc 加密 a0ai-api-sg.byteintlapi.com

功能

  • 自动解密四版本认证数据,无需手动配置 Token
  • 提供 OpenAI (/v1/chat/completions) 和 Anthropic (/v1/messages) 兼容接口
  • 支持 OpenAI Responses API (/v1/responses),兼容新版 OpenAI SDK 和 Agents SDK
  • Token 过期自动刷新,自动保存到 .env
  • 支持流式输出 (SSE)
  • 完整支持 Claude Code 工具调用
  • 3 级 API 端点回退机制
  • 自适应 CN/SG 两种 SSE 事件格式
  • 上下文窗口自动截断,避免超出 Token 限制
  • DSH 设置页面(v1.1.0+):
    • 运行状态一览(监听地址、版本、上游、用户、Token/Refresh 过期倒计时)
    • 请求统计(各端点请求数、错误数、运行时长)
    • 一键刷新 Token / 重新解密凭证 / 测试上游连接
    • 端口、监听地址、API Key、版本、上游地址、上下文上限在线修改,保存后代理热重启立即生效

前置条件

  • Node.js >= 18(内置 fetch 支持)
  • 已安装并登录以下任一 Trae IDE:
    • Trae CN(国内版)
    • TRAE SOLO CN(独立部署版)
    • Trae(国际版)
    • TRAE SOLO(国际版)
  • 对应 IDE 的 %APPDATA% 目录下存在 globalStorage/storage.json

快速开始

方式 A:作为 DSH 插件安装(推荐)

前提:已安装 DeepSeek Harness(dsh CLI)。

# 安装到 web profile
dsh plugin --profile web add @casually/dsh-trae-api

# 重启 dsh 使插件生效
dsh web

插件启动后,代理服务自动运行在 http://localhost:9220。可通过插件配置自定义端口和 API Key:

# 编辑 profile 的 cordis.patch.yml
- insert:
    - id: trae-api
      name: '@casually/dsh-trae-api'
      config:
        port: 9220
        apiKey: ***

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev onebox-dsh-bridge 下一个 Next dsh-edu →