Fengling API

客户对接文档

用于接入 api.kuocai.net 的视频/图片生成、任务查询、账户用量和余额查询接口,支持 Seedance、Seedance Fast、Seedance 标准线路一、Happy Horse 与 fengling image2。

基础信息

所有接口均使用 HTTPS 调用。

Base URL https://api.kuocai.net

支持模型

model_id 模型 售价 默认时长 支持时长 分辨率 说明
52 Seedance ¥1.00/秒 4 秒 4-15 秒 480P720P 支持参考图、首尾帧、参考音频、参考视频
51 Seedance Fast ¥1.00/秒 4 秒 4-15 秒 480P720P 支持参考图、参考音频、参考视频
53 Seedance 标准线路一 ¥1.00/秒 4 秒 4-15 秒 480P720P 固定使用标准线路一;折扣用户最低 ¥0.90/秒,720P 结果由本服务后处理生成
39 Happy Horse ¥0.40/秒 5 秒 51015 720P 支持参考图、首尾帧
45 fengling image2 ¥0.30/张 - - 2K4K1080P 图片生成,支持参考图

视频接口 model_id 可不传,不传时默认使用 Seedance。选择 Seedance Fast 时请传 model_id: 51,选择 Seedance 标准线路一时请传 model_id: 53,选择 Happy Horse 时请传 model_id: 39。图片接口选择 fengling image2 时请传 model_id: 45

鉴权方式

所有业务接口都需要在请求头中携带客户 API Key。请妥善保管 API Key,建议由服务端调用本 API。

Authorization: Bearer kc_xxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

1. 提交视频生成任务

POST /api/v1/video/generations

请求参数

字段 类型 必填 说明
promptstring视频描述文本
model_idnumber52 为 Seedance,51 为 Seedance Fast,53 为 Seedance 标准线路一,39 为 Happy Horse;默认 52
sizestringSeedance 系列: 9:1616:91:13:22:321:9;Happy Horse: 16:99:164:33:41:1
secondsnumberSeedance 系列: 4-15,默认 4;Happy Horse: 5/10/15,默认 5
resolutionstringSeedance 系列: 480P720P;Happy Horse: 720P
countnumber1234,默认 1
reference_imagestring单张参考图公网 HTTPS URL
reference_imagesstring[]多张参考图公网 HTTPS URL,最多 9 个
frame_startstringSeedance、Happy Horse 支持,首帧图片公网 HTTPS URL
frame_endstringSeedance、Happy Horse 支持,尾帧图片公网 HTTPS URL
reference_audiostringSeedance 系列支持,单个参考音频公网 HTTPS URL
reference_audiosstring[]Seedance 系列支持,多个参考音频公网 HTTPS URL,最多 3 个
reference_videostringSeedance 系列支持,单个参考视频公网 HTTPS URL
reference_videosstring[]Seedance 系列支持,多个参考视频公网 HTTPS URL,最多 3 个

参考素材 URL 只能使用公网 HTTPS 地址。系统会拒绝 HTTP、localhost、内网/本地 IP、带账号密码的 URL,以及 DNS 解析到内网/本地地址的域名。

计费规则

消费金额 = seconds × count × 模型单价
模型secondscount消费金额
Seedance41¥4.00
Seedance154¥60.00
Seedance Fast82¥16.00
Seedance 标准线路一82¥16.00;折扣用户最低 ¥14.40
Happy Horse52¥4.00
Happy Horse154¥24.00

余额不足时返回 402 Insufficient balance。上游失败、超时、业务错误码非 200 或生成接口没有返回 data.task_id 时,本次预扣金额会自动退回。

Seedance 请求示例

curl -X POST https://api.kuocai.net/api/v1/video/generations \
  -H "Authorization: Bearer kc_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": 52,
    "prompt": "海边日落延时摄影,金色阳光洒在波浪上",
    "size": "9:16",
    "seconds": 4,
    "resolution": "480P",
    "count": 1,
    "reference_video": "https://your-cdn.example/reference.mp4"
  }'

Happy Horse 请求示例

