> For AI agents: the complete documentation index is available at https://docs.reelway.ai/llms.txt, the full documentation bundle is available at https://docs.reelway.ai/llms-full.txt.

***

title: JavaScript / TypeScript 客户端
description: @reelway/client 的完整使用指南:初始化、生成、上传、事件与恢复。
-----------------------------------------------------

# JavaScript / TypeScript 客户端

## 事件驱动与 Promise 两种风格

```js
// 事件驱动
const project = client.projects.create({ modelId: 'z_image_turbo_bf16', positivePrompt: '…' });
project.on('progress', (p) => console.log(p.progress));
project.on('completed', (urls) => console.log(urls));

// Promise 风格
const urls = await project.waitForCompletion();   // 48 小时有效签名 URL
```

## 上传输入

SDK 接受 `Buffer` / `Blob` / `File` 并自动完成预签名上传:

```js
import fs from 'node:fs';

const project = client.projects.create({
  modelId: 'minimax-h3-fl2va-fp8_i2v',
  positivePrompt: '人物转身微笑',
  referenceImage: fs.readFileSync('./first-frame.png'),
});

// 可复用资产:显式上传
const saved = await client.projects.assets.upload(file, file.type, 'product-ref');
```

## 预估费用

```js
const quote = await client.projects.estimateVideoCost({ modelId, duration });
```

预览预估当前返回结构完整的零报价,实际以受理时价格规则为准
## 恢复与多实例

- **同账号同 `appId` 的新连接以关闭码 `4015` 接管旧连接**;多实例请用不同 `appId`。
- 进程重启后 SDK 重连时自动调用 `projects/sync`,继续追踪在途项目并领取已完成结果。

## 更多

- 上游契约的完整能力说明与示例见 `reelway-client-ts` 仓的 `README.md`、`llms.txt`、`examples/`(35+ 可运行示例)。
- 端点级参考见 [API 参考](https://docs.reelway.ai/api-reference/index.md);视频模型参数见[模型指南](https://docs.reelway.ai/models/index.md)。
