npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

turing-sdk

v1.1.7

Published

Node.js SDK for Turing Code with query, stream, and streamText APIs.

Readme

turing-sdk

Turing Code 的 Node.js SDK。

它给你一个接近 Claude Code SDK 风格的程序化调用入口,可以直接在 Node.js 代码里使用 querystreamstreamText

English version: README.md

Quick Install

npm install turing-sdk
export SUBLB_API_KEY="your-key"
import { createTuringClient } from 'turing-sdk'

const client = createTuringClient({
  preset: 'sublb',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
  model: 'gpt-5.4',
})

const result = await client.query('只回复 ok')
console.log(result.text)

预期输出:

ok

这是什么?

turing-sdkTuring Code 的 Node.js SDK,适合把 Turing 接进脚本、服务、队列、自动化流程和其他程序化工作流。

如果你希望保留 turing-code 的能力,但又不想只停留在命令行里,而是要在业务代码里驱动它,这个包就是为此准备的。

为什么叫 Turing?

Turing Code 这个名字,是为了纪念 Alan Turing(艾伦·图灵)

图灵为现代计算机科学奠定了基础,尤其是“通用计算”这一核心思想。同时,他关于机器智能的思考,也深刻影响了后来人工智能的发展,最广为人知的代表之一就是 Turing Test(图灵测试)

我们使用这个名字,是想提醒自己:好的工具,不只是替人输出结果,更应该帮助人扩大思考能力。

重要说明

  • 这个包是 Node.js SDK,不是浏览器直连 SDK。
  • 安装 turing-sdk 时,也会安装 turing-code,后者会继续下载底层 turing 平台二进制。
  • 下方示例默认使用真实 OpenAI-compatible 入口:https://sub-lb.tap365.org/v1
  • 当前版本化安装资源分发自:
    • https://turing.tap365.org/
    • https://tap365.cn/turing/

最小查询示例

import { createTuringClient } from 'turing-sdk'

const client = createTuringClient({
  preset: 'sublb',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
  model: 'gpt-5.4',
})

const result = await client.query('只回复 ok')
console.log(result.text)

流式

原始事件流

import { createTuringClient } from 'turing-sdk'

const client = createTuringClient({
  preset: 'sublb',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
})

for await (const event of client.stream('写一个 hello world')) {
  console.log(event.type, event)
}

纯文本流

import { createTuringClient } from 'turing-sdk'

const client = createTuringClient({
  preset: 'sublb',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
})

for await (const chunk of client.streamText('写一个 hello world')) {
  process.stdout.write(chunk)
}

使用 OpenAI-compatible Key

如果你的 Key 是 sk-* 或其他 OpenAI-compatible Key,也可以继续使用同一个入口:

import { createTuringClient } from 'turing-sdk'

const client = createTuringClient({
  preset: 'openai',
  apiKey: process.env.OPENAI_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
  model: 'gpt-5.4',
})

const result = await client.query('只回复 ok')
console.log(result.text)

Provider 与 endpoint 约定

所有内置 preset 默认都可以共用:https://sub-lb.tap365.org/v1

SDK 会按 preset 自动选择协议 endpoint,通常只需要配置同一个 baseUrl

| preset | 默认入口 | 默认 endpoint | 说明 | | --- | --- | --- | --- | | sublb | https://sub-lb.tap365.org/v1 | /responses | 推荐默认使用 | | openai | https://sub-lb.tap365.org/v1 | /responses | OpenAI-compatible Responses | | grok | https://sub-lb.tap365.org/v1 | /responses | OpenAI-compatible Responses | | google | https://sub-lb.tap365.org/v1 | /chat/completions | OpenAI-compatible Chat Completions | | gemini | https://sub-lb.tap365.org/v1 | /chat/completions | OpenAI-compatible Chat Completions | | claude | https://sub-lb.tap365.org/v1 | /messages | Anthropic Messages |

如果你没有显式传 preset

  • 传了 baseUrl 时,默认按 OpenAI-compatible 处理
  • apiKeysk- 开头时,默认按 openai 处理
  • 其他情况默认走 sublb

Claude / Anthropic system 兼容

Anthropic Messages 协议要求 system 放在请求体顶层。SDK 默认按这个规范发送:

const client = createTuringClient({
  preset: 'claude',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
  model: 'claude-opus-4-8',
  systemPrompt: '你是严谨的代码助手。',
})

如果某些 OpenAI-compatible 中转站不兼容 Anthropic 顶层 system 字段,可以关闭发送:

