@henjicc/ai-sdk 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +41 -35
  2. package/README.md +60 -60
  3. package/dist/catalog/audio/tts-common.d.ts +5 -0
  4. package/dist/catalog/audio/tts-common.js +17 -0
  5. package/dist/catalog/bailian/cosyvoice-v3.5.model.d.ts +2 -0
  6. package/dist/catalog/bailian/cosyvoice-v3.5.model.js +40 -0
  7. package/dist/catalog/bailian/minimax-speech-2.8.model.d.ts +2 -0
  8. package/dist/catalog/bailian/minimax-speech-2.8.model.js +38 -0
  9. package/dist/catalog/bailian/qwen-audio-3.1-tts-flash.model.d.ts +2 -0
  10. package/dist/catalog/bailian/qwen-audio-3.1-tts-flash.model.js +35 -0
  11. package/dist/catalog/fal/eleven-v3-tts.model.d.ts +2 -0
  12. package/dist/catalog/fal/eleven-v3-tts.model.js +31 -0
  13. package/dist/catalog/fal/minimax-speech-2.8.model.d.ts +2 -0
  14. package/dist/catalog/fal/minimax-speech-2.8.model.js +39 -0
  15. package/dist/catalog/fal/qwen3-tts-1.7b.model.d.ts +2 -0
  16. package/dist/catalog/fal/qwen3-tts-1.7b.model.js +33 -0
  17. package/dist/catalog/index.js +116 -90
  18. package/dist/catalog/kie/eleven-turbo-2.5-tts.model.d.ts +2 -0
  19. package/dist/catalog/kie/eleven-turbo-2.5-tts.model.js +29 -0
  20. package/dist/catalog/kie/eleven-v3-dialogue.model.d.ts +2 -0
  21. package/dist/catalog/kie/eleven-v3-dialogue.model.js +46 -0
  22. package/dist/catalog/kie/gemini-3.1-flash-tts.model.d.ts +2 -0
  23. package/dist/catalog/kie/gemini-3.1-flash-tts.model.js +40 -0
  24. package/dist/catalog/ppio/minimax-speech.model.js +1 -3
  25. package/dist/catalog/siliconflow/cosyvoice2-tts.model.d.ts +2 -0
  26. package/dist/catalog/siliconflow/cosyvoice2-tts.model.js +27 -0
  27. package/dist/catalog/siliconflow/moss-ttsd-0.5.model.d.ts +2 -0
  28. package/dist/catalog/siliconflow/moss-ttsd-0.5.model.js +28 -0
  29. package/dist/catalog/volcengine-speech/seed-icl-2.0.model.d.ts +2 -0
  30. package/dist/catalog/volcengine-speech/seed-icl-2.0.model.js +26 -0
  31. package/dist/catalog/volcengine-speech/seed-tts-2.0.model.d.ts +2 -0
  32. package/dist/catalog/volcengine-speech/seed-tts-2.0.model.js +25 -0
  33. package/dist/packs/models/bailian/cosyvoice-v3.5.d.ts +6 -0
  34. package/dist/packs/models/bailian/cosyvoice-v3.5.js +7 -0
  35. package/dist/packs/models/bailian/minimax-speech-2.8.d.ts +6 -0
  36. package/dist/packs/models/bailian/minimax-speech-2.8.js +7 -0
  37. package/dist/packs/models/bailian/qwen-audio-3.1-tts-flash.d.ts +6 -0
  38. package/dist/packs/models/bailian/qwen-audio-3.1-tts-flash.js +7 -0
  39. package/dist/packs/models/fal/eleven-v3-tts.d.ts +6 -0
  40. package/dist/packs/models/fal/eleven-v3-tts.js +7 -0
  41. package/dist/packs/models/fal/minimax-speech-2.8.d.ts +6 -0
  42. package/dist/packs/models/fal/minimax-speech-2.8.js +7 -0
  43. package/dist/packs/models/fal/qwen3-tts-1.7b.d.ts +6 -0
  44. package/dist/packs/models/fal/qwen3-tts-1.7b.js +7 -0
  45. package/dist/packs/models/kie/eleven-turbo-2.5-tts.d.ts +6 -0
  46. package/dist/packs/models/kie/eleven-turbo-2.5-tts.js +7 -0
  47. package/dist/packs/models/kie/eleven-v3-dialogue.d.ts +6 -0
  48. package/dist/packs/models/kie/eleven-v3-dialogue.js +7 -0
  49. package/dist/packs/models/kie/gemini-3.1-flash-tts.d.ts +6 -0
  50. package/dist/packs/models/kie/gemini-3.1-flash-tts.js +7 -0
  51. package/dist/packs/models/siliconflow/cosyvoice2-tts.d.ts +6 -0
  52. package/dist/packs/models/siliconflow/cosyvoice2-tts.js +7 -0
  53. package/dist/packs/models/siliconflow/moss-ttsd-0.5.d.ts +6 -0
  54. package/dist/packs/models/siliconflow/moss-ttsd-0.5.js +7 -0
  55. package/dist/packs/models/volcengine-speech/seed-icl-2.0.d.ts +6 -0
  56. package/dist/packs/models/volcengine-speech/seed-icl-2.0.js +7 -0
  57. package/dist/packs/models/volcengine-speech/seed-tts-2.0.d.ts +6 -0
  58. package/dist/packs/models/volcengine-speech/seed-tts-2.0.js +7 -0
  59. package/dist/packs/provider-adapters/siliconflow.d.ts +3 -0
  60. package/dist/packs/provider-adapters/siliconflow.js +5 -0
  61. package/dist/packs/provider-adapters/volcengine-speech.d.ts +3 -0
  62. package/dist/packs/provider-adapters/volcengine-speech.js +5 -0
  63. package/dist/packs/provider-packs/bailian.d.ts +1 -1
  64. package/dist/packs/provider-packs/bailian.js +6 -3
  65. package/dist/packs/provider-packs/fal.d.ts +1 -1
  66. package/dist/packs/provider-packs/fal.js +41 -38
  67. package/dist/packs/provider-packs/kie.d.ts +1 -1
  68. package/dist/packs/provider-packs/kie.js +33 -30
  69. package/dist/packs/provider-packs/siliconflow.d.ts +4 -0
  70. package/dist/packs/provider-packs/siliconflow.js +7 -0
  71. package/dist/packs/provider-packs/volcengine-speech.d.ts +4 -0
  72. package/dist/packs/provider-packs/volcengine-speech.js +7 -0
  73. package/dist/providers/audio-data.d.ts +2 -0
  74. package/dist/providers/audio-data.js +21 -0
  75. package/dist/providers/bailian.js +30 -2
  76. package/dist/providers/index.js +4 -0
  77. package/dist/providers/metadata.js +8 -0
  78. package/dist/providers/siliconflow.d.ts +3 -0
  79. package/dist/providers/siliconflow.js +34 -0
  80. package/dist/providers/volcengine-speech.d.ts +3 -0
  81. package/dist/providers/volcengine-speech.js +143 -0
  82. package/dist/types/model.d.ts +4 -4
  83. package/dist/types/model.js +3 -1
  84. package/docs/consumers.md +124 -119
  85. package/docs/llm-adaptation/README.md +29 -29
  86. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206/DeepSeek.md +14 -14
  87. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206/Kimi.md +3 -3
  88. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206//345/260/217/347/261/263MiMo.md +42 -42
  89. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206//346/231/272/350/260/261GLM.md +3 -3
  90. package/docs/model-adaptation/Fun-ASR-Realtime/Fun-ASR-Realtime_/347/231/276/347/202/274.md +22 -22
  91. package/docs/model-adaptation/GLM-5.3-Flash/GLM-5.3-Flash_/346/231/272/350/260/261.md +6 -6
  92. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_APIMart.md +66 -66
  93. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_Fal.md +55 -55
  94. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_Grsai.md +53 -53
  95. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_KIE.md +55 -55
  96. package/docs/model-adaptation/HappyHorse-1.1/HappyHorse-1.1_KIE.md +27 -27
  97. package/docs/model-adaptation/IC-Light-v2/IC-Light-v2_Fal.md +14 -14
  98. package/docs/model-adaptation/Qwen-MT-Flash/Qwen-MT-Flash_/347/231/276/347/202/274.md +24 -24
  99. package/docs/model-adaptation/Qwen-MT-Lite/Qwen-MT-Lite_/347/231/276/347/202/274.md +3 -3
  100. package/docs/model-adaptation/Qwen-MT-Plus/Qwen-MT-Plus_/347/231/276/347/202/274.md +3 -3
  101. package/docs/model-adaptation/Qwen3-ASR-Flash-Realtime/Qwen3-ASR-Flash-Realtime_/347/231/276/347/202/274.md +25 -25
  102. package/docs/model-adaptation/README.md +14 -10
  103. package/docs/model-adaptation/SeedASR-2.0-Realtime/SeedASR-2.0-Realtime_/347/201/253/345/261/261/345/274/225/346/223/216.md +7 -7
  104. package/docs/model-adaptation/Seedream-5.0-Flash/Seedream-5.0-Flash_/347/201/253/345/261/261/345/274/225/346/223/216.md +18 -18
  105. package/docs/model-adaptation/TTS-/345/244/232/344/276/233/345/272/224/345/225/206-2026-09.md +55 -0
  106. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//346/264/276/346/254/247/344/272/221.md +9 -9
  107. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//347/201/253/345/261/261/345/274/225/346/223/216.md +11 -11
  108. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//347/231/276/347/202/274.md +31 -31
  109. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//347/241/205/345/237/272/346/265/201/345/212/250.md +67 -67
  110. package/docs/model-adaptation//346/226/207/346/241/243/351/207/207/351/233/206/346/211/213/345/206/214.md +8 -8
  111. package/examples/form-renderer/package.json +1 -1
  112. package/examples/llm-chat/README.md +8 -8
  113. package/examples/llm-chat/index.ts +1 -1
  114. package/examples/llm-chat/package.json +1 -1
  115. package/examples/minimal-node/package.json +1 -1
  116. package/package.json +258 -258
