素材生成接口

提交生成任务(图片、改图、音效、音乐、视频、3D、配音、序列帧动画),排队执行后取回结果文件。任务是异步的:提交后拿到任务编号,再查询状态。用你的密钥登录用户页可以看到全部记录和用量。

鉴权

所有接口(除 /api/health)都要带密钥:

Authorization: Bearer tk_xxxxxxxx

接口根地址:

快速开始

BASE=
KEY=tk_xxxxxxxx

# 1. 提交任务
curl -s -X POST $BASE/api/tasks -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
  "type": "image", "title": "部落营地",
  "params": {"prompt": "卡通风格部落营地,篝火与帐篷", "name": "camp", "target_size": "1280x720", "aspect_ratio": "16:9"}
}'
# => {"id": "T00012", "status": "queued"}

# 2. 查询(每 10–30 秒一次即可;视频通常几分钟)
curl -s $BASE/api/tasks/T00012 -H "Authorization: Bearer $KEY"
# status=done 时,file_urls 是结果文件地址(下载同样要带 Authorization),result.previewUrl 是上游公开预览地址(图片有)

# 3. 下载
curl -s -o camp.png -H "Authorization: Bearer $KEY" "$BASE/files/assets/image/k1_camp_20261124050036.png"

接口

方法与路径说明
POST /api/tasks提交任务。请求体 {"type", "title"(可选), "params"},返回 {"id","status"}
GET /api/tasks/{id}任务详情:status、params、result、files、file_urls、credits、error、steps、children(重做出的新任务)
GET /api/tasks任务列表,倒序。查询参数 status type limit(≤500) offset
POST /api/tasks/{id}/redo不满意重做:沿用原参数生成新任务,请求体 {"params": {...}} 里的字段会覆盖原参数(如改 prompt)。返回新任务编号
POST /api/tasks/{id}/cancel取消排队中的任务(已开始的无法取消)
POST /api/uploads?filename=x.png上传参考素材,请求体为文件原始字节(≤30MB,图片/视频/音频)。返回 {"path"},可直接用在 params 的文件参数里
GET /files/{path}下载自己的结果或上传文件;加 ?download=1 以附件形式下载
GET /api/me密钥名称、各状态任务数、已记录积分
GET /api/health服务是否在线(无需密钥)

任务状态

queued 排队中 → running 生成中 → done 完成。异常结束为 failed(上游明确失败,看 error)或 unknown(超时或服务重启,无法确定是否已执行,先查询再决定是否重做,避免重复扣费);canceled 为已取消。

任务类型与参数

type必填常用可选
imageprompt, name, target_size(如 "1280x720")aspect_ratio, resolution(0.5K/1K/2K/4K), transparent, reference_images(≤14), quality, seed, model
image_batchimages(数组,每项同 image)
edit_imageimage, prompt, name, target_sizereference_images, aspect_ratio, resolution
sfxtextduration_seconds(≤120), loop, output_name
sfx_batchsounds(数组 {name,text,duration,loop})
musicpromptcustomMode, style, title, instrumental, model
videomode, duration(4–10 整数秒)prompt, images, videos, audios, resolution(480p/720p), ratio, generate_audio
3dprompt 或 imagesquality_tier(fast/balanced/high_quality), rig(true 则生成后绑骨骼), subject_type
voice_auditioncharacter_name, character_description, audition_line(≥100 字)candidate_count(1–3)
dialogueinputs(数组 {character_name,text})output_name, stability
spritesprite, anim,以及 source_image 或 design_prompt,以及 action 或 video_pathduration(默认 4), resolution, fps(默认 12), target_height(默认 256), loop, style_refs

video.mode

text_to_video / first_frame / first_last_frame / multi_modal_reference。图片写法 "images": [{"url": "...", "role": "first_frame"}]。

sprite(序列帧动画)

流程:设定图 → 视频 → 抠绿幕、拆帧、打包,输出 spritesheet.png、spritesheet.json、frames_preview.webp。设定图要求侧视朝右、纯绿背景(#00FF00)、居中、四肢完整;design_prompt 不含“绿”字时会自动补上。action 只写动作,不描述外观。结果里的 green_residual_pct 偏高时建议换更干净的设定图。

文件参数怎么填

image、reference_images、images、source_image、style_refs、videos、audios 等文件参数只接受:

video_path 只接受你自己的文件路径。name / output_name 会自动加上 k{编号}_ 前缀;名称类参数不能包含 / \ ..。

限制