const client = createTuringClient({
  preset: 'claude',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
  model: 'claude-opus-4-8',
  systemPrompt: '你是严谨的代码助手。',
  anthropicSystemMode: 'disabled',
})

也可以用环境变量关闭:

export TURING_ANTHROPIC_SYSTEM_MODE=disabled

常用参数

const client = createTuringClient({
  preset: 'sublb',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
  model: 'gpt-5.4',
  cwd: process.cwd(),
  timeoutMs: 60_000,
  maxTurns: 6,
  extraArgs: ['--dangerously-skip-permissions'],
})

支持的核心参数:

  • preset
  • apiKey
  • baseUrl
  • model
  • transport
  • protocol
  • cwd
  • timeoutMs
  • signal
  • maxTurns
  • maxBudgetUsd
  • includePartialMessages
  • extraArgs
  • anthropicSystemMode

本地仓库调试

如果你正在源码仓里本地调试 SDK,建议显式传 binaryPath,让 SDK 直接使用本仓库根目录的 turing 二进制:

const client = createTuringClient({
  preset: 'sublb',
  apiKey: process.env.SUBLB_API_KEY,
  baseUrl: 'https://sub-lb.tap365.org/v1',
  binaryPath: '/Users/you/path/to/gpt-code/turing',
})

二进制解析顺序:

  1. binaryPath
  2. TURING_BINARY_PATH
  3. turing-code 包内 vendor 二进制
  4. 当前系统 PATH 里的 turing

安全说明

  • SDK 不会把 apiKey 拼进命令行参数
  • apiKey 只通过子进程环境变量传递
  • 建议把 Key 放在环境变量里,不要硬编码进源码

当前公开发布与文档布局

当前对外布局:

  • 私有源码仓:[email protected]:mason0510/turing.git
  • 公开发包仓:https://github.com/mason0510/sublb-client
  • Release 下载入口:https://github.com/mason0510/sublb-client/releases
  • 公网安装与分发页:
    • https://turing.tap365.org/
    • https://tap365.cn/turing/

推荐下一步:

  • 增加一个专门面向公众的 GitHub 版本与文档仓库,用于沉淀版本说明、更新日志、迁移指南、安装文档和 FAQ。
  • 仓库命名可以考虑:mason0510/turing-docsmason0510/turing-releases
  • 这样可以把“私有源码协作”“公开发包资产”“公开版本文档”三类职责彻底拆开,npm 页面也更容易给出稳定、清晰、长期可维护的链接。

Troubleshooting

找不到 turing 二进制

请依次检查:

  1. binaryPath
  2. TURING_BINARY_PATH
  3. turing-code 是否安装成功
  4. 系统 PATH 中是否存在 turing

Anthropic 网关不接受 system

可以设置:

export TURING_ANTHROPIC_SYSTEM_MODE=disabled

或直接传:

anthropicSystemMode: 'disabled'

我只是想在终端里聊天

那直接使用 turing CLI 会更简单。turing-sdk 更适合程序化接入。

FAQ

适合谁?

  • 想把 Turing 接到 Node.js 服务、脚本、队列和自动化流程里的人
  • 想保留 turing CLI 能力,但要用代码来驱动它的人
  • 想要 querystreamstreamText 这类程序接口的人

不适合谁?

  • 只想在终端里手动聊几句的人
  • 只做浏览器端直连的人

是否必须有网关?

是。你需要一个兼容的上游入口和有效的 API key。

安装时是否会下载二进制?

会。turing-sdk 依赖 turing-code,而 turing-code 安装时会继续下载当前平台对应的二进制。

文档与支持

  • 安装入口:https://turing.tap365.org/
  • 镜像入口:https://tap365.cn/turing/
  • Release 下载:https://github.com/mason0510/sublb-client/releases
  • 更新日志:CHANGELOG.md
  • 支持说明:SUPPORT.md
  • 英文 README:README.md
  • 计划中的公开文档仓:mason0510/turing-docs
  • 当前公开问题反馈入口:https://github.com/mason0510/sublb-client/issues

获取帮助

  • 安装页:https://turing.tap365.org/
  • 镜像页:https://tap365.cn/turing/
  • 版本下载:https://github.com/mason0510/sublb-client/releases
  • 更新日志:CHANGELOG.md
  • 支持说明:SUPPORT.md
  • 当前公开问题反馈入口:https://github.com/mason0510/sublb-client/issues

License

当前采用自定义许可,详见 LICENSE.md