package/CHANGELOG.md CHANGED
@@ -1,41 +1,47 @@
1
1
  # Changelog
2
2
 
3
- ## 0.6.2 - 2026-09-24
3
+ ## 0.7.0 - 2026-09-27
4
4
 
5
- - 完善聊天与翻译 SSE 的事件边界和完成状态校验:保留合法空中间帧、用量与状态通知,提前结束、服务端错误和无效终态不再伪装成功;保留翻译增量/累积协议差异。
6
- - 修复百炼实时 ASR 字段校验、Qwen 中间文字拼接和状态通知处理;保留 0.6.1 空中间帧兼容,诊断包含实际模型、协议及失败阶段。
7
- - 收口共享实时会话的取消、超时、后台故障通知和资源释放;SDK 会话提供可选 result promise,旧自定义会话仍兼容。握手清理失败保留首个故障,火山服务错误默认脱敏。
8
- - 阻止聊天及火山实时识别在取消后继续派发同一帧的后续结果;明确智谱推理网络错误与上下文截断,扩展通知不冒充完成证据。
9
- - 增加脱敏事件序列回归并执行修复撤销验证,更新聊天示例的合法结束帧。未改变供应商配额、网络稳定性或模型识别质量。
10
-
11
- ## 0.6.1 - 2026-09-24
12
-
13
- - 修复百炼 Fun Duplex 实时识别把无句首标记的空文本中间帧误判为无效响应的问题;覆盖 Qwen Audio 3.1 streaming 与 Fun-ASR 共享协议。
14
- - 保持缺失文字字段、空最终结果、全程无有效 final 的严格校验及连接释放。
15
-
16
- ## 0.6.0 - 2026-09-24
17
-
18
- - 新增 MiMo 2.6 Pro / Flash / Pro-UltraSpeed 能力;默认推荐 Pro / Flash,保留 2.5 ID(官方计划 10 月 21 日下线),不自动替换用户选择。
19
- - MiMo Chat / Responses 思考字段分离,兼容完整 reasoning_text 事件及历史思考回传,流中断不再伪装完成。
20
- - 新增大陆 GLM-5.3-FlashX 与官方价格;Flash / FlashX 开放 JSON 输出并保留思考。
21
- - 新增 KIE HappyHorse 1.1 文生、图生、多图参考模式,以及火山 Seedream 5.0 Flash 生成/编辑和图层拆分;价格按最新官方单价。
22
- - 百炼新增 Qwen-Audio 3.1 短音频、文件与实时 ASR,支持方言/即时热词与说话人输出;修复短音频 JSON 回退、上下文字段及文件声道数组。
23
- - Kimi K3 资料补齐缓存写入 TTL 价格。新增公开入口保持向后兼容,既有外部 ASR 消费方从 0.2.x 升级仍须满足 0.5.0 的宿主流式上传要求。
24
-
25
-
26
- ## 0.5.2 - 2026-09-21
27
-
28
- - `llm/streaming` 新增有类型定义的文本、JSON Object 与 JSON Schema 输出配置,并把它正式写入 Chat Completions 的 `response_format`。
29
- - 模型能力现在可声明结构化输出与思考模式能否并用;不支持或尚未核实的组合在网络请求前返回可解析错误码,Groq 流式 JSON Schema 按官方限制明确拒绝。
30
- - 新增 `maxOutputTokens`,OpenAI/Groq/MiMo 使用 `max_completion_tokens`,其余兼容端点沿用 `max_tokens`;省略时不再强制 4096,流结束用 `truncated` 标记 token 上限截断。
31
- - 最终发送体复用正式构建结果,`onRequestBuilt` 只收到观察快照;保留正文/思考分流、AbortSignal、可选总时限与轻量受限宿主边界。
32
-
33
- ## 0.5.1 - 2026-09-21
34
-
35
- - Grsai GPT Image 2.5 默认变体从维护中的 Flare 切换为可用的 Standard;显式 Flare/Sunburst 参数保持兼容,等待官方恢复公告。
36
- - 默认请求体与默认价格估算同步使用 Standard,避免界面未选择变体时仍把任务提交到维护通道。
37
-
38
- ## 0.5.0 - 2026-09-21
5
+ - 新增 Fal、百炼、KIE、硅基流动和火山语音的 13 个 TTS 模型入口;保留派欧云 MiniMax Speech 2.8,并按平台契约隐藏未证实的情感参数。
6
+ - 接入百炼 MiniMax Hex 音频、百炼 Qwen/CosyVoice 同步音频、硅基流动二进制音频及火山 V3 分块音频;输出统一交给现有媒体落盘边界。
7
+ - 有公开字符单价的模型提供估算;按音频输出 Token 计费或缺少可核实按量单价的模型不显示数字估算。
8
+
9
+ ## 0.6.2 - 2026-09-24
10
+
11
+ - 完善聊天与翻译 SSE 的事件边界和完成状态校验:保留合法空中间帧、用量与状态通知,提前结束、服务端错误和无效终态不再伪装成功;保留翻译增量/累积协议差异。
12
+ - 修复百炼实时 ASR 字段校验、Qwen 中间文字拼接和状态通知处理;保留 0.6.1 空中间帧兼容,诊断包含实际模型、协议及失败阶段。
13
+ - 收口共享实时会话的取消、超时、后台故障通知和资源释放;SDK 会话提供可选 result promise,旧自定义会话仍兼容。握手清理失败保留首个故障,火山服务错误默认脱敏。
14
+ - 阻止聊天及火山实时识别在取消后继续派发同一帧的后续结果;明确智谱推理网络错误与上下文截断,扩展通知不冒充完成证据。
15
+ - 增加脱敏事件序列回归并执行修复撤销验证,更新聊天示例的合法结束帧。未改变供应商配额、网络稳定性或模型识别质量。
16
+
17
+ ## 0.6.1 - 2026-09-24
18
+
19
+ - 修复百炼 Fun Duplex 实时识别把无句首标记的空文本中间帧误判为无效响应的问题;覆盖 Qwen Audio 3.1 streaming 与 Fun-ASR 共享协议。
20
+ - 保持缺失文字字段、空最终结果、全程无有效 final 的严格校验及连接释放。
21
+
22
+ ## 0.6.0 - 2026-09-24
23
+
24
+ - 新增 MiMo 2.6 Pro / Flash / Pro-UltraSpeed 能力;默认推荐 Pro / Flash,保留 2.5 ID(官方计划 10 月 21 日下线),不自动替换用户选择。
25
+ - MiMo Chat / Responses 思考字段分离,兼容完整 reasoning_text 事件及历史思考回传,流中断不再伪装完成。
26
+ - 新增大陆 GLM-5.3-FlashX 与官方价格;Flash / FlashX 开放 JSON 输出并保留思考。
27
+ - 新增 KIE HappyHorse 1.1 文生、图生、多图参考模式,以及火山 Seedream 5.0 Flash 生成/编辑和图层拆分;价格按最新官方单价。
28
+ - 百炼新增 Qwen-Audio 3.1 短音频、文件与实时 ASR,支持方言/即时热词与说话人输出;修复短音频 JSON 回退、上下文字段及文件声道数组。
29
+ - Kimi K3 资料补齐缓存写入 TTL 价格。新增公开入口保持向后兼容,既有外部 ASR 消费方从 0.2.x 升级仍须满足 0.5.0 的宿主流式上传要求。
30
+
31
+
32
+ ## 0.5.2 - 2026-09-21
33
+
34
+ - `llm/streaming` 新增有类型定义的文本、JSON Object 与 JSON Schema 输出配置,并把它正式写入 Chat Completions 的 `response_format`。
35
+ - 模型能力现在可声明结构化输出与思考模式能否并用;不支持或尚未核实的组合在网络请求前返回可解析错误码,Groq 流式 JSON Schema 按官方限制明确拒绝。
36
+ - 新增 `maxOutputTokens`,OpenAI/Groq/MiMo 使用 `max_completion_tokens`,其余兼容端点沿用 `max_tokens`;省略时不再强制 4096,流结束用 `truncated` 标记 token 上限截断。
37
+ - 最终发送体复用正式构建结果,`onRequestBuilt` 只收到观察快照;保留正文/思考分流、AbortSignal、可选总时限与轻量受限宿主边界。
38
+
39
+ ## 0.5.1 - 2026-09-21
40
+
41
+ - Grsai GPT Image 2.5 默认变体从维护中的 Flare 切换为可用的 Standard;显式 Flare/Sunburst 参数保持兼容,等待官方恢复公告。
42
+ - 默认请求体与默认价格估算同步使用 Standard,避免界面未选择变体时仍把任务提交到维护通道。
43
+
44
+ ## 0.5.0 - 2026-09-21
39
45
 