curl -X POST https://api.kuocai.net/api/v1/video/generations \
  -H "Authorization: Bearer kc_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": 39,
    "prompt": "草原上奔跑的马,电影感镜头",
    "size": "16:9",
    "seconds": 5,
    "resolution": "720P",
    "count": 2,
    "reference_images": [
      "https://your-cdn.example/horse-1.jpg",
      "https://your-cdn.example/horse-2.jpg"
    ]
  }'

Seedance Fast 请求示例

curl -X POST https://api.kuocai.net/api/v1/video/generations \
  -H "Authorization: Bearer kc_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": 51,
    "prompt": "海边日落延时摄影,金色阳光洒在波浪上",
    "size": "9:16",
    "seconds": 8,
    "resolution": "480P",
    "count": 1,
    "reference_image": "https://your-cdn.example/reference.jpg",
    "reference_audio": "https://your-cdn.example/reference.mp3"
  }'

Seedance 标准线路一请求示例

curl -X POST https://api.kuocai.net/api/v1/video/generations \
  -H "Authorization: Bearer kc_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": 53,
    "prompt": "城市夜景航拍,霓虹灯反射在雨后街道上",
    "size": "16:9",
    "seconds": 8,
    "resolution": "720P",
    "count": 1,
    "reference_image": "https://your-cdn.example/reference.jpg"
  }'

2. 提交图片生成任务

POST /api/v1/images/generations

fengling image2 售价为 ¥0.30/张,成本为 ¥0.10/张。计费公式为 count × ¥0.30

字段 类型 必填 说明
promptstring图片描述文本
model_idnumber45 为 fengling image2
sizestring1:12:33:23:44:316:99:16
resolutionstring2K4K1080P
countnumber1234,默认 1
reference_imagestring单张参考图公网 HTTPS URL
reference_imagesstring[]多张参考图公网 HTTPS URL,最多 9 个
curl -X POST https://api.kuocai.net/api/v1/images/generations \
  -H "Authorization: Bearer kc_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": 45,
    "prompt": "窗边晒太阳的橘猫,柔和自然光",
    "size": "1:1",
    "resolution": "2K",
    "count": 3,
    "reference_images": [
      "https://your-cdn.example/cat-1.jpg",
      "https://your-cdn.example/cat-2.jpg"
    ]
  }'

3. 查询任务状态

GET /api/v1/tasks/{task_id}

task_id 为提交生成任务后返回的任务 ID。后续只能使用同一个 API Key 查询该任务结果。

curl -X GET https://api.kuocai.net/api/v1/tasks/T202604271430001234C001 \
  -H "Authorization: Bearer kc_your_api_key"

建议客户服务端轮询查询任务状态。轮询间隔建议不少于 3-5 秒。

4. 查询账户用量和余额

GET /api/v1/usage

该接口用于查询当前 API Key 的余额、消费金额、计费秒数/张数、任务历史和最近请求记录。

curl -X GET https://api.kuocai.net/api/v1/usage \
  -H "Authorization: Bearer kc_your_api_key"

5. 健康检查

GET /health

该接口不需要客户 API Key,会返回当前可用模型列表。

curl https://api.kuocai.net/health

6. 客户页面

客户可打开自助页面查询余额,也可在测试台用自己的 kc_... API Key 直接测试 Seedance、Seedance Fast、Seedance 标准线路一、Happy Horse 和 fengling image2。

https://api.kuocai.net/client
https://api.kuocai.net/test

错误码

HTTP 状态码message说明
400Request body must be valid JSON请求体不是合法 JSON
400prompt must be a non-empty string缺少 prompt 或为空
400model_id must be one of: 52, 51, 53, 39model_id must be one of: 45模型 ID 不支持
400{field} has an unsupported value参数值不在所选模型支持范围内
400{field} must be a public HTTPS URL参考素材 URL 不是公网 HTTPS 地址
401Invalid or missing API keyAPI Key 缺失或无效
403API key is disabledAPI Key 已停用
402Insufficient balance余额不足
404Task not found任务不存在或不属于当前 API Key
502Upstream request failed上游服务请求失败或返回业务错误
504Upstream request timed out上游服务请求超时