开始使用
开放平台统一 AI 能力接口,覆盖文本、图片、视频三大类模型能力。
能力总览
▶
视频生成
以文本、参考图 / 视频 / 音频、首尾帧等方式创建视频生成任务。
POST /video/v1/tasks
▶
标准视频生成
以
content 内容列表统一描述文本、图片、视频、音频与首尾帧,创建标准协议视频任务。POST /video/v1/official/tasks
◔
视频查询
通过任务 ID 轮询查询视频生成状态与结果,获取视频与尾帧地址。
GET /video/v1/tasks/{taskId}
通用约定
请求地址
所有接口均以服务基础地址 + 请求路径缀拼接。
# 生产环境基础地址
https://api.9193ai.cn/
请求头
| 字段 | 类型 | 说明 |
|---|---|---|
| Content-Type | string | 固定为 application/json。必填 |
| Authorization | string | 接口鉴权凭证,格式为 Bearer {API_KEY}。必填 |
响应结构
所有接口统一返回 HttpResponse 包装结构:
{
"req_id": "8f3a91c2", // 请求ID,链路追踪用
"status": 0, // 业务状态码,0 表示成功,-1 表示失败
"error": null, // 错误提示信息,成功时为 null
"data": { } // 业务数据,具体结构见各接口文档
}
提示:视频类接口为异步任务模式,创建任务只返回任务 ID(
data.id),
需要轮询「视频查询」接口获取最终结果。
LLM 模型
对话补全接口,根据输入的上下文让模型补全对话内容。
创建对话补全
POST
/llm/v1/chat/completions
根据输入的上下文,让模型补全对话内容。支持流式(SSE)返回与思考模式。
请求体(Body)
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| model | string | — | 使用的模型 ID。必填 |
| messages | object[] | — | 对话的消息列表,至少 1 条。每项包含 role(system / user / assistant)与 content。必填 |
| thinking | object | nullable | 控制思考模式开关,子字段 type:enabled / disabled。 |
| reasoning_effort | string | high | 思考强度,枚举 none / low / high / max。 |
| max_tokens | integer | 8192 | 限制一次请求生成的最大 token 数,取值范围 1 ~ 393216。 |
| response_format | object | nullable | 指定输出格式,{ "type": "json_object" } 可开启 JSON 模式。 |
| stop | string | string[] | nullable | 遇到指定词时停止生成,最多 16 个。 |
| stream | boolean | false | 是否以 SSE 流式返回,消息流以 data: [DONE] 结尾。 |
| stream_options | object | nullable | 流式选项,include_usage 为 true 时每个块都带 usage。必须与 stream: true 同时使用。 |
| temperature | number | 1 | 采样温度,介于 0 ~ 2 之间。值越高输出越随机。 |
| top_p | number | 1 | 核采样参数,取值 0 ~ 1。建议与 temperature 二选一调整。 |
| tools | object[] | nullable | 模型可调用的工具列表,目前仅支持 function 类型。 |
| tool_choice | string | object | auto | 控制工具调用行为:none / auto / required 或指定具体 function。 |
| logprobs | boolean | false | 是否返回输出 token 的对数概率。 |
| top_logprobs | integer | nullable | 返回概率最高的前 N 个 token(0 ~ 20),需 logprobs 为 true。 |
| user_id | string | nullable | 业务侧用户标识,用于内容安全与缓存隔离,最大长度 512。 |
请求示例
curl https://api.9193ai.cn/llm/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -d '{ "model": "mustai-chat", "messages": [ {"role": "system", "content": "你是一个专业的短剧剧本助手。"}, {"role": "user", "content": "帮我写一个都市悬疑题材的开场。"} ], "temperature": 0.7, "stream": false }'
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 该对话的唯一标识符。 |
| object | string | 对象类型,固定为 chat.completion。 |
| created | integer | 创建时间,Unix 秒级时间戳。 |
| model | string | 生成该结果的模型名。 |
| choices | object[] | 生成的选择列表,含 index、finish_reason、message。 |
| choices[].message | object | 生成的消息,含 role、content、可选 reasoning_content、tool_calls。 |
| choices[].finish_reason | string | 停止原因:stop / length / content_filter / tool_calls。 |
| usage | object | 用量信息,含 prompt_tokens、completion_tokens、total_tokens。 |
响应示例
{
"id": "chat-9f2c1a...",
"object": "chat.completion",
"created": 1728451200,
"model": "mustai-chat",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "深夜的写字楼只剩下 27 层还亮着灯……"
}
}
],
"usage": {
"prompt_tokens": 38,
"completion_tokens": 142,
"total_tokens": 180
}
}
图片模型
文生图 / 图生图接口,支持多种尺寸比例与参考图输入。
创建图片生成任务
POST
/image/v1/tasks
根据文本提示词(可附参考图)创建图片生成任务。
请求体(Body)
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| model | string | — | 模型的 ID。必填 |
| prompt | string | — | 文本提示词输入。必填 |
| size | string | 1024x1024 | 图片分辨率,如 1024x1024、1280x720。 |
| ratio | string | 1:1 | 宽高比例:16:9 / 4:3 / 1:1 / 3:4 / 9:16。 |
| n | integer | 1 | 生成图片数量,取值范围 1 ~ 4。 |
| seed | integer | -1 | 随机种子,-1 表示随机。 |
| watermark | boolean | false | 生成图片是否包含水印。 |
| images | string[] | null | 参考图列表,取值 0 ~ 4 张,需为公开可访问的 URL。 |
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 任务 ID,用于查询任务状态与结果。 |
| status | string | 任务状态:queued / processing / completed / failed。 |
| images | string[] | 图片资源链接,仅任务完成后返回。 |
| created | integer | 任务创建时间,Unix 秒级时间戳。 |
图片模型同样采用异步任务机制,创建后可通过任务 ID 轮询查询结果。
视频生成
统一视频创建任务接口,支持文生视频、参考图 / 视频 / 音频、首尾帧等多种输入方式。
创建视频生成任务
POST
/video/v1/tasks
创建一个视频生成任务,接口立即返回任务 ID,视频生成过程为异步执行,需通过「视频查询」接口轮询获取结果。
请求体(Body)
命名约定:请求体采用
snake_case 下划线命名。
多词字段需使用下划线形式:generate_audio、return_last_frame、
first_image、last_image;其余字段为单词,命名与 Java 属性一致。
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| model | string | — |
模型的 ID。必填
|
| prompt | string | — | 文本提示词输入,用于描述期望生成的视频内容。 |
| resolution | string | — |
视频分辨率,枚举值:
|
| ratio | string | — |
生成视频的宽高比例,枚举值:16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9。
不同宽高比对应的宽高像素值见下方表格。
|
| duration | integer | — | 视频时长(秒)。 |
| generate_audio | boolean | true | 是否生成音频。对应 Java 属性 generateAudio,默认 true。 |
| seed | integer | -1 | 种子整数,用于控制生成内容的随机性。取值范围:[-1, 2^32-1] 之间的整数。 |
| watermark | boolean | false | 生成视频是否包含水印。枚举值:false 不含水印;true 含有水印。 |
| return_last_frame | boolean | false |
是否要求返回尾帧。对应 Java 属性 returnLastFrame。
last_frame_url 用于读取尾帧地址。
|
| images | string[] | null | 参考图。取值范围:0 – 9。支持传入公开可访问的资源在线 URL。 |
| videos | string[] | null | 参考视频输入。取值范围:0 – 3。支持传入公开可访问的资源在线 URL。 |
| audios | string[] | null | 参考音频输入。取值范围:0 – 3。支持传入公开可访问的资源在线 URL。 |
| first_image | string | null | 图生视频首帧输入。对应 Java 属性 firstImage。 |
| last_image | string | null | 视频尾帧约束输入。对应 Java 属性 lastImage。 |
| tools | string[] | null | 提示词。 |
宽高比与像素值对照
| 宽高比 | 480p | 720p | 1080p |
|---|---|---|---|
| 16:9 | 854 × 480 | 1280 × 720 | 1920 × 1080 |
| 4:3 | 640 × 480 | 960 × 720 | 1440 × 1080 |
| 1:1 | 480 × 480 | 720 × 720 | 1080 × 1080 |
| 3:4 | 480 × 640 | 720 × 960 | 1080 × 1440 |
| 9:16 | 480 × 854 | 720 × 1280 | 1080 × 1920 |
| 21:9 | 1120 × 480 | 1680 × 720 | 2520 × 1080 |
请求示例
curl -X POST https://api.9193ai.cn/video/v1/tasks \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -d '{ "model": "seedance_2.0", "prompt": "雨夜的城市街头,霓虹灯反射在湿漉漉的路面上,镜头缓慢推近", "resolution": "720p", "ratio": "16:9", "duration": 5, "generate_audio": true, "seed": -1, "watermark": false, "return_last_frame": true, "images": [], "videos": [], "audios": [], "first_image": null, "last_image": null, "tools": [] }'
响应字段
返回 UnifiedVideoVo 对象,创建任务时仅返回任务标识与初始状态:
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 任务 ID,如 cgt-20261009-8f3a91c2,用于查询任务状态和结果。 |
| model | string | 本次请求使用的模型 ID。 |
| status | string | 任务状态:queued / running / cancelled / succeeded / failed / expired,详见下方「任务状态说明」。 |
| content | object | 生成结果内容,创建任务阶段为 null,任务完成后返回 video_url / last_frame_url。 |
| content.video_url | string | 视频资源链接,仅 succeeded 后返回。(Java:videoUrl) |
| content.last_frame_url | string | 视频尾帧图像 URL,创建任务时 return_last_frame 为 true 时返回。(Java:lastFrameUrl) |
| usage | object | 用量信息,创建任务阶段为 null。 |
| usage.completion_tokens | integer | 补全 token 数。(Java:completionTokens) |
| usage.total_tokens | integer | 总消耗 token 数。(Java:totalTokens) |
| usage.deduct_points | integer | 本次任务消耗积分。(Java:deductPoints) |
| error | object | 错误信息,含 code、message;成功 / 排队 / 处理中为 null。 |
| error.code | string | 错误码。 |
| error.message | string | 错误提示信息。 |
| created_at | integer | 任务创建时间,Unix 秒级时间戳。(Java:createdAt) |
| updated_at | integer | 任务更新时间,Unix 秒级时间戳。(Java:updatedAt) |
| resolution | string | 分辨率,如 720p,仅查询结果返回。 |
| ratio | string | 画面比例,如 16:9,仅查询结果返回。 |
| duration | integer | 视频时长(秒),仅查询结果返回。 |
| seed | integer | 随机种子,仅查询结果返回。 |
| generate_audio | boolean | 是否生成音频,仅查询结果返回。(Java:generateAudio) |
响应示例
{
"req_id": "8f3a91c2",
"status": 0,
"error": null,
"data": {
"id": "cgt-20261009-8f3a91c2",
"model": "seedance_2.0",
"status": "queued",
"content": null,
"usage": null,
"error": null,
"created_at": 1728451200,
"updated_at": null,
"resolution": null,
"ratio": null,
"duration": null,
"seed": null,
"generate_audio": null
}
}
注意:
resolution 为 1080p 时不支持参考图(images)场景;
参考图最多 9 张、参考视频与参考音频各最多 3 个。
任务状态说明
queued — 排队中
running — 处理中
cancelled — 已取消
succeeded — 成功
failed — 失败
expired — 超时
标准视频生成
标准视频创建任务接口,使用 content 内容列表统一组织文本、图片、视频、音频与首尾帧输入。
创建标准视频任务
POST
/video/v1/official/tasks
创建一个标准视频生成任务,接口立即返回任务 ID,视频生成过程为异步执行,需通过「视频查询」接口轮询获取结果。
请求体(Body)
命名约定:多词字段采用
snake_case 下划线命名:
return_last_frame、generate_audio、image_url、video_url;
其余字段为单词,命名与 Java 属性一致。
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| model | string | — |
模型的 ID。必填
|
| content | object[] | — |
内容列表,按顺序描述本次生成任务的输入内容。必填
每项由 type 决定使用哪个子字段,详见下方「content 内容项」表格。
|
| return_last_frame | boolean | null |
是否返回最后一帧。对应 Java 属性 returnLastFrame,
为 true 时查询结果中的 last_frame_url 返回尾帧图像地址,可用于连贯视频生产工作流。
|
| generate_audio | boolean | true | 是否生成音频。对应 Java 属性 generateAudio。 |
| ratio | string | adaptive |
画面比例,可选值:16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9 /
adaptive(根据任务类型和输入内容自动适配宽高比)。
|
| duration | integer | — | 视频时长(秒)。 |
| resolution | string | — |
分辨率,均支持 480p、720p,仅部分模型支持 1080p、4k。
|
| watermark | boolean | false | 生成视频是否添加水印。 |
content 内容项
根据 type 选择填充 text / image_url / video_url:
| 字段 | 类型 | 说明 |
|---|---|---|
| type | string |
内容类型:text / image_url / video_url。必填
|
| text | string | 文本内容,type=text 时使用。 |
| image_url | object | 图片引用,type=image_url 时使用,结构为 { "url": "..." }。对应 Java 属性 imageUrl。 |
| video_url | object | 视频引用,type=video_url 时使用,结构为 { "url": "..." }。对应 Java 属性 videoUrl。 |
| role | string |
内容角色:reference_image / reference_video / reference_audio /
first_frame / last_frame。用于标注该素材在生成任务中的用途。
|
请求示例
curl -X POST https://api.9193ai.cn/video/v1/official/tasks \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -d '{ "model": "seedance_2.0", "content": [ { "type": "text", "text": "雨夜的城市街头,霓虹灯反射在湿漉漉的路面上,镜头缓慢推近" }, { "type": "image_url", "image_url": { "url": "https://cdn.example.com/ref/first-frame.jpg" }, "role": "first_frame" } ], "return_last_frame": true, "generate_audio": true, "ratio": "16:9", "duration": 5, "resolution": "720p", "watermark": false }'
响应字段
返回 UnifiedVideoVo 对象(多词字段为 snake_case 命名),创建任务时仅返回任务标识与初始状态:
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 任务 ID,如 cgt-20261009-7b1d4e05,用于查询任务状态和结果。 |
| model | string | 本次请求使用的模型 ID。 |
| status | string | 任务状态:queued / running / cancelled / succeeded / failed / expired,详见下方「任务状态说明」。 |
| content | object | 生成结果内容,创建任务阶段为 null,任务完成后返回 video_url / last_frame_url。 |
| content.video_url | string | 视频资源链接,仅 succeeded 后返回。(Java:videoUrl) |
| content.last_frame_url | string | 视频尾帧图像 URL,请求时 return_last_frame 为 true 时返回。(Java:lastFrameUrl) |
| usage | object | 用量信息,创建任务阶段为 null。 |
| usage.completion_tokens | integer | 补全 token 数。(Java:completionTokens) |
| usage.total_tokens | integer | 总消耗 token 数。(Java:totalTokens) |
| usage.deduct_points | integer | 本次任务消耗积分。(Java:deductPoints) |
| error | object | 错误信息,含 code、message;成功 / 排队 / 处理中为 null。 |
| error.code | string | 错误码。 |
| error.message | string | 错误提示信息。 |
| created_at | integer | 任务创建时间,Unix 秒级时间戳。(Java:createdAt) |
| updated_at | integer | 任务更新时间,Unix 秒级时间戳。(Java:updatedAt) |
| resolution | string | 分辨率,如 720p,仅查询结果返回。 |
| ratio | string | 画面比例,如 16:9,仅查询结果返回。 |
| duration | integer | 视频时长(秒),仅查询结果返回。 |
| seed | integer | 随机种子,仅查询结果返回。 |
| generate_audio | boolean | 是否生成音频,仅查询结果返回。(Java:generateAudio) |
响应示例
{
"req_id": "7b1d4e05",
"status": 0,
"error": null,
"data": {
"id": "cgt-20261009-7b1d4e05",
"model": "seedance_2.0",
"status": "queued",
"content": null,
"usage": null,
"error": null,
"created_at": 1728451200,
"updated_at": null,
"resolution": null,
"ratio": null,
"duration": null,
"seed": null,
"generate_audio": null
}
}
注意:
image_url / video_url 需传入公开可访问的资源在线 URL;
未显式指定 duration、resolution 时由模型侧按默认值处理。
任务状态说明
queued — 排队中
running — 处理中
cancelled — 已取消
succeeded — 成功
failed — 失败
expired — 超时
提示:创建成功后使用返回的任务 ID(
data.id)调用
「视频查询」接口轮询结果,建议间隔 5 ~ 10 秒。
视频查询
通过任务 ID 查询视频生成任务的状态与结果。
查询视频生成任务
GET
/video/v1/tasks/{taskId}
根据创建任务时返回的任务 ID(data.id)查询任务状态。建议以轮询方式调用,直至状态变为 succeeded、failed 或 expired。
路径参数(Path)
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| taskId | string | — | 创建视频任务时返回的任务 ID。必填 |
请求示例
curl -X GET https://api.9193ai.cn/video/v1/tasks/vt_20261009_8f3a91c2 \
-H "Authorization: Bearer $API_KEY"
响应字段
返回 UnifiedVideoVo 对象(多词字段为 snake_case 命名):
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 任务 ID,如 cgt-20261009-8f3a91c2。 |
| model | string | 本次请求使用的模型 ID。 |
| status | string | 任务状态:queued / running / cancelled / succeeded / failed / expired,详见下方「任务状态说明」。 |
| content | object | 生成结果内容,任务完成前为 null。 |
| content.video_url | string | 视频资源链接,仅 succeeded 后返回。(Java:videoUrl) |
| content.last_frame_url | string | 视频尾帧图像 URL,创建任务时 return_last_frame 为 true 时返回。(Java:lastFrameUrl) |
| usage | object | 用量信息,任务完成前为 null。 |
| usage.completion_tokens | integer | 补全 token 数。(Java:completionTokens) |
| usage.total_tokens | integer | 总消耗 token 数。(Java:totalTokens) |
| usage.deduct_points | integer | 本次任务消耗积分。(Java:deductPoints) |
| error | object | 错误信息,含 code、message;成功 / 排队 / 处理中为 null。 |
| error.code | string | 错误码。 |
| error.message | string | 错误提示信息。 |
| created_at | integer | 任务创建时间,Unix 秒级时间戳。(Java:createdAt) |
| updated_at | integer | 任务更新时间,Unix 秒级时间戳。(Java:updatedAt) |
| resolution | string | 分辨率,如 720p。 |
| ratio | string | 画面比例,如 16:9。 |
| duration | integer | 视频时长(秒)。 |
| seed | integer | 随机种子。 |
| generate_audio | boolean | 是否生成音频。(Java:generateAudio) |
响应示例(处理中)
{
"req_id": "8f3a91c2",
"status": 0,
"error": null,
"data": {
"id": "cgt-20261009-8f3a91c2",
"model": "seedance_2.0",
"status": "running",
"content": null,
"usage": null,
"error": null,
"created_at": 1728451200,
"updated_at": 1728451235,
"resolution": null,
"ratio": null,
"duration": null,
"seed": null,
"generate_audio": null
}
}
响应示例(已完成)
{
"req_id": "8f3a91c2",
"status": 0,
"error": null,
"data": {
"id": "cgt-20261009-8f3a91c2",
"model": "seedance_2.0",
"status": "succeeded",
"content": {
"video_url": "https://cdn.example.com/video/cgt-20261009-8f3a91c2.mp4",
"last_frame_url": "https://cdn.example.com/video/cgt-20261009-8f3a91c2_last.jpg"
},
"usage": {
"completion_tokens": 86000,
"total_tokens": 86000,
"deduct_points": 120
},
"error": null,
"created_at": 1728451200,
"updated_at": 1728451302,
"resolution": "720p",
"ratio": "16:9",
"duration": 5,
"seed": -1,
"generate_audio": true
}
}
任务状态说明
queued — 排队中
running — 处理中
cancelled — 已取消
succeeded — 成功
failed — 失败
expired — 超时
轮询建议
# 轮询逻辑(伪代码) taskId = create_video_task(...) // 1. 创建任务,取 data.id while True: resp = GET(f"/video/v1/tasks/{taskId}") // 2. 查询状态 if resp.data.status == "succeeded": return resp.data.content.video_url // 3. 取回视频地址 if resp.data.status in ("failed", "expired", "cancelled"): raise Exception(resp.data.error.message) // 失败原因在 error.message sleep(5) // 建议间隔 5 秒左右
建议:查询间隔设置为 5 ~ 10 秒;
content 与 usage
在任务完成前均为 null,请勿提前读取。