40
46
  - 文件 ASR 支持分块 JSON/Base64 与 multipart,请求体不重组整文件;支持结构化大小错误、PCM 时长估算及取消清理。
41
47
  - **迁移要求**:百炼异步本地文件需宿主 transport.uploadFile 原生直传 OSS,不再走媒体读取通道。其他流式路径需 describe/readChunk + fetchStream;旧 read 路径保留但不得放宽内存保护。
package/README.md CHANGED
@@ -48,10 +48,10 @@ try {
48
48
 
49
49
  百炼工厂必须传 `baseUrl` 为实际地域/工作空间的 API 根地址,不包含端点路径。其他供应商可以覆盖根地址与 `credentialId`;SDK 不自动切换地域或账号。不同模型的向量不能混用;切换模型通常需要重建向量索引。Rerank 分数仅在本次请求内比较。
50
50
 
51
- SDK `0.6.2` 的正式分发渠道为公共 npm,无需配置 registry 或访问令牌:
51
+ SDK `0.7.0` 的正式分发渠道为公共 npm,无需配置 registry 或访问令牌:
52
52
 
53
53
  ```bash
54
- npm install @henjicc/ai-sdk@0.6.2
54
+ npm install @henjicc/ai-sdk@0.7.0
55
55
  ```
56
56
 
57
57
  然后提供 4 个宿主能力(`Transport` / `CredentialStore` / `MediaReader` / `Logger`),创建客户端:
@@ -192,50 +192,50 @@ import {
192
192
  type RuntimeContext,
193
193
  } from '@henjicc/ai-sdk/llm/streaming'
194
194
 
195
- const request: LlmChatRequestDto = {
196
- requestId: 'chat-1', providerId: 'openai', modelId: 'gpt-5-mini',
197
- messages: [{ role: 'user', content: '你好' }],
198
- capabilities: {
199
- structuredOutputMode: 'schema',
200
- reasoning: true,
201
- structuredOutputWithReasoning: true,
202
- maxOutputTokens: 32_000,
203
- },
204
- reasoning: { enabled: true, effort: 'high' },
205
- structuredOutput: {
206
- type: 'json_schema',
207
- name: 'subtitle_segments',
208
- strict: true,
209
- schema: {
210
- type: 'object',
211
- properties: {
212
- segments: {
213
- type: 'array',
214
- items: {
215
- type: 'object',
216
- properties: { text: { type: 'string' } },
217
- required: ['text'],
218
- additionalProperties: false,
219
- },
220
- },
221
- },
222
- required: ['segments'],
223
- additionalProperties: false,
224
- },
225
- },
226
- maxOutputTokens: 24_000,
227
- }
228
- const result = await runLlmChatStream(request, 'chat-1', onStreamEvent, runtime as RuntimeContext)
229
- console.log(result.output, result.reasoningOutput, result.usage, result.finishReason, result.truncated)
230
- cancelLlmChatTask('chat-1')
231
- ```
232
-
233
- `structuredOutput` 支持 `text`、`json_object`、`json_schema`。轻量入口只执行 Chat Completions,
234
- 所以这里会正式映射到最终请求体的 `response_format`;它不包含 Responses API 执行器,Responses
235
- 路径的等价字段 `text.format` 由完整 `llm` 入口处理。JSON Object、JSON Schema 和“结构化输出 +
236
- 思考”都必须由 `capabilities` 明确声明;未知或不支持的组合会在网络请求前返回结构化错误,不会静默
237
- 降级。省略 `maxOutputTokens` 时 SDK 不再强加 4096 tokens,而是交给供应商默认值;省略执行参数里的
238
- `timeoutMs` 则没有请求总时限,宿主可在 `Transport` 中实现长时间无数据才超时。
195
+ const request: LlmChatRequestDto = {
196
+ requestId: 'chat-1', providerId: 'openai', modelId: 'gpt-5-mini',
197
+ messages: [{ role: 'user', content: '你好' }],
198
+ capabilities: {
199
+ structuredOutputMode: 'schema',
200
+ reasoning: true,
201
+ structuredOutputWithReasoning: true,
202
+ maxOutputTokens: 32_000,
203
+ },
204
+ reasoning: { enabled: true, effort: 'high' },
205
+ structuredOutput: {
206
+ type: 'json_schema',
207
+ name: 'subtitle_segments',
208
+ strict: true,
209
+ schema: {
210
+ type: 'object',
211
+ properties: {
212
+ segments: {
213
+ type: 'array',
214
+ items: {
215
+ type: 'object',
216
+ properties: { text: { type: 'string' } },
217
+ required: ['text'],
218
+ additionalProperties: false,
219
+ },
220
+ },
221
+ },
222
+ required: ['segments'],
223
+ additionalProperties: false,
224
+ },
225
+ },
226
+ maxOutputTokens: 24_000,
227
+ }
228
+ const result = await runLlmChatStream(request, 'chat-1', onStreamEvent, runtime as RuntimeContext)
229
+ console.log(result.output, result.reasoningOutput, result.usage, result.finishReason, result.truncated)
230
+ cancelLlmChatTask('chat-1')
231
+ ```
232
+
233
+ `structuredOutput` 支持 `text`、`json_object`、`json_schema`。轻量入口只执行 Chat Completions,
234
+ 所以这里会正式映射到最终请求体的 `response_format`;它不包含 Responses API 执行器,Responses
235
+ 路径的等价字段 `text.format` 由完整 `llm` 入口处理。JSON Object、JSON Schema 和“结构化输出 +
236
+ 思考”都必须由 `capabilities` 明确声明;未知或不支持的组合会在网络请求前返回结构化错误,不会静默
237
+ 降级。省略 `maxOutputTokens` 时 SDK 不再强加 4096 tokens,而是交给供应商默认值;省略执行参数里的
238
+ `timeoutMs` 则没有请求总时限,宿主可在 `Transport` 中实现长时间无数据才超时。
239
239
 
240
240
  ### 可选模型分发包与统一能力筛选
241
241
 
@@ -493,20 +493,20 @@ await capabilities.dispose()
493
493
  - `llm/bigmodel`:智谱同一 provider family 下的中国大陆/Global 端点 profile、独立凭据槽与 GLM-5.3-Flash 能力。
494
494
  - `llm/modules`:外部包、插件与内置 LLM 共用的注册、执行、发现、取消和 namespace 卸载边界。
495
495
 
496
- 实时会话仍使用 `openSession → send → finish/close`。由 client 创建的会话额外提供 `result` Promise:
497
- 它不主动发送 finish;在最终结果到达或后台失败、取消、超时、主动关闭,并完成资源收尾后结算。
498
- 调用方可以观察 `session.result` 以获知停止发送音频期间的后台失败,不必等到下一次 `send/finish`。
499
- `finish()` 幂等且返回同一结果;正常关闭但没有最终结果时 `result` 拒绝 `realtime_session_closed`,
500
- 取消是 `cancelled`,超时是 `timeout`,供应商失败保留原错误。未订阅该 Promise 不产生未处理拒绝,
501
- SDK 仍按现有日志契约记录失败。
502
-
503
- 外部实时驱动可以提供可选 `result` Promise,致命后台/发送错误必须拒绝它,成功则返回有效最终结果。
504
- 输入校验等可恢复的单次 send 错误只拒绝该调用,不应结束 result。旧驱动无需新增字段即可继续使用;
505
- 如果旧驱动没有提供结果通道,SDK 无法自行发现它的后台失败。公共类型中的可选属性用于兼容旧会话实现。
506
- 完成、失败、取消与关闭竞争时只结算一次;清理失败不能覆盖首个失败,但成功路径清理失败不能报成功。
507
- 连接、监听器与定时器回收后,原 requestId 可用于新会话;不会自动重连或重放已可能计费的音频。
508
-
509
- ASR module ID 固定为 `<providerId>.speech-recognition.<modelId>`,翻译固定为
496
+ 实时会话仍使用 `openSession → send → finish/close`。由 client 创建的会话额外提供 `result` Promise:
497
+ 它不主动发送 finish;在最终结果到达或后台失败、取消、超时、主动关闭,并完成资源收尾后结算。
498
+ 调用方可以观察 `session.result` 以获知停止发送音频期间的后台失败,不必等到下一次 `send/finish`。
499
+ `finish()` 幂等且返回同一结果;正常关闭但没有最终结果时 `result` 拒绝 `realtime_session_closed`,
500
+ 取消是 `cancelled`,超时是 `timeout`,供应商失败保留原错误。未订阅该 Promise 不产生未处理拒绝,
501
+ SDK 仍按现有日志契约记录失败。
502
+
503
+ 外部实时驱动可以提供可选 `result` Promise,致命后台/发送错误必须拒绝它,成功则返回有效最终结果。
504
+ 输入校验等可恢复的单次 send 错误只拒绝该调用,不应结束 result。旧驱动无需新增字段即可继续使用;
505
+ 如果旧驱动没有提供结果通道,SDK 无法自行发现它的后台失败。公共类型中的可选属性用于兼容旧会话实现。
506
+ 完成、失败、取消与关闭竞争时只结算一次;清理失败不能覆盖首个失败,但成功路径清理失败不能报成功。
507
+ 连接、监听器与定时器回收后,原 requestId 可用于新会话;不会自动重连或重放已可能计费的音频。
508
+
509
+ ASR module ID 固定为 `<providerId>.speech-recognition.<modelId>`,翻译固定为
510
510
  `bailian.translation.<modelId>`;供应商 ID 使用 `bailian` / `volcengine` / `siliconflow` / `groq`,
511
511
  没有 `funasr` 兼容供应商别名。火山文件标准版不会读取本地 bytes/media-ref;宿主必须先通过自己受控的
512
512
  对象存储发布成供应商可访问 URL。SDK 不提供公共 URL 文本框或冒充上传成功的回退路径。
@@ -0,0 +1,5 @@
1
+ import type { JsonObject, JsonValue } from '../../types/runtime.js';
2
+ export declare function speechText(params: JsonObject): string;
3
+ export declare function speechString(value: JsonValue): string | undefined;
4
+ export declare function speechNumber(value: JsonValue): number | undefined;
5
+ export declare function speechCharacterPrice(params: JsonObject, perThousand: number): number;
@@ -0,0 +1,17 @@
1
+ export function speechText(params) {
2
+ const value = typeof params.text === 'string' ? params.text : params.prompt;
3
+ if (typeof value !== 'string' || value.trim().length === 0) {
4
+ throw new Error('语音合成需要非空文本');
5
+ }
6
+ return value;
7
+ }
8
+ export function speechString(value) {
9
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
10
+ }
11
+ export function speechNumber(value) {
12
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
13
+ }
14
+ export function speechCharacterPrice(params, perThousand) {
15
+ const value = typeof params.text === 'string' ? params.text : params.prompt;
16
+ return typeof value === 'string' ? (Array.from(value).length * perThousand) / 1000 : 0;
17
+ }
@@ -0,0 +1,2 @@
1
+ export declare const bailianCosyVoice35Model: import("../../index.js").ModelRuntimeDefinition;
2
+ export default bailianCosyVoice35Model;
@@ -0,0 +1,40 @@
1
+ import { defineModel } from '../defineModel.js';
2
+ import { speechCharacterPrice, speechNumber, speechString, speechText } from '../audio/tts-common.js';
3
+ export const bailianCosyVoice35Model = defineModel({
4
+ meta: {
5
+ id: 'bailian-cosyvoice-v3.5', canonicalModelId: 'cosyvoice-v3.5', provider: 'bailian', type: 'audio',
6
+ tags: ['text-to-audio', 'provider-bailian'],
7
+ },
8
+ inputLimits: { images: { max: 0 }, videos: { max: 0 } },
9
+ params: [
10
+ { id: 'bailianCosyVoiceSpec', type: 'dropdown', order: 1, default: 'flash', options: [{ value: 'flash' }, { value: 'plus' }] },
11
+ { id: 'bailianCosyVoiceId', type: 'text', order: 2, required: true, default: '' },
12
+ { id: 'bailianCosyVoiceInstruction', type: 'text', order: 3, default: '' },
13
+ { id: 'bailianCosyVoiceSpeed', type: 'number', order: 4, default: 1, min: 0.5, max: 2, step: 0.1 },
14
+ ],
15
+ endpoints: '/api/v1/services/audio/tts/SpeechSynthesizer',
16
+ request: {
17
+ builder: (params) => {
18
+ const voice = speechString(params.bailianCosyVoiceId);
19
+ if (!voice)
20
+ throw new Error('CosyVoice 3.5 需要事先创建的声音复刻或设计音色 ID');
21
+ const input = {
22
+ text: speechText(params), voice, format: 'mp3',
23
+ rate: speechNumber(params.bailianCosyVoiceSpeed) ?? 1,
24
+ };
25
+ const instruction = speechString(params.bailianCosyVoiceInstruction);
26
+ if (instruction)
27
+ input.instruction = instruction;
28
+ return {
29
+ model: params.bailianCosyVoiceSpec === 'plus' ? 'cosyvoice-v3.5-plus' : 'cosyvoice-v3.5-flash',
30
+ input,
31
+ };
32
+ },
33
+ },
34
+ pricing: {
35
+ currency: '¥',
36
+ calculator: params => speechCharacterPrice(params, params.bailianCosyVoiceSpec === 'plus' ? 0.15 : 0.08),
37
+ description: 'CosyVoice 3.5 Flash ¥0.8/万字符,Plus ¥1.5/万字符;须先取得自定义音色 ID',
38
+ },
39
+ });
40
+ export default bailianCosyVoice35Model;
@@ -0,0 +1,2 @@
1
+ export declare const bailianMinimaxSpeech28Model: import("../../index.js").ModelRuntimeDefinition;
2
+ export default bailianMinimaxSpeech28Model;
@@ -0,0 +1,38 @@
1
+ import { defineModel } from '../defineModel.js';
2
+ import { speechCharacterPrice, speechNumber, speechString, speechText } from '../audio/tts-common.js';
3
+ export const bailianMinimaxSpeech28Model = defineModel({
4
+ meta: {
5
+ id: 'bailian-minimax-speech-2.8', canonicalModelId: 'minimax-speech-2.8', provider: 'bailian', type: 'audio',
6
+ tags: ['text-to-audio', 'provider-bailian'],
7
+ },
8
+ inputLimits: { images: { max: 0 }, videos: { max: 0 } },
9
+ params: [
10
+ { id: 'bailianMinimaxSpeechSpec', type: 'dropdown', order: 1, default: 'hd', options: [{ value: 'hd' }, { value: 'turbo' }] },
11
+ { id: 'bailianMinimaxSpeechVoice', type: 'text', order: 2, default: 'male-qn-qingse' },
12
+ { id: 'bailianMinimaxSpeechSpeed', type: 'number', order: 3, default: 1, min: 0.5, max: 2, step: 0.1 },
13
+ { id: 'bailianMinimaxSpeechEmotion', type: 'dropdown', order: 4, default: '', options: ['', 'happy', 'sad', 'angry', 'fearful', 'disgusted', 'surprised', 'calm'].map(value => ({ value })) },
14
+ ],
15
+ endpoints: '/api/v1/services/aigc/multimodal-generation/generation',
16
+ request: {
17
+ builder: (params) => {
18
+ const spec = params.bailianMinimaxSpeechSpec === 'turbo' ? 'turbo' : 'hd';
19
+ const voiceSetting = {
20
+ voice_id: speechString(params.bailianMinimaxSpeechVoice) ?? 'male-qn-qingse',
21
+ speed: speechNumber(params.bailianMinimaxSpeechSpeed) ?? 1,
22
+ };
23
+ const emotion = speechString(params.bailianMinimaxSpeechEmotion);
24
+ if (emotion)
25
+ voiceSetting.emotion = emotion;
26
+ return {
27
+ model: `MiniMax/speech-2.8-${spec}`,
28
+ input: { text: speechText(params), voice_setting: voiceSetting },
29
+ };
30
+ },
31
+ },
32
+ pricing: {
33
+ currency: '¥',
34
+ calculator: params => speechCharacterPrice(params, params.bailianMinimaxSpeechSpec === 'turbo' ? 0.2 : 0.35),
35
+ description: '百炼 MiniMax 2.8 HD ¥3.5/万字符,Turbo ¥2/万字符',
36
+ },
37
+ });
38
+ export default bailianMinimaxSpeech28Model;
@@ -0,0 +1,2 @@
1
+ export declare const bailianQwenAudio31TtsFlashModel: import("../../index.js").ModelRuntimeDefinition;
2
+ export default bailianQwenAudio31TtsFlashModel;
@@ -0,0 +1,35 @@
1
+ import { defineModel } from '../defineModel.js';
2
+ import { speechNumber, speechString, speechText } from '../audio/tts-common.js';
3
+ export const bailianQwenAudio31TtsFlashModel = defineModel({
4
+ meta: {
5
+ id: 'bailian-qwen-audio-3.1-tts-flash', canonicalModelId: 'qwen-audio-3.1-tts-flash',
6
+ provider: 'bailian', type: 'audio',
7
+ tags: ['text-to-audio', 'provider-bailian'],
8
+ },
9
+ inputLimits: { images: { max: 0 }, videos: { max: 0 } },
10
+ params: [
11
+ { id: 'bailianQwenTtsVoice', type: 'dropdown', order: 1, default: 'longanhuan_v3.1', options: ['longanhuan_v3.1', 'longanlingxin_v3.1', 'longanfengyue_v3.1', 'xunanchuan_v3.1'].map(value => ({ value })) },
12
+ { id: 'bailianQwenTtsInstruction', type: 'text', order: 2, default: '' },
13
+ { id: 'bailianQwenTtsSpeed', type: 'number', order: 3, default: 1, min: 0.5, max: 2, step: 0.1 },
14
+ ],
15
+ endpoints: '/api/v1/services/audio/tts/SpeechSynthesizer',
16
+ request: {
17
+ builder: (params) => {
18
+ const input = {
19
+ text: speechText(params),
20
+ voice: speechString(params.bailianQwenTtsVoice) ?? 'longanhuan_v3.1',
21
+ format: 'mp3',
22
+ rate: speechNumber(params.bailianQwenTtsSpeed) ?? 1,
23
+ };
24
+ const instruction = speechString(params.bailianQwenTtsInstruction);
25
+ if (instruction)
26
+ input.instruction = instruction;
27
+ return { model: 'qwen-audio-3.1-tts-flash', input };
28
+ },
29
+ },
30
+ pricing: {
31
+ currency: '¥', calculator: () => Number.NaN,
32
+ description: '输入 ¥1.5/百万 Token、输出 ¥12/百万 Token;输出 Token 无法在提交前准确估算',
33
+ },
34
+ });
35
+ export default bailianQwenAudio31TtsFlashModel;
@@ -0,0 +1,2 @@
1
+ export declare const falElevenV3TtsModel: import("../../index.js").ModelRuntimeDefinition;
2
+ export default falElevenV3TtsModel;
@@ -0,0 +1,31 @@
1
+ import { defineModel } from '../defineModel.js';
2
+ import { speechCharacterPrice, speechNumber, speechString, speechText } from '../audio/tts-common.js';
3
+ export const falElevenV3TtsModel = defineModel({
4
+ meta: {
5
+ id: 'fal-eleven-v3-tts', canonicalModelId: 'eleven-v3-tts', provider: 'fal', type: 'audio',
6
+ tags: ['text-to-audio', 'provider-fal'],
7
+ polling: { interval: 3000, maxAttempts: 120, expectedAttempts: 20 },
8
+ },
9
+ inputLimits: { images: { max: 0 }, videos: { max: 0 } },
10
+ params: [
11
+ { id: 'falElevenV3Voice', type: 'text', order: 1, default: 'Rachel' },
12
+ { id: 'falElevenV3Stability', type: 'number', order: 2, default: 0.5, min: 0, max: 1, step: 0.05 },
13
+ { id: 'falElevenV3Language', type: 'text', order: 3, default: '' },
14
+ ],
15
+ endpoints: 'fal-ai/elevenlabs/tts/eleven-v3',
16
+ request: {
17
+ builder: (params) => {
18
+ const body = {
19
+ text: speechText(params),
20
+ voice: speechString(params.falElevenV3Voice) ?? 'Rachel',
21
+ stability: speechNumber(params.falElevenV3Stability) ?? 0.5,
22
+ };
23
+ const language = speechString(params.falElevenV3Language);
24
+ if (language)
25
+ body.language_code = language;
26
+ return body;
27
+ },
28
+ },
29
+ pricing: { currency: '$', calculator: params => speechCharacterPrice(params, 0.1), description: '$0.10/千字符' },
30
+ });
31
+ export default falElevenV3TtsModel;
@@ -0,0 +1,2 @@
1
+ export declare const falMinimaxSpeech28Model: import("../../index.js").ModelRuntimeDefinition;
2
+ export default falMinimaxSpeech28Model;
@@ -0,0 +1,39 @@
1
+ import { defineModel } from '../defineModel.js';
2
+ import { speechCharacterPrice, speechNumber, speechString, speechText } from '../audio/tts-common.js';
3
+ export const falMinimaxSpeech28Model = defineModel({
4
+ meta: {
5
+ id: 'fal-minimax-speech-2.8', canonicalModelId: 'minimax-speech-2.8',
6
+ provider: 'fal', type: 'audio',
7
+ tags: ['text-to-audio', 'provider-fal'],
8
+ polling: { interval: 3000, maxAttempts: 120, expectedAttempts: 20 },
9
+ },
10
+ inputLimits: { images: { max: 0 }, videos: { max: 0 } },
11
+ params: [
12
+ { id: 'falMinimaxSpeechSpec', type: 'dropdown', order: 1, default: 'hd', options: [{ value: 'hd' }, { value: 'turbo' }] },
13
+ { id: 'falMinimaxSpeechVoice', type: 'text', order: 2, default: 'Wise_Woman' },
14
+ { id: 'falMinimaxSpeechSpeed', type: 'number', order: 3, default: 1, min: 0.5, max: 2, step: 0.1 },
15
+ { id: 'falMinimaxSpeechEmotion', type: 'dropdown', order: 4, default: '', options: ['', 'happy', 'sad', 'angry', 'fearful', 'disgusted', 'surprised', 'neutral'].map(value => ({ value })) },
16
+ ],
17
+ endpoints: {
18
+ selector: (params) => params.falMinimaxSpeechSpec === 'turbo'
19
+ ? 'fal-ai/minimax/speech-2.8-turbo' : 'fal-ai/minimax/speech-2.8-hd',
20
+ },
21
+ request: {
22
+ builder: (params) => {
23
+ const voice = {
24
+ voice_id: speechString(params.falMinimaxSpeechVoice) ?? 'Wise_Woman',
25
+ speed: speechNumber(params.falMinimaxSpeechSpeed) ?? 1,
26
+ };
27
+ const emotion = speechString(params.falMinimaxSpeechEmotion);
28
+ if (emotion)
29
+ voice.emotion = emotion;
30
+ return { prompt: speechText(params), voice_setting: voice, output_format: 'url' };
31
+ },
32
+ },
33
+ pricing: {
34
+ currency: '$',
35
+ calculator: params => speechCharacterPrice(params, params.falMinimaxSpeechSpec === 'turbo' ? 0.06 : 0.1),
36
+ description: 'Fal Speech 2.8 HD $0.10/千字符,Turbo $0.06/千字符',
37
+ },
38
+ });
39
+ export default falMinimaxSpeech28Model;
@@ -0,0 +1,2 @@
1
+ export declare const falQwen3Tts17bModel: import("../../index.js").ModelRuntimeDefinition;
2
+ export default falQwen3Tts17bModel;
@@ -0,0 +1,33 @@
1
+ import { defineModel } from '../defineModel.js';
2
+ import { speechCharacterPrice, speechNumber, speechString, speechText } from '../audio/tts-common.js';
3
+ export const falQwen3Tts17bModel = defineModel({
4
+ meta: {
5
+ id: 'fal-qwen3-tts-1.7b', canonicalModelId: 'qwen3-tts-1.7b', provider: 'fal', type: 'audio',
6
+ tags: ['text-to-audio', 'provider-fal'],
7
+ polling: { interval: 3000, maxAttempts: 120, expectedAttempts: 20 },
8
+ },
9
+ inputLimits: { images: { max: 0 }, videos: { max: 0 } },
10
+ params: [
11
+ { id: 'falQwen3TtsVoice', type: 'dropdown', order: 1, default: 'Vivian', options: ['Vivian', 'Serena', 'Uncle_Fu', 'Dylan', 'Eric', 'Ryan', 'Aiden', 'Ono_Anna', 'Sohee'].map(value => ({ value })) },
12
+ { id: 'falQwen3TtsLanguage', type: 'dropdown', order: 2, default: 'Auto', options: ['Auto', 'English', 'Chinese', 'Spanish', 'French', 'German', 'Italian', 'Japanese', 'Korean', 'Portuguese', 'Russian'].map(value => ({ value })) },
13
+ { id: 'falQwen3TtsStyle', type: 'text', order: 3, default: '' },
14
+ { id: 'falQwen3TtsTemperature', type: 'number', order: 4, default: 0.9, min: 0, max: 2, step: 0.1 },
15
+ ],
16
+ endpoints: 'fal-ai/qwen-3-tts/text-to-speech/1.7b',
17
+ request: {
18
+ builder: (params) => {
19
+ const body = {
20
+ text: speechText(params),
21
+ voice: speechString(params.falQwen3TtsVoice) ?? 'Vivian',
22
+ language: speechString(params.falQwen3TtsLanguage) ?? 'Auto',
23
+ temperature: speechNumber(params.falQwen3TtsTemperature) ?? 0.9,
24
+ };
25
+ const style = speechString(params.falQwen3TtsStyle);
26
+ if (style)
27
+ body.prompt = style;
28
+ return body;
29
+ },
30
+ },
31
+ pricing: { currency: '$', calculator: params => speechCharacterPrice(params, 0.09), description: '$0.09/千字符' },
32
+ });
33
+ export default falQwen3Tts17bModel;