AI_Painting_V2.0/docs/模型参数后端化方案.md

191 lines
6.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 欢迎使用 RunningHub API轻松调用 RunningHub 标准模型API
## 开始使用
### 注册用户
先注册成为RunningHub网站的用户并充值钱包。标准模型API仅支持企业级-共享API Key
### 获取您的 API Key
RunningHub 为每位用户自动生成一个独特的 32 位 API KEY
请妥善保存您的 API KEY不要外泄后续步骤将依赖此密钥进行操作
### 提交请求
提交 API 请求。RunningHub API 已为您处理 API Key您只需提交请求即可
```curl
curl --location --request POST 'https://www.runninghub.cn/openapi/v2/rhart-video/ltx-2.3/text-to-video' \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${RUNNINGHUB_API_KEY}" \
--data-raw '{
"prompt": "第一视角无人机跟拍视角主体为一只自由飞翔的鸟镜头快速划过城市上空与飞鸟同步高速飞行沉浸式第一视角流畅丝滑运镜低空急速掠过楼宇街道强烈速度感与飞行沉浸感电影级动态光影稳定不抖动4K 超清画质,飞鸟为主视觉,城市背景虚化,氛围感拉满。",
"resolution": "720p",
"aspectRatio": "16:9",
"duration": 5
}'
```
#### 请求参数说明
| 参数说明 | 类型 | 必填/可选 | AI 应用程序生成的结果。 |
| --- | --- | --- | --- |
| `prompt` | String | 必填 | |
| `resolution` | String | 必填 | 枚举值: [1080p, 720p, 480p] |
| `aspectRatio` | String | 必填 | 枚举值: [16:9, 9:16] |
| `duration` | Int | 必填 | 输入范围值: 5 - 15 |
#### 响应示例
```json
{
"taskId": "2013508786110730241",
"status": "RUNNING",
"errorCode": "",
"errorMessage": "",
"results": null,
"clientId": "f828b9af25161bc066ef152db7b29ccc",
"promptTips": "{\"result\": true, \"error\": null, \"outputs_to_execute\": [\"4\"], \"node_errors\": {}}"
}
```
#### 响应字段说明
| 参数说明 | 类型 | AI 应用程序生成的结果。 |
| --- | --- | --- |
| `taskId` | String | 任务ID用于后续查询任务状态 |
| `status` | String | 当前任务状态常见状态QUEUED (排队中), RUNNING (运行中), SUCCESS (成功), FAILED (失败) |
| `errorCode` | String | 错误码,仅在失败时返回 |
| `errorMessage` | String | 错误具体信息 |
| `results` | List | 生成结果(提交时为 null |
| ├ `url` | String | 重要提醒:该链接有效期仅为 24 小时。任务生成结束后,请务必在此时间窗口内将视频文件下载或转存至您的服务器。逾期后链接将永久失效且无法恢复。 |
| ├ `nodeId` | String | 生成该结果的工作流节点 ID |
| ├ `outputType` | String | 文件扩展名 (如 png, mp4, txt) |
| └ `text` | String | 如果输出是纯文本,内容将显示在此字段 |
| `clientId` | String | 客户端会话ID用于标识本次连接 |
| `promptTips` | String (JSON) | ComfyUI 后端的校验信息包含需执行的节点ID等调试信息 |
### 查询结果与 Webhook
如果在提交时添加了 "webhookUrl": "https://example.com/webhook" 请求体参数RunningHub 会在任务完成时向您的URL发送POST请求
#### 请求示例
```curl
curl --location --request POST 'https://www.runninghub.cn/openapi/v2/query' \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${RUNNINGHUB_API_KEY}" \
--data-raw '{
"taskId": "${RUNNINGHUB_TASKID}"
}'
```
#### 响应示例
```json
{
"taskId": "2013508786110730241",
"status": "SUCCESS",
"errorCode": "",
"errorMessage": "",
"failedReason": {},
"usage": {
"consumeMoney": null,
"consumeCoins": null,
"taskCostTime": "0",
"thirdPartyConsumeMoney": null
},
"results": [
{
"url": "https://rh-images-1252422369.cos.ap-beijing.myqcloud.com/b04e28cad0ee39193921a30a2eb4dc00/output/ComfyUI_00001_plhjr_1768892915.png",
"nodeId": "2",
"outputType": "png",
"text": null
}
],
"clientId": "",
"promptTips": ""
}
```
#### 响应字段说明
| 参数说明 | 类型 | AI 应用程序生成的结果。 |
| --- | --- | --- |
| `taskId` | String | 任务 ID |
| `status` | String | 任务最终状态SUCCESS 表示生成成功 |
| `results` | List | 生成结果列表,包含图片、视频或文本等输出 |
| ├ `url` | String | 重要提醒:该链接有效期仅为 24 小时。任务生成结束后,请务必在此时间窗口内将视频文件下载或转存至您的服务器。逾期后链接将永久失效且无法恢复。 |
| ├ `nodeId` | String | 生成该结果的工作流节点 ID |
| ├ `outputType` | String | 文件扩展名 (如 png, mp4, txt) |
| └ `text` | String | 如果输出是纯文本,内容将显示在此字段 |
| `errorCode` | String | 错误码 (如有) |
| `errorMessage` | String | 错误信息 (如有) |
| `failedReason` | Object | ComfyUI 相关的失败原因 |
| `usage` | Object | 任务消耗信息 |
| ├ `thirdPartyConsumeMoney` | String | 三方API消费金额 |
| ├ `consumeMoney` | String | 运行时长消耗金额 |
| ├ `consumeCoins` | String | 运行消耗的RH币 |
| └ `taskCostTime` | String | 运行耗时ComfyUI 工作流运行时长) |
### 文件上传
资源文件(如 imageUrls参数支持传入文件 URL 或 Base64 Data URI。
#### 公共 URL
直接传递可公开访问的 URL
```json
{
"imageUrls": [
"https://example.com/image.png"
]
}
```
#### Base64 data URI
以 Base64 格式嵌入图片:
```json
{
"images": [
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
]
}
```
#### RH 上传接口
上传本地文件以获取一个 URL。
**Endpoint:** `https://www.runninghub.cn/openapi/v2/media/upload/binary`
**请求**
```curl
curl --location --request POST 'https://www.runninghub.cn/openapi/v2/media/upload/binary' \
--header 'Authorization: Bearer [Your API KEY]' \
--form 'file=@/path/to/image.png'
```
**响应**
```json
{
"code": 0,
"message": "success",
"data": {
"type": "image",
"download_url": "xxxx.png",
"fileName": "openapi/xxxx.png",
"size": "3490"
}
}
```
**备注:** 上传后获得的链接有效期为 1 天,超期将无法通过 URL 直接访问。