iot-image-sdk
v0.1.0
Published
IoT 平台文生图/图生图开放 API SDK(原生 fetch,零运行时依赖,Node 18+/浏览器)
Maintainers
Readme
iot-image-sdk (JavaScript / TypeScript)
文生图 / 图生图开放 API 的 JS/TS SDK(原生 fetch,零运行时依赖,Node 18+ / 浏览器)。
安装
npm install iot-image-sdk(本地开发:cd sdk/js && npm install 或软链)
快速开始
import { IotImageClient } from 'iot-image-sdk';
const client = new IotImageClient({ apiKey: 'sk-img-...', baseURL: 'https://iot.hbthink.cn' });
await client.health();
const r = await client.textToImage({ prompt: '赛博城市' });
const r2 = await client.imageToImage({ prompt: '换背景', imageUrl: 'https://.../ref.png' });
const up = await client.uploadImage(blob, 'ref.png');错误处理
非零 code 抛 IotImageError 子类:AuthenticationError(401)、InvalidRequestError(400)、RateLimitError(429)、TimeoutError(504)、ServiceError(502/其他)。超时/服务端/限流默认指数退避重试 2 次;401/400 不重试。
