# O1Key API 对接文档 > 图像与视频生成接口。统一 Bearer 鉴权,异步任务提交后按任务 ID 轮询结果。 鉴权:`Authorization: Bearer `。Base URL:`https://api.o1key.com`(主地址)。 每个链接是一页 Markdown,开头的 YAML 写明接口路径,`## Agent 调用规则` 写明提交、轮询和失败处理方式。 ## 对接指南 - [对接概览](/docs/index.md): 本文档面向接入方技术团队,说明如何调用图像与视频生成接口。所有接口共用一套 Bearer 鉴权:先上传参考素材取得公网地址,再提交生成任务,最后按任务 ID 轮询结果。 - [临时素材上传](/docs/temporary-upload.md): 把本地图片、音频、视频或文档上传,换取生成接口可以引用的公网 URL。同步返回,无需轮询。 ## 图像 - [图片生成:调用方式](/docs/image-v2.md): 所有图片模型共用一个异步接口:POST /v2/images 提交,GET /v2/images/{id} 查询。 - [GPT Image](/docs/image-gpt-image.md): 文生图与参考图编辑,支持透明背景;2.6 另支持 SVG、GIF 和标注图编辑。 - [Nano Banana(Gemini)](/docs/image-nano-banana.md): Gemini 原生图片模型:文生图、参考图编辑与多图融合,每次 1 张。 - [Seedream](/docs/image-seedream.md): 单图生成、参考图编辑与多图融合;5.0 Pro 还支持图层拆分。 - [Midjourney](/docs/image-midjourney.md): Midjourney v8.2:画幅、画质等设置写在提示词末尾,每次返回 4 张图,按次计费。 - [Kling IMAGE 4.0](/docs/image-kling.md): 可灵 Image 4.0 的单图、组图和长图(电商详情页、网页设计)。路径、请求体和响应都与可灵官方一致,只需把 Base URL 和 API Key 换成本站。客户端使用任务 ID 轮询结果,提交时请省略 callback_url。 ## 视频 - [Seedance 素材与视频](/docs/seedance.md): 提交视频任务,保存任务 ID,再查询结果。参考素材可直接传 URL,需要复用时再预上传。 - [SD 2 / SD 2.5 视频生成](/docs/sd-video.md): 11 个按秒计费的视频模型,支持文字生成和图片、视频、音频参考。通过同一个接口提交任务、查询进度和下载 MP4。 - [MiniMax H3 系列视频生成](/docs/minimax-h3.md): 支持 H3、Highspeed、Lite、Max 和 Max Turbo。按模型选择分辨率和输入素材,通过统一异步接口提交任务并查询视频结果。 - [万相 Wan 3.0 视频生成](/docs/wan3.md): 文生视频、首帧/首尾帧生视频、参考生视频和视频编辑。通过统一异步接口创建任务,并使用任务 ID 查询结果。 - [Gemini Omni 视频](/docs/gemini-omni.md): 文生视频、图生视频、多参考图生视频和视频编辑。媒体输入只接受 Base64,完成后通过内容接口下载 MP4。 - [Omni Flash 1.2 视频](/docs/omni-flash.md): 文生视频和视频编辑,按次计费。提交后返回任务 ID,查询到 completed 后下载 MP4。 - [Grok 视频生成](/docs/grok-video.md): 支持视频生成、视频编辑和视频延长三种操作。三个接口共用同一查询端点。 - [Kling VIDEO 4.0 / Flash](/docs/kling-4.md): 可灵 4.0 与 4.0 Flash 的文生视频、图生视频(多关键帧)和 Omni 多素材 / 视频编辑。路径与可灵官方一致。客户端使用任务 ID 轮询状态,提交时请省略 callback_url。 - [Kling VIDEO 3.0](/docs/kling-3.md): 可灵 3.0 文生视频、图生视频、3.0 Omni(多素材参考、视频编辑)和动作模仿。路径与可灵官方一致,提交后返回 data.id,用 GET /tasks 查询。客户端使用任务 ID 轮询状态,提交时请省略 callback_url。 ## 机器可读 - [全部文档](/docs/llms-full.txt): 以上所有页面合并为一份 Markdown --- # 对接概览 本文档面向接入方技术团队,说明如何调用图像与视频生成接口。所有接口共用一套 Bearer 鉴权:先上传参考素材取得公网地址,再提交生成任务,最后按任务 ID 轮询结果。 ## 基本信息 | 入口 | Base URL | 说明 | |---|---|---| | 主地址 | `https://api.o1key.com` | 所有接口和文档示例均使用此地址 | | 项目 | 说明 | |---|---| | 认证方式 | 请求头 `Authorization: Bearer `,所有接口相同 | | 数据格式 | JSON,UTF-8 编码。素材上传接口使用 `multipart/form-data` | | 素材地址 | 参考图、视频、音频需为公网可直接下载的 URL。本地文件先用[素材上传](/docs/temporary-upload.md)换取 URL | ## 接口一览 | 分类 | 模型 / 能力 | 接口 | 路径 | 说明 | |---|---|---|---|---| | 对接指南 | [素材上传](/docs/temporary-upload.md) | 上传文件 | `POST /v1/o1key/uploads` | 文件 URL(同步) | | 图像 | [调用方式](/docs/image-v2.md) | 提交任务 | `POST /v2/images` | 任务对象(202) | | 图像 | [调用方式](/docs/image-v2.md) | 查询任务 | `GET /v2/images/{id}` | 任务对象 | | 图像 | [调用方式](/docs/image-v2.md) | 可用模型 | `GET /v2/image/models` | 模型与参数列表 | | 图像 | [GPT Image](/docs/image-gpt-image.md) | 提交 GPT Image 任务 | `POST /v2/images` | 任务对象(202) | | 图像 | [Nano Banana](/docs/image-nano-banana.md) | 提交 Nano Banana 任务 | `POST /v2/images` | 任务对象(202) | | 图像 | [Seedream](/docs/image-seedream.md) | 提交 Seedream 任务 | `POST /v2/images` | 任务对象(202) | | 图像 | [Midjourney](/docs/image-midjourney.md) | 提交 Midjourney 任务 | `POST /v2/images` | 任务对象(202) | | 图像 | [Kling Image 4.0](/docs/image-kling.md) | 单图与组图 | `POST /image-generation/kling-4.0` | 任务 ID(异步) | | 图像 | [Kling Image 4.0](/docs/image-kling.md) | 长图(电商详情页 / 网页设计) | `POST /long-image-generation/kling-4.0` | 任务 ID(异步) | | 图像 | [Kling Image 4.0](/docs/image-kling.md) | 查询图片任务 | `GET /tasks?task_ids={task_id}` | 任务状态与图片 | | 视频 | [Seedance](/docs/seedance.md) | Seedance 多模态视频生成 | `POST /v1/video/generations` | 任务 ID(异步) | | 视频 | [Seedance](/docs/seedance.md) | 查询视频任务 | `GET /v1/video/generations/{task_id}` | 任务状态与结果 | | 视频 | [Seedance](/docs/seedance.md) | 创建素材 | `POST /v1/seedance/assets` | 素材 ID | | 视频 | [Seedance](/docs/seedance.md) | 查询素材 | `GET /v1/seedance/assets/{asset_id}?type={type}` | 素材状态 | | 视频 | [SD 2 / SD 2.5](/docs/sd-video.md) | 创建视频 | `POST /v1/videos` | 视频任务 ID | | 视频 | [SD 2 / SD 2.5](/docs/sd-video.md) | 查询任务和下载视频 | `GET /v1/videos/{id}`
`GET /v1/videos/{id}/content` | 任务状态或 MP4 文件 | | 视频 | [MiniMax H3](/docs/minimax-h3.md) | 创建 MiniMax H3 系列视频任务 | `POST /v1/video/generations` | 任务 ID(异步) | | 视频 | [MiniMax H3](/docs/minimax-h3.md) | 查询 MiniMax H3 系列视频任务 | `GET /v1/videos/{task_id}` | 任务状态与结果 | | 视频 | [万相 Wan 3.0](/docs/wan3.md) | 创建万相 Wan 3.0 视频任务 | `POST /v1/video/generations` | 任务 ID(异步) | | 视频 | [万相 Wan 3.0](/docs/wan3.md) | 查询万相 Wan 3.0 视频任务 | `GET /v1/video/generations/{task_id}` | 任务状态与结果 | | 视频 | [Gemini Omni](/docs/gemini-omni.md) | 创建 Gemini Omni 视频任务 | `POST /v1/videos` | 任务 ID(异步) | | 视频 | [Gemini Omni](/docs/gemini-omni.md) | 查询与下载 Gemini Omni 视频 | `GET /v1/videos/{task_id}`
`GET /v1/videos/{task_id}/content` | 任务状态、视频文件 | | 视频 | [Omni Flash 1.2](/docs/omni-flash.md) | 创建 Omni Flash 1.2 视频任务 | `POST /v1/videos` | 任务 ID(异步) | | 视频 | [Omni Flash 1.2](/docs/omni-flash.md) | 查询与下载 Omni Flash 1.2 视频 | `GET /v1/videos/{task_id}`
`GET /v1/videos/{task_id}/content` | 任务状态、视频文件 | | 视频 | [Grok 视频](/docs/grok-video.md) | 视频生成 | `POST /grok/v1/videos/generations` | 任务 ID(异步) | | 视频 | [Grok 视频](/docs/grok-video.md) | 查询任务 | `GET /grok/v1/videos/{task_id}` | 任务状态与结果 | | 视频 | [Grok 视频](/docs/grok-video.md) | 视频编辑 | `POST /grok/v1/videos/edits` | 任务 ID(异步) | | 视频 | [Grok 视频](/docs/grok-video.md) | 视频延长 | `POST /grok/v1/videos/extensions` | 任务 ID(异步) | | 视频 | [Kling 4.0 / Flash](/docs/kling-4.md) | 文生视频 | `POST /text-to-video/kling-4.0`
`POST /text-to-video/kling-4.0-flash` | 任务 ID(异步) | | 视频 | [Kling 4.0 / Flash](/docs/kling-4.md) | 图生视频 · 多关键帧 | `POST /image-to-video/kling-4.0`
`POST /image-to-video/kling-4.0-flash` | 任务 ID(异步) | | 视频 | [Kling 4.0 / Flash](/docs/kling-4.md) | Omni 多素材与视频编辑 | `POST /omni-video/kling-4.0`
`POST /omni-video/kling-4.0-flash` | 任务 ID(异步) | | 视频 | [Kling 4.0 / Flash](/docs/kling-4.md) | 查询任务(GET / POST /tasks) | `GET /tasks`
`POST /tasks` | 任务状态与结果 | | 视频 | [Kling 3.0](/docs/kling-3.md) | 文生视频 | `POST /text-to-video/kling-3.0` | 任务 ID(异步) | | 视频 | [Kling 3.0](/docs/kling-3.md) | 图生视频 | `POST /image-to-video/kling-3.0` | 任务 ID(异步) | | 视频 | [Kling 3.0](/docs/kling-3.md) | Kling 3.0 Omni 视频生成 | `POST /omni-video/kling-3.0-omni` | 任务 ID(异步) | | 视频 | [Kling 3.0](/docs/kling-3.md) | Kling 3.0 动作模仿 | `POST /motion-control/kling-3.0` | 任务 ID(异步) | ## 任务流程 1**上传素材**
本地文件先换取公网 URL,线上素材可直接使用。 2**提交任务**
选择模型与参数,立即返回任务 ID。 3**轮询结果**
用任务 ID 查询,直到成功或失败。各接口的状态名和建议间隔见对应页面。 ## 对接清单 获取 API Key,并确认可用模型 完成一次提交和查询,确认返回格式 实现轮询,并处理失败状态和错误信息 成功后下载结果。部分接口的结果链接有时效,见对应页面 --- # 临时素材上传 把本地图片、音频、视频或文档上传,换取生成接口可以引用的公网 URL。同步返回,无需轮询。 ## Agent 调用规则 1. 用 `multipart/form-data` POST `/v1/o1key/uploads`,字段名 `file`,一次一个文件。 2. 从响应读取 `url`,填入生成接口的素材字段;注意 `expires_at`。 3. 400 表示文件无效、格式不支持或传了多个文件;413 表示超过大小限制。把原因告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 生成接口只接受公网可下载的素材地址。手里只有本地文件时,先用这个接口上传,拿到 URL 后再提交生成任务。 ### 你需要提供的信息 - **文件**:`file`,每次 1 个文件,最大 20 MiB。多个文件请分别上传。 - **格式**:图片 png / jpg / jpeg / webp,音频 mp3 / wav / m4a,视频 mp4 / mov,文档 pdf / txt / md。 ### 怎么拿到结果 - **返回**:接口直接返回 `url`,上传后 24 小时内有效,到期时间见 `expires_at`。 ## 上传文件 `POST /v1/o1key/uploads` `Authorization: Bearer ` · `multipart/form-data` **参数**:`file`(必填,每次 1 个文件,最大 20 MiB)。多个文件请分别上传。 返回的 `url` 可直接用作各生成接口的参考素材,上传后 24 小时内有效,到期时间见 `expires_at`。 ### 支持的文件格式 | 类型 | 扩展名 | |---|---| | 图片 | `png`、`jpg`、`jpeg`、`webp` | | 音频 | `mp3`、`wav`、`m4a` | | 视频 | `mp4`、`mov` | | 文档 | `pdf`、`txt`、`md` | **常见错误**:`400` 文件无效、格式不支持或传入多个文件 · `401` 鉴权失败 · `413` 超过大小限制 ### 请求 ```bash curl -X POST "$BASE_URL/v1/o1key/uploads" \ -H "Authorization: Bearer $API_KEY" \ -F "file=@./reference.png" ``` ### 成功响应 ```json { "url": "https://upload.o1key.com/tmp/input/7f46d5e8-9bf6-45c4-9a3a-87dbd5138dd1.png", "filename": "reference.png", "content_type": "image/png", "size": 11630, "expires_at": 1787495062 } ``` ### 错误响应(HTTP 400 示例) ```json { "error": "unsupported attachment type" } ``` --- # 图片生成:调用方式 所有图片模型共用一个异步接口:POST /v2/images 提交,GET /v2/images/{id} 查询。 ## Agent 调用规则 1. POST `/v2/images`,带 `Idempotency-Key`;网络超时重试时沿用同一个值。 2. 按 `Retry-After` 轮询 GET `/v2/images/{id}`,直到 `succeeded` 或 `failed`。 3. 收到 `400` 按 `error.param` 修正参数;任务 `failed` 时只在 `error.retryable` 为 `true` 时重新提交。 ## 提交任务 `POST /v2/images` ### 请求参数 | 字段 | 必填 | 说明 | |---|---|---| | `model` | 是 | 模型名,见各模型页。 | | `prompt` | 是 | 生成或编辑指令。 | | `n` | 否 | 张数,默认 1。 | | `images` | 否 | 参考图,每项为 `{"url"}` 或 `{"data", "mime_type"}`(Base64)。 | | `resolution` + `aspect_ratio` | 否 | 档位(如 `2K`)加宽高比(如 `16:9`)。 | | `size` | 否 | 像素尺寸 `WIDTHxHEIGHT`。与 `resolution` 二选一。 | | `quality` | 否 | 画质,仅 GPT Image。 | | `output` | 否 | `format`、`compression`、`background`。 | | `provider_options` | 否 | 模型专属参数,键为 `gemini`、`openai` 或 `seedream`,见各模型页。 | | `metadata` | 否 | 自定义字符串键值,最多 16 个,原样返回。 | 请求头 `Idempotency-Key`(可选):24 小时内同一个值重复提交,返回同一个任务,不重复扣费。 各模型支持的尺寸、张数、格式和专属参数,也可以用 `GET /v2/image/models` 查询。 ### 提交错误 | HTTP | error.code | 处理 | |---|---|---| | 400 | `invalid_request`、`unknown_parameter`、`unsupported_model`、`reference_unreadable` | 按 `error.param` 修正,不扣费。 | | 403 | `insufficient_user_quota` | 余额不足,不扣费。 | | 409 | `idempotency_conflict`、`idempotency_in_progress` | 同一个 Key 换了内容 / 首次请求还在处理。 | | 5xx | `internal_error` | 稍后重试。 | ### 请求 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-1024" \ -d '{ "model": "gemini-3-pro-image", "prompt": "雨夜霓虹街道,电影感", "resolution": "2K", "aspect_ratio": "16:9" }' ``` ### 响应 202 ```json { "id": "task_8KqZ3xLm", "object": "image.task", "status": "queued", "model": "gemini-3-pro-image", "created_at": 1764580000, "started_at": null, "completed_at": null, "images": [], "usage": null, "billing": null, "error": null } ``` ### 错误 400 ```json { "error": { "code": "unknown_parameter", "message": "unknown parameter: qualty", "param": "qualty", "retryable": false } } ``` ## 查询任务 `GET /v2/images/{id}` 批量查询:`GET /v2/images?ids=a,b`,最多 50 个,返回 `{"object": "list", "data": [...]}`。 ### 任务对象 | 字段 | 说明 | |---|---| | `status` | `queued`、`running`、`succeeded`、`failed`。 | | `images[]` | `url` 或 `b64_json`,以及 `mime_type`、`width`、`height`。 | | `usage` | `images` 实际张数,`requested` 请求张数;成功时另有上游报告的 `input_tokens`、`output_tokens`(含图像输出)和 `image_output_tokens`,按张计价的模型可能为 0。 | | `billing` | 任务结束后的实际扣费:`amount`(已乘分组倍率)、`currency`、`quota`(额度)。失败退款后为 0;未结束时为 `null`。 | | `error` | 失败时为 `{code, message, retryable}`。 | 结果返回 `url` 还是 `b64_json`,由令牌的「结果存储」设置决定。 ### 失败原因 失败任务一律全额退款。`retryable` 为 `true` 的可以原样重新提交。与上游有关的失败,`error.message` 是从上游响应中原样提取的错误字段(如 `finishReason`、`blockReason`、`error.message`),便于排查。 | error.code | 说明 | retryable | |---|---|---| | `no_image_generated` | 模型未出图(如安全拦截) | 是 | | `upstream_unavailable` | 上游繁忙 | 是 | | `storage_failed` | 结果保存失败 | 是 | | `interrupted`、`timeout` | 服务中断或超时 | 是 | | `content_blocked` | 内容审核拒绝 | 否 | | `upstream_rejected` | 上游拒绝参数 | 否 | | `reference_unreadable` | 参考图无法读取 | 否 | | `generation_failed` | 其他错误 | 否 | ### 请求 ```bash curl -X GET https://api.o1key.com/v2/images/task_8KqZ3xLm \ -H "Authorization: Bearer $API_KEY" ``` ### 成功 200 ```json { "id": "task_8KqZ3xLm", "object": "image.task", "status": "succeeded", "model": "gemini-3-pro-image", "created_at": 1764580000, "started_at": 1764580001, "completed_at": 1764580041, "images": [ {"url": "https://.../task_8KqZ3xLm-0.png", "mime_type": "image/png"} ], "usage": { "images": 1, "requested": 1, "input_tokens": 12, "output_tokens": 1329, "image_output_tokens": 1120 }, "billing": {"amount": 0.821592, "currency": "CNY", "quota": 410796}, "error": null } ``` ### 失败 200 ```json { "id": "task_8KqZ3xLm", "status": "failed", "images": [], "usage": {"images": 0, "requested": 1}, "billing": {"amount": 0, "currency": "CNY", "quota": 0}, "error": { "code": "no_image_generated", "message": "finishReason=IMAGE_SAFETY; finishMessage=Unable to show the generated image.", "retryable": true } } ``` ## 可用模型 `GET /v2/image/models` 返回当前令牌可用的图片模型,以及各自的 `max_images`、`resolutions`、`aspect_ratios`、`accepts_pixel_size`、`qualities`、`output_formats`、`provider_options`。 ### 请求 ```bash curl -X GET https://api.o1key.com/v2/image/models \ -H "Authorization: Bearer $API_KEY" ``` ### 响应 200 ```json { "object": "list", "data": [ { "id": "gemini-3-pro-image", "family": "gemini", "max_images": 1, "resolutions": ["1K", "2K", "4K"], "aspect_ratios": ["1:1", "16:9", "9:16", "..."], "accepts_pixel_size": false, "provider_option_key": "gemini", "provider_options": ["response_modalities", "thinking_level", "..."] } ] } ``` --- # GPT Image 文生图与参考图编辑,支持透明背景;2.6 另支持 SVG、GIF 和标注图编辑。 ## 提交 GPT Image 任务 `POST /v2/images` 提交、查询和错误码见 [调用方式](/docs/image-v2.md)。本页只列 GPT Image 的模型和参数。 ### 模型 | 系列 | 特价 | 优质 | 企业 | |---|---|---|---| | 2.6 Sunburst | `gpt-image-2.6-sunburst-sp` | `gpt-image-2.6-sunburst-sd` | `gpt-image-2.6-sunburst` | | 2.6 Flare | `gpt-image-2.6-flare-sp` | `gpt-image-2.6-flare-sd` | `gpt-image-2.6-flare` | | 2.5 Sunburst | `gpt-image-2.5-sunburst-sp` | `gpt-image-2.5-sunburst-sd` | `gpt-image-2.5-sunburst` | | 2.5 Flare | `gpt-image-2.5-flare-sp` | `gpt-image-2.5-flare-sd` | `gpt-image-2.5-flare` | | 2 | `gpt-image-2-c-sp` | `gpt-image-2-c-sd` | `gpt-image-2` | Sunburst 偏精修,Flare 偏快速。 ### 能力差异 | 能力 | 2 | 2.5 | 2.6 | |---|---|---|---| | `quality` 为 `xhigh` / `max` | — | 支持 | 支持 | | `complexity` | — | — | 支持 | | `markup` 标注图编辑 | — | 支持 | 支持 | | `output.format` 为 `svg` / `gif` | — | — | 支持 | | `input_fidelity` | 不要传 | 可传 | 可传 | ### 参数 | 字段 | 说明 | |---|---| | `images` | 第一张是编辑目标。 | | `n` | 1–128。 | | `size` | `auto` 或 `WIDTHxHEIGHT`,见下表。 | | `quality` | `low`、`medium`、`high`、`auto`;2.5 起另有 `xhigh`、`max`。 | | `output.format` | `png`(默认)、`jpeg`、`webp`;2.6 另有 `svg`(仅生成,`n` 须为 1)、`gif`。 | | `output.compression` | 0–100,仅 `jpeg`、`webp`。 | | `output.background` | `auto`、`transparent`、`opaque`;透明需 `png` 或 `webp`。 | | `provider_options.openai.moderation` | `auto` 或 `low`。 | | `provider_options.openai.input_fidelity` | 2.5 起可传;GPT Image 2 不要传。 | | `provider_options.openai.complexity` | 仅 2.6:`low`、`medium`、`high`(默认)。 | | `provider_options.openai.mask` | 局部重绘蒙版 `{"image_url"}`,需 alpha 通道,作用于第一张参考图;与 `markup` 互斥。 | | `provider_options.openai.markup` | 2.5 起:标注图 `{"image_url"}`,与原图等大、透明底。 | | `provider_options.openai.frame_count` | 仅 GIF:2–64,默认 9。 | | `provider_options.openai.frame_duration_ms` | 仅 GIF:20–2000,默认 200。 | ### 常用尺寸 | 档位 | 正方形 | 横版 | 竖版 | |---|---|---|---| | 自动 | `auto` | | | | 1K | `1024x1024` | `1536x1024`、`1360x1024`、`1824x1024` | `1024x1536`、`1024x1360`、`1024x1824` | | 2K | `2048x2048` | `3072x2048`、`2736x2048`、`3648x2048` | `2048x3072`、`2048x2736`、`2048x3648` | | 4K | `2880x2880` | `3504x2336`、`3264x2448`、`3840x2160` | `2336x3504`、`2448x3264`、`2160x3840` | 自定义尺寸:小写 `x`;宽高为 16 的倍数,比例 1:3–3:1,单边 ≤ 3840,总像素 655,360–8,294,400,超出返回 400。 SVG / GIF(仅 2.6):SVG 只能生成、不能带参考图,`n` 为 1;GIF 生成和编辑都可用。两者都不支持 `output.compression`。 ### 请求示例 #### 文生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2.6-sunburst-sp", "prompt": "生成一枚蓝色玻璃徽章", "size": "1024x1024", "quality": "max", "output": { "format": "png", "background": "transparent" }, "provider_options": { "openai": { "complexity": "high", "moderation": "low" } } }' ``` #### 图生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2.6-flare-sd", "prompt": "保留主体结构,将材质改为磨砂金属", "images": [ { "url": "https://upload.o1key.com/uploads/product.png" } ], "size": "1536x1024", "quality": "xhigh", "output": { "format": "png" } }' ``` 第一张参考图是编辑目标;也可以用 `{"data": "Base64", "mime_type": "image/png"}` 直接传图。 #### 标注图编辑 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2.6-sunburst", "prompt": "把红圈标注的花瓶改成青瓷,其余部分保持不变", "images": [ { "url": "https://upload.o1key.com/uploads/room.png" } ], "quality": "high", "provider_options": { "openai": { "markup": { "image_url": "https://upload.o1key.com/uploads/room-markup.png" } } } }' ``` 标注层是独立透明 PNG,与第一张参考图等大,不要叠在原图上。 #### GIF 动图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2.6-flare", "prompt": "一盏灯笼轻微摇曳,循环回到起始姿态", "size": "1024x1024", "quality": "medium", "output": { "format": "gif" }, "provider_options": { "openai": { "frame_count": 9, "frame_duration_ms": 200 } } }' ``` 9 帧 × 200ms ≈ 1.8 秒循环。带参考静帧时把图片放进 `images`。 #### SVG 矢量 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2.6-sunburst", "prompt": "一个极简线性风格的云朵图标,单色", "size": "1024x1024", "quality": "high", "output": { "format": "svg" } }' ``` 仅生成,不能带参考图,`n` 为 1。 --- # Nano Banana(Gemini) Gemini 原生图片模型:文生图、参考图编辑与多图融合,每次 1 张。 ## 提交 Nano Banana 任务 `POST /v2/images` 提交、查询和错误码见 [调用方式](/docs/image-v2.md)。本页只列 Nano Banana 的模型和参数。 ### 模型 | 系列 | 特价 | 优质 | 企业 | |---|---|---|---| | Nano Banana 2.1 | `gemini-nano-banana-2.1-sp` | `gemini-nano-banana-2.1-sd` | `gemini-nano-banana-2.1` | | Gemini 3 Pro Image | `gemini-3-pro-image-c-sp` | `gemini-3-pro-image-c-sd` | `gemini-3-pro-image` | | Gemini 3.1 Flash Image | `gemini-3.1-flash-image-c-sp` | `gemini-3.1-flash-image-c-sd` | `gemini-3.1-flash-image` | ### 参数 | 字段 | 说明 | |---|---| | `n` | 只能为 1。 | | `resolution` | `1K`(默认)、`2K`、`4K`,大写 K。不支持像素 `size`。 | | `aspect_ratio` | `1:1`、`2:3`、`3:2`、`3:4`、`4:3`、`4:5`、`5:4`、`9:16`、`16:9`、`21:9`;3.1 Flash 另有 `1:4`、`1:8`、`4:1`、`8:1`。省略时有参考图沿用其比例,否则 1:1。 | | `provider_options.gemini.response_modalities` | `["IMAGE"]` 或 `["TEXT","IMAGE"]`。 | | `provider_options.gemini.thinking_level` | 思考深度,取值见下方「思考」。 | | `provider_options.gemini.include_thoughts` | 是否让上游返回思考内容,见下方「思考」。 | | `provider_options.gemini.media_resolution` | 参考图的解析精度,如 `MEDIA_RESOLUTION_HIGH`;越高越能保留参考图细节,输入 token 也越多。 | | `provider_options.gemini.google_search` | `true` 启用 Google 搜索增强,适合需要实时信息的画面(如天气、新闻)。 | 参考图:URL 须在任务完成前保持公网可访问;Base64 参考图合计不超过 20MiB。 ### 思考 这些模型出图前会先“思考”构图与逻辑,思考越深,画面越贴合复杂指令,耗时也越长。 | 模型 | `thinking_level` | 默认 | 说明 | |---|---|---|---| | Gemini 3.1 Flash Image | `minimal`、`high` | `minimal` | `minimal` 延迟最低,但不等于不思考;`high` 适合多元素、强逻辑的画面。 | | Nano Banana 2.1 | `minimal`、`medium`、`high` | 上游默认 | 三档依次加深。 | | Gemini 3 Pro Image | 不可调 | 固定 `high` | 始终深度思考,不要传 `thinking_level`。 | | `include_thoughts` | 效果 | |---|---| | 不传 / `false` | 上游不返回思考内容,但思考仍在进行。 | | `true` | 上游会返回思考文字和最多 2 张中间草图。任务结果只返回最终图片。 | 计费:思考产生的 token 计入 `usage.output_tokens`。按 token 计价的模型,思考越深费用越高;按次计价的 `-sp` 模型不受影响。 ### 请求示例 #### 文生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-nano-banana-2.1-sp", "prompt": "16:9 的极简科技产品海报", "resolution": "2K", "aspect_ratio": "16:9", "provider_options": { "gemini": { "response_modalities": [ "IMAGE" ] } } }' ``` #### 图生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-3-pro-image", "prompt": "把两张图里的人物放进同一个咖啡馆场景,保持各自的外貌", "images": [ { "url": "https://upload.o1key.com/uploads/person-a.png" }, { "url": "https://upload.o1key.com/uploads/person-b.png" } ], "resolution": "2K", "aspect_ratio": "4:3" }' ``` 多张参考图可做融合;省略 `aspect_ratio` 时沿用参考图比例。 --- # Seedream 单图生成、参考图编辑与多图融合;5.0 Pro 还支持图层拆分。 ## 提交 Seedream 任务 `POST /v2/images` 提交、查询和错误码见 [调用方式](/docs/image-v2.md)。本页只列 Seedream 的模型和参数。 ### 模型 | 系列 | 模型名称 | |---|---| | Seedream 5.0 Pro | `dola-seedream-5-0-pro-260628-ep` | | Seedream 5.5 | `dola-seedream-5-5-261028-ep` | ### 参数 | 字段 | 说明 | |---|---| | `n` | 只能为 1。 | | `images` | 最多 10 张;JPEG、PNG、WebP、BMP、TIFF、GIF、HEIC、HEIF,每张 ≤ 30MB。 | | `resolution` | 仅 5.0 Pro:`1K` 或 `2K`。 | | `size` | `WIDTHxHEIGHT`,总像素 921,600–4,624,220,宽高比 1:16–16:1。5.5 只用像素尺寸,例如 `2048x2048`、`2688x1512`。 | | `output.format` | `png` 或 `jpeg`。 | | `provider_options.seedream.watermark` | `true` 添加“AI 生成”水印。 | | `provider_options.seedream.layer_decomposition` | 仅 5.0 Pro:把 1 张输入图拆成 1 张底图和最多 16 个透明图层;`images` 必须正好 1 张,`prompt` 可省略,尺寸限 `auto`、`1K`、`1.5K`、`2K`。图层带 `z_index`、`bounding_box`、`name`、`description`;任一图层失败则整个任务失败。 | ### 常用尺寸(5.0 Pro) | 宽高比 | 1K | 2K | |---|---|---| | 1:1 | `1024x1024` | `2048x2048` | | 4:3 | `1152x864` | `2368x1776` | | 3:4 | `864x1152` | `1776x2368` | | 16:9 | `1424x800` | `2816x1584` | | 9:16 | `800x1424` | `1584x2816` | | 3:2 | `1248x832` | `2496x1664` | | 2:3 | `832x1248` | `1664x2496` | | 21:9 | `1568x672` | `3136x1344` | 可直接用 `size` 传上表像素值。 ### 计费 | 模型 | ≤ 261 万像素 | > 261 万像素 | 参考图 | |---|---|---|---| | 5.0 Pro | ¥0.30 / 张 | ¥0.60 / 张 | 第 2 张起每张 ¥0.02 | | 5.0 Pro 图层拆分 | ¥0.15 / 张 | ¥0.30 / 张 | 按返回的每张图(含底图)计费 | | 5.5 | ¥0.14 / 张 | ¥0.245 / 张 | 每张 ¥0.056 | 最终价格乘以令牌所属分组的倍率。 ### 请求示例 #### 文生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "dola-seedream-5-0-pro-260628-ep", "prompt": "生成一张 16:9 横版科技产品海报", "size": "2816x1584", "output": { "format": "png" }, "provider_options": { "seedream": { "watermark": false } } }' ``` #### 多图融合 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "dola-seedream-5-0-pro-260628-ep", "prompt": "保留图一人物的姿势,换上图二的套装", "images": [ { "url": "https://upload.o1key.com/uploads/subject.png" }, { "url": "https://upload.o1key.com/uploads/outfit.png" } ], "resolution": "2K", "provider_options": { "seedream": { "watermark": false } } }' ``` #### 图层拆分 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "dola-seedream-5-0-pro-260628-ep", "prompt": "将主体、背景和文字拆分为可独立编辑的图层", "images": [ { "url": "https://upload.o1key.com/uploads/poster.png" } ], "resolution": "2K", "provider_options": { "seedream": { "layer_decomposition": true } } }' ``` 结果 `images` 依次为底图和各图层,按 `z_index` 排序。 #### 5.5 图生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "dola-seedream-5-5-261028-ep", "prompt": "保持构图,改成水彩风格", "images": [ { "url": "https://upload.o1key.com/uploads/scene.png" } ], "size": "2688x1512" }' ``` --- # Midjourney Midjourney v8.2:画幅、画质等设置写在提示词末尾,每次返回 4 张图,按次计费。 ## 提交 Midjourney 任务 `POST /v2/images` 提交、查询和错误码见 [调用方式](/docs/image-v2.md)。本页只列 Midjourney 的写法。 ### 参数 | 字段 | 说明 | |---|---| | `model` | `mj-v8.2`。 | | `prompt` | 提示词,设置写在末尾,例如 `A cat --ar 16:9 --q 2`。 | | `images` | 最多 1 张(JPEG、PNG、WebP,≤ 7MB)。多张内容参考把 URL 写在 `prompt` 开头。 | 不支持 `n`、尺寸、画质、`output` 和 `provider_options`。 ### 提示词参数 | 参数 | 作用 | 取值 | |---|---|---| | `--ar` | 画面比例 | 如 `16:9`,默认 `1:1` | | `--q` | 渲染质量 | `1`–`4` | | `--hd` | 高清档,长边约 2048(最高 2K) | 开关 | | `--iw` | 内容参考权重 | 0–3,默认 1 | | `--sref` / `--sw` | 风格参考图与权重 | URL;0–1000,默认 100 | | `--raw` | 弱化美化,更写实 | 开关 | | `--s` | 风格化强度 | 0–1000,默认 250 | | `--c` | 四张差异度 | 0–100 | | `--seed` | 随机种子 | 整数 | | `--no` | 排除元素 | 关键词 | | `--tile` | 无缝平铺 | 开关 | | `--weird` | 怪异度 | 0–3000 | | `--exp` | 影调增强 | 0–100 | | `--draft` | 草图模式,张数不固定、边长约 512 | 开关 | 不支持 `--stop`、`::` 分段加权、`--cref`、`--oref`。 ### 输出尺寸 | `--ar` | 标准档 | 加 `--hd` | |---|---|---| | 1:1 | 1024 × 1024 | 2048 × 2048 | | 16:9 | 1456 × 816 | 2944 × 1648 | | 9:16 | 816 × 1456 | 1648 × 2944 | | 4:5 | 960 × 1200 | 约 1920 × 2400 | | 3:2 | 1344 × 896 | 约 2688 × 1792 | | 4:3 | 1232 × 928 | 约 2464 × 1856 | 最高 2K,不支持 4K。 ### 计费 按次计费,一次任务 4 张图只扣一次:标准档(长边约 1024)与高清档(`--hd`)分别计价。提交时按高清档预扣,完成后按实际档位结算并退回差额。价格乘以令牌所属分组的倍率。 ### 请求示例 #### 文生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "mj-v8.2", "prompt": "A misty mountain lake at sunrise --ar 16:9 --q 2" }' ``` #### 高清档 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "mj-v8.2", "prompt": "A misty mountain lake at sunrise --ar 16:9 --hd" }' ``` 长边约 2048,按高清档计费。 #### 图生图 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "mj-v8.2", "prompt": "Replace the outfit with a black knit cardigan --ar 4:5 --iw 2 --raw", "images": [ { "url": "https://upload.o1key.com/uploads/portrait.png" } ] }' ``` #### 多参考 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "mj-v8.2", "prompt": "https://upload.o1key.com/uploads/a.jpg https://upload.o1key.com/uploads/b.jpg a fashion editorial --iw 1.5 --sref https://upload.o1key.com/uploads/style.jpg --sw 80" }' ``` 多张内容参考写在 `prompt` 开头,`images` 留空。 #### 草图模式 ```bash curl -X POST https://api.o1key.com/v2/images \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "mj-v8.2", "prompt": "A cozy reading nook, warm light --draft" }' ``` 张数不固定,边长约 512。 --- # Kling IMAGE 4.0 可灵 Image 4.0 的单图、组图和长图(电商详情页、网页设计)。路径、请求体和响应都与可灵官方一致,只需把 Base URL 和 API Key 换成本站。客户端使用任务 ID 轮询结果,提交时请省略 `callback_url`。 ## Agent 调用规则 1. 普通图片或组图 POST `/image-generation/kling-4.0`;长图 POST `/long-image-generation/kling-4.0`。请求体不传 `model`,记录 `data.id`。 2. `contents` 必须且只能有一条 `prompt`。分辨率用小写:图片 `2k`/`4k`/`8k`,长图 `1k`/`2k`。 3. 每 5–10 秒 GET `/tasks?task_ids={id}`,`submitted` 或 `processing` 时继续查询。 4. `succeeded`:把每条 `outputs[].url` 返回给用户,提醒链接有时效。 5. `failed`:把 `message` 告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 用可灵 Image 4.0 生成图片:一次出 1–9 张独立图片,或出一组人物、风格连贯的组图;也可以生成一整张电商详情页或网页设计长图。用法和可灵官方完全一样,已经按官方文档写好代码的,只改 Base URL 和 API Key。 ### 你需要提供的信息 - **做什么**:普通图片和组图用 `image-generation`;长图用 `long-image-generation`。路径末尾都是 `kling-4.0`。 - **想要什么画面**:`contents` 里放一条 `{"type":"prompt","text":"…"}`,可再加参考图,提示词里用 `@id` 引用。 - **出几张、多大(可选)**:`settings.n` 或 `settings.series_amount`;`settings.resolution`;`settings.aspect_ratio`。 - **长图类型**:`settings.skill`:电商详情页 `ecommerce` 或网页设计 `webpage`。 ### 怎么拿到结果 - **状态**:`submitted`、`processing` 继续等待;`succeeded` 成功;`failed` 失败。 - **图片地址**:`data[].outputs[].url`,每张图一条,PNG 格式。链接有时效,请及时保存。 ## 路径、参数与价格 ### 路径 | 类型 | 提交 | 按任务 ID 查询 | |---|---|---| | 单图 / 组图 | `POST /image-generation/kling-4.0` | `GET /image-generation/kling-4.0/{task_id}` | | 长图 | `POST /long-image-generation/kling-4.0` | `GET /long-image-generation/kling-4.0/{task_id}` | | 批量查询 | `GET /tasks?task_ids=id1,id2` 或 `GET /tasks?external_task_ids=a,b`,与视频共用 | | - 请求头:`Authorization: Bearer `,`Content-Type: application/json`。 - 路径末尾写 `kling-4.0`(可灵官方写法)或 `kling-image-4.0` 都可以,指的都是图片模型 `kling-image-4.0`,和视频的 `kling-4.0` 是两个产品。你的 API Key 所在分组需要开通 `kling-image-4.0`。 - 响应与可灵官方一致:`{code, message, request_id, data}`,出错时 `code` 为可灵业务码(例如参数错误 `1201`、Key 无效 `1000`)。 ### 通用字段 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `contents` | array | 是 | 素材列表。必须且只能有一条 `{"type":"prompt","text":"…"}`。图片素材写 `{"type":"…","url":"…","id":"…"}`,`url` 可以是图片链接或 Base64(JPG / PNG,≤ 30 MB,宽高 ≥ 300 px,宽高比 2:5 到 5:2),建议用链接。 | | `options.external_task_id` | string | 否 | 自定义任务 ID,不覆盖 `data.id`,同一账号下必须唯一。用 `GET /tasks?external_task_ids=` 查询。 | | `options.watermark_info.enabled` | boolean | 否 | 是否同时生成带水印结果,默认 `false`。 | > 不支持 `options.callback_url`(传了会返回 400),请轮询查询接口。素材链接由可灵在中国大陆以外下载,需要公网可访问、无需登录。 ### 价格 按生成的张数计费,另按输入的参考图(每张 `refer_image`、`style_refer_image`、`subject_refer_image`)计费。组图 `series_amount` 为 `auto` 时,提交时按 10 张预扣,完成后按实际张数结算。失败的任务不计费。当前售价见[模型定价](/pricing)中的 `kling-image-4.0`。 | 类型 | 规格 | 官方价(每张) | |---|---|---| | 单图 / 组图 | 2K / 4K / 8K | ¥0.4 / ¥0.6 / ¥1.0 | | 长图 · 网页设计 | 1K / 2K | ¥3.5 / ¥3.8 | | 长图 · 电商详情页 · 短 | 1K / 2K | ¥1.5 / ¥1.8 | | 长图 · 电商详情页 · 中 | 1K / 2K | ¥3.0 / ¥3.5 | | 长图 · 电商详情页 · 长 | 1K / 2K | ¥5.0 / ¥5.5 | | 参考图 | 每张 | ¥0.02 | 实际扣费以你所在分组的倍率为准。可灵说明:[图片生成](https://kling.ai/document-api/api/image/4-0/image-generation)、[长图生成](https://kling.ai/document-api/api/image/4-0/long-image-generation)。 ### 创建响应 · 200 ```json { "code": 0, "message": "SUCCEED", "request_id": "req_xxxxxxxxxx", "data": { "id": "task_xxxxxxxxxx", "status": "submitted", "create_time": 1795834453436, "update_time": 1795834453436, "external_id": "my-order-0001" } } ``` 用 `data.id` 查询。时间戳单位为毫秒。 ### 错误响应 · 400 ```json { "code": 1201, "message": "settings.resolution must be one of 2k, 4k, 8k", "request_id": "req_xxxxxxxxxx" } ``` ## 单图与组图 `POST /image-generation/kling-4.0` | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `contents[].type` | string | 是 | `prompt`(一条,必填);`refer_image` 参考图,最多 10 张。 | | `settings.result_type` | string | 否 | `single`(默认)生成独立图片;`series` 生成人物、风格连贯的组图。 | | `settings.n` | integer | 否 | `single` 时生成几张,1–9,默认 1。 | | `settings.series_amount` | integer / string | 否 | `series` 时的张数,2–10 或 `"auto"`(由可灵决定 2–10 张),默认 4。 | | `settings.resolution` | string | 否 | `2k`(默认)、`4k`、`8k`,必须小写。 | | `settings.aspect_ratio` | string | 否 | `auto`(默认)、`16:9`、`9:16`、`1:1`、`4:3`、`3:4`、`3:2`、`2:3`、`21:9`。 | 可灵官方的参考主体(`element`)本站暂不支持,请用 `refer_image` 传参考图。 ### 请求示例 · 参考一张图生成单图 ```bash curl https://api.o1key.com/image-generation/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "以 @dog 中的小狗为参考,生成一张三维动画风格的角色海报,暖色灯光,背景简洁。"}, {"type": "refer_image", "url": "https://cdn.example.com/dog.png", "id": "dog"} ], "settings": {"result_type": "single", "n": 1, "resolution": "2k", "aspect_ratio": "1:1"} }' ``` ### 请求示例 · 4 张 4K 组图 ```bash curl https://api.o1key.com/image-generation/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "以 @dog 为主角生成四张连贯的三维动画故事图:走进咖啡馆、在窗边落座、闻咖啡香、在门口告别。"}, {"type": "refer_image", "url": "https://cdn.example.com/dog.png", "id": "dog"} ], "settings": {"result_type": "series", "series_amount": 4, "resolution": "4k", "aspect_ratio": "3:4"}, "options": {"external_task_id": "my-order-0001"} }' ``` ## 长图(电商详情页 / 网页设计) `POST /long-image-generation/kling-4.0` 每个任务生成**一张完整长图**,不支持指定张数。 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `settings.skill` | string | 是 | `ecommerce` 电商详情页;`webpage` 网页设计。 | | `contents[].type` | string | 是 | `prompt`(一条,必填)。`ecommerce`:必须有 1–3 张 `refer_image`。`webpage`:可选一张 `style_refer_image`(参考视觉和排版风格)和一张 `subject_refer_image`(围绕这个主体设计),不能用 `refer_image`。不支持 `element`。 | | `settings.length` | string | 否 | 仅 `ecommerce`:`short`(约 2–5 个模块)、`medium`(默认,6–10)、`long`(11–18)。 | | `settings.resolution` | string | 否 | `1k`(默认)或 `2k`。 | 提示词长度:纯英文最多 166,000 字符,纯非英文最多 71,000 字符;混合输入须满足 E/166000 + N/71000 ≤ 1。长图生成通常比普通图片慢。 ### 请求示例 · 电商详情页 ```bash curl https://api.o1key.com/long-image-generation/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "为 @product 中的咖啡机设计电商详情页长图,包含主视觉、核心卖点和使用场景;仅使用提供的商品事实。"}, {"type": "refer_image", "url": "https://cdn.example.com/coffee-machine.png", "id": "product"} ], "settings": {"skill": "ecommerce", "length": "medium", "resolution": "2k"} }' ``` ### 请求示例 · 网页设计 ```bash curl https://api.o1key.com/long-image-generation/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "为一家精品咖啡店设计官网首页,参考 @style 的排版,突出 @bean。"}, {"type": "style_refer_image", "url": "https://cdn.example.com/style.png", "id": "style"}, {"type": "subject_refer_image", "url": "https://cdn.example.com/bean.png", "id": "bean"} ], "settings": {"skill": "webpage", "resolution": "1k"} }' ``` ## 查询图片任务 `GET /tasks?task_ids={task_id}` | 参数 | 说明 | |---|---| | `task_ids` | 任务 ID,逗号分隔,每次最多 50 个。 | | `external_task_ids` | 自定义任务 ID,逗号分隔。不能与 `task_ids` 同时使用。 | | 字段 | 说明 | |---|---| | `data` | 任务数组。不存在或不属于你的任务不会出现在数组里(200 + 空数组)。 | | `status` | `submitted`、`processing`、`succeeded`、`failed`。 | | `outputs[]` | 每张图一条,`type` 为 `image`,各有自己的 `url`,顺序与可灵一致。组图另有 `group_id`。没有 `duration` 和 `usage`。 | | `message` | 失败原因,例如内容审核未通过。 | ### 请求示例 ```bash curl "https://api.o1key.com/tasks?task_ids=task_xxxxxxxxxx" \ -H "Authorization: Bearer $API_KEY" ``` ### 成功响应 · 200 ```json { "code": 0, "message": "SUCCEED", "request_id": "req_xxxxxxxxxx", "data": [ { "id": "task_xxxxxxxxxx", "status": "succeeded", "message": "", "create_time": 1795834453065, "update_time": 1795834485555, "external_id": "my-order-0001", "outputs": [ {"type": "image", "url": "https://cdn.example.com/image-1.png"}, {"type": "image", "url": "https://cdn.example.com/image-2.png"} ] } ] } ``` ID、链接仅为示例。也可以用 `GET /image-generation/kling-4.0/{task_id}` 查询单个任务,返回同一结构。 --- # Seedance 素材与视频 提交视频任务,保存任务 ID,再查询结果。参考素材可直接传 URL,需要复用时再预上传。 ## Agent 调用规则 1. POST `/v1/video/generations`,`content` 至少包含一项非空 `text`,记录返回的本站任务 ID(`task_...`)。 2. 每 5–10 秒 GET `/v1/video/generations/{task_id}`。`in_progress` 包括素材准备,继续查询即可。 3. `completed`:把 `result_url` 返回给用户,提醒链接约 24 小时有效。 4. `failed`:把 `error.message` 告诉用户,不要自动重试。 5. 创建请求超时时先查询已有任务,避免重复提交和重复计费。缺少 `model` 或提示词时,先向用户确认。 ## 简明说明 ### 这个接口做什么? 用 Seedance 生成视频:可以只写文字,也可以加参考图、参考视频和音频。参考素材直接传公网 URL 即可,需要反复使用同一素材时再预先上传成素材句柄。接口先返回**任务编号**,之后用编号查询。 ### 你需要提供的信息 - **用哪个模型**:`model`,例如 `doubao-seedance-2-0`,可选列表见完整参考。 - **想要什么画面**:`content` 数组,至少一项非空 `text`,第一条文本作为提示词;素材也放在这里。 - **时长、分辨率、比例(可选)**:`duration`、`resolution`、`ratio`。 ### 怎么拿到结果 - **状态**:`queued`、`in_progress` 继续等待;`completed` 成功;`failed` 失败。 - **视频地址**:`result_url`(同 `metadata.url`)。链接通常 24 小时有效,请及时转存。 ## Seedance 多模态视频生成 `POST /v1/video/generations` > **接入步骤**:使用本站 API Key 提交请求 → 保存响应中的 `id` / `task_id` → 调用查询接口,直到 `completed` 或 `failed`。 下表适用于 Doubao MAX 与 Dreamina MAX。新接入请使用简写模型名;实际可用模型以本站 `GET /v1/models` 返回为准。 ### 顶层参数 | 字段 | 必填 | 类型 | 支持值与说明 | |---|---|---|---| | `model` | 是 | string | 模型名称,取值见下方模型表 | | `content` | 是 | array | 有序多模态数组,至少包含一项非空 `text`;第一条非空文本作为提示词 | | `duration` | 否 | integer | 单位秒,默认 `5`;2.0 / fast / mini 为 `4–15`,2.5 为 `4–30`;均支持 `-1`。2.5 编辑任务必须显式传 `-1`,输出时长基本跟随待编辑视频;其他任务使用 `-1` 时由模型自选时长 | | `resolution` | 否 | string | 默认 `720p`;具体范围见模型表 | | `ratio` | 否 | string | `16:9`、`4:3`、`1:1`、`3:4`、`9:16`、`21:9`、`adaptive`;默认 `adaptive`。接受别名 `aspect_ratio`,同时填写时以非空 `ratio` 为准;首尾帧模式比例跟随图片。2.5 的首帧 / 首尾帧、编辑、延长任务仅支持 `adaptive` | | `generate_audio` | 否 | boolean | 是否生成同步单声道音频,默认 `true`;显式 `false` 会转发 | | `watermark` | 否 | boolean | 是否添加“AI 生成”水印,默认 `false`;Doubao MAX 和 Dreamina MAX / HC 均支持 | | `seed` | 否 | integer | `[-1, 2147483647]`,默认 `-1`(随机);`0` 是有效种子。相同种子结果相似,不保证完全一致 | | `return_last_frame` | 否 | boolean | 默认 `false`;设为 `true` 后,完成时从 `metadata.last_frame_url` 读取尾帧 PNG 地址 | | `callback_url` | 否 | string | 任务状态变化时接收 POST 通知的地址;回调格式及关联方式见下方说明 | | `execution_expires_after` | 否 | integer | 上游未完成任务的过期秒数,`[3600, 259200]`,默认 `172800`;本站任务超时策略仍独立生效 | | `output_format` | 否 | string | 仅 2.5:`mp4`(默认)或 `mov` | | `omni_reference_task_type` | 否 | string | 仅 2.5:`auto`(默认)、`reference`、`edit`、`extend`;用于引导参考、编辑或延长模式,并校验对应参数限制。提示词意图仍须与所选模式一致 | 可选参数未填写时使用上游默认值。`false` 和 `0` 使用 JSON 原生类型,不能写成字符串;未列出的扩展字段不保证转发。 ### 模型与分辨率 主推简写模型名(推荐新接入使用): | 模型 | 支持分辨率 | 时长 | |---|---|---| | `dreamina-seedance-2-0` | `480p`、`720p`、`1080p`、`4k` | 4–15 秒或 -1 | | `dreamina-seedance-2-0-fast` | `480p`、`720p` | 4–15 秒或 -1 | | `dreamina-seedance-2-0-mini` | `480p`、`720p` | 4–15 秒或 -1 | | `dreamina-seedance-2-5` | `480p`、`720p`、`1080p` | 4–30 秒或 -1 | | `doubao-seedance-2-0` | `480p`、`720p`、`1080p`、`4k` | 4–15 秒或 -1 | | `doubao-seedance-2-0-fast` | `480p`、`720p` | 4–15 秒或 -1 | | `doubao-seedance-2-0-mini` | `480p`、`720p` | 4–15 秒或 -1 | | `doubao-seedance-2-5` | `480p`、`720p`、`1080p` | 4–30 秒或 -1 | 国内 Doubao 长名别名仍可用:`doubao-seedance-2-0-260128-max`、`doubao-seedance-2-0-fast-260128-max`、`doubao-seedance-2-0-mini-260615-max`、`doubao-seedance-2-5-260628-max`。 ### 兼容旧名(Dreamina `-hc`) 以下名称保留给老客户兼容,能力与上方同档简写一致;新接入请使用不带 `-hc` 的简写。 | 兼容旧名 | 对应简写 | 支持分辨率 | 时长 | |---|---|---|---| | `dreamina-seedance-2-0-hc` | `dreamina-seedance-2-0` | `480p`、`720p`、`1080p`、`4k` | 4–15 秒或 -1 | | `dreamina-seedance-2-0-fast-hc` | `dreamina-seedance-2-0-fast` | `480p`、`720p` | 4–15 秒或 -1 | | `dreamina-seedance-2-0-mini-hc` | `dreamina-seedance-2-0-mini` | `480p`、`720p` | 4–15 秒或 -1 | | `dreamina-seedance-2-5-hc` | `dreamina-seedance-2-5` | `480p`、`720p`、`1080p` | 4–30 秒或 -1 | ### `content` 多模态项目 | `type` | 字段 | `role` | 说明 | |---|---|---|---| | `text` | `text` | 不填 | 提示词,例如 `{"type":"text","text":"..."}` | | `image_url` | `image_url.url` | `first_frame` | 首帧图:首帧生视频时显式填写此角色;比例跟随图片 | | `image_url` | `image_url.url` | `last_frame` | 尾帧图:首尾帧生视频时使用,同时提供首帧图 | | `image_url` | `image_url.url` | `reference_image` | 参考图:省略图片角色时按参考图处理;支持公开 URL 或预上传返回的 `Ref` | | `video_url` | `video_url.url` | `reference_video` | 参考视频:支持公开 URL 或素材句柄 | | `audio_url` | `audio_url.url` | `reference_audio` | 参考音频:2.0 需同时传图片或视频;2.5 允许音频作为唯一参考素材,仍需提示词 | `@Image1` 是数组中第一张参考图,`@Video1` 是第一段参考视频,分别按出现顺序编号。本站保留素材顺序;首尾帧图不计入参考图编号。 ### 按生成场景选择参数 以下六种场景均调用 `POST /v1/video/generations`。通过 `content` 中的素材角色和 2.5 的 `omni_reference_task_type` 区分场景。 | 场景 | 请求内容 | 适用模型 | |---|---|---| | 文生视频 | 只传 `text` 提示词 | 2.0 / fast / mini / 2.5 | | 首帧视频 | 提示词 + 一张 `first_frame` 图片;2.5 的 `ratio` 仅支持 `adaptive` | 2.0 / fast / mini / 2.5 | | 首尾帧 | 提示词 + `first_frame` 和 `last_frame` 图片;2.5 的 `ratio` 仅支持 `adaptive` | 2.0 / fast / mini / 2.5 | | 全能参考 | 提示词 + 按需组合的 `reference_image` / `reference_video` / `reference_audio` | 2.0 / fast / mini / 2.5 | | 视频编辑 | 提示词 + `reference_video`;待编辑视频为 4–30 秒;设置 `omni_reference_task_type: "edit"`、`ratio: "adaptive"`、`duration: -1` | 仅 2.5 | | 视频延长 | 提示词 + `reference_video`;设置 `omni_reference_task_type: "extend"`、`ratio: "adaptive"`;`duration` 可设为 4–30 秒或 `-1` | 仅 2.5 | 2.5 编辑提示词应明确增删改意图,例如“修改 @Video1 的背景”;延长提示词应明确方向与目标,例如“向后延长 @Video1”。仅填写任务类型不能替代明确的提示词。场景限制依据 [火山引擎 Seedance 2.5 官方教程](https://docs.volcengine.com/docs/ark/seedance-2-5?lang=zh);请求仍使用本站路径、模型名和 API Key。 > 首尾帧模式不能与 `reference_*` 素材混用。`content` 中的 `last_frame` 是输入的目标结束画面;`return_last_frame: true` 用于导出生成视频的尾帧,完成后从 `metadata.last_frame_url` 读取。 ### 参考素材数量 | 素材 | 2.0 / fast / mini | 2.5 | |---|---|---| | 参考图片 | 最多 9 张 | 最多 30 张 | | 参考视频 | 最多 3 段;单段 2–15 秒,总时长 ≤ 15 秒 | 最多 10 段,总时长 ≤ 30 秒 | | 参考音频 | 最多 3 段;单段 2–15 秒,总时长 ≤ 15 秒 | 最多 10 段,总时长 ≤ 30 秒 | 图片支持 JPEG、PNG、WebP、BMP、TIFF、GIF、HEIC、HEIF,单张 < 30 MB;视频支持 MP4 / MOV,单段 ≤ 200 MB;音频支持 WAV / MP3,单段 ≤ 15 MB。图片 / 视频边长为 300–6000 px,图片宽高比为 0.4–2.5;请求体 ≤ 64 MB。 素材 URL 需公网可下载,不依赖登录、Cookie 或防盗链。带素材的请求可能先被受理,再因下载、规格或内容审核失败;请查询最终状态和 `error.message`。含真人人脸的参考素材可能被隐私审核拒绝。 ### 完成通知与任务关联 `callback_url` 会原样转发,上游直接向该地址 POST 状态通知。回调体是 `{"task": {...}}`,其中 `task.id` 是上游任务标识;本站查询接口返回 `task_...` 和 `object: "video"`。 建议在回调 URL 带上自己的业务 ID(如 `?job_id=123`),提交成功后保存业务 ID 与本站 `task_id` 的关联。收到通知后用本站任务 ID 查询确认结果;保留轮询作为兜底。 ### 按场景选择请求 使用本站 API Key,并将素材 URL 替换为自己的公网地址。HC 模型使用相同请求结构,修改 model 即可;已有素材可将对应 URL 替换为预上传返回的 Ref。 #### 文生视频 只传提示词即可生成视频,不需要参考素材。可通过 ratio 指定输出比例。 ```bash curl -X POST https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2-0-mini", "content": [ { "type": "text", "text": "明亮的厨房中,一台精致的咖啡机缓慢旋转,柔和的晨光洒在金属表面,镜头平稳推进,广告片风格。" } ], "duration": 5, "resolution": "720p", "ratio": "16:9", "generate_audio": false }' ``` #### 首帧视频 first_frame 指定视频的起始画面,比例跟随图片。本例同时导出生成视频的尾帧,完成后从 metadata.last_frame_url 读取。 ```bash curl -X POST https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2-0-mini", "content": [ { "type": "text", "text": "从输入图片的构图开始,咖啡机缓慢旋转,镜头平稳拉近,保持产品外观和厨房场景一致。" }, { "type": "image_url", "image_url": { "url": "https://your-cdn.com/first-frame.png" }, "role": "first_frame" } ], "duration": 5, "resolution": "720p", "generate_audio": false, "return_last_frame": true, "seed": 0 }' ``` #### 首尾帧 同时提供起始画面和目标结束画面,让模型生成两者之间的过渡。显式填写 first_frame / last_frame,比例跟随图片,不混入 reference_* 素材。 ```bash curl -X POST https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2-0-mini", "content": [ { "type": "text", "text": "从咖啡机的正面视角平稳绕行到侧面视角,自然衔接首尾两张图片,保持产品外观与光线一致。" }, { "type": "image_url", "image_url": { "url": "https://your-cdn.com/first-frame.png" }, "role": "first_frame" }, { "type": "image_url", "image_url": { "url": "https://your-cdn.com/last-frame.png" }, "role": "last_frame" } ], "duration": 8, "resolution": "720p", "generate_audio": false }' ``` #### 全能参考 本例组合两张参考图、一段参考视频和一段参考音频,可按需删减。@Image1 / @Image2、@Video1 分别按参考图、参考视频的数组顺序编号;2.0 的音频不能作为唯一参考素材。 ```bash curl -X POST https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2-0", "content": [ { "type": "text", "text": "@Image1 的咖啡机作为主体,场景与配色参考 @Image2,运镜参考 @Video1,动作节奏跟随参考音频。保持产品外观一致,制作一段明亮的广告片。" }, { "type": "image_url", "image_url": { "url": "https://your-cdn.com/product.png" }, "role": "reference_image" }, { "type": "image_url", "image_url": { "url": "https://your-cdn.com/scene.png" }, "role": "reference_image" }, { "type": "video_url", "video_url": { "url": "https://your-cdn.com/camera.mp4" }, "role": "reference_video" }, { "type": "audio_url", "audio_url": { "url": "https://your-cdn.com/rhythm.mp3" }, "role": "reference_audio" } ], "duration": 8, "resolution": "720p", "ratio": "16:9", "generate_audio": true }' ``` #### 视频编辑 仅 2.5:待编辑视频须为 4–30 秒,role 为 reference_video;设置 edit、ratio: "adaptive" 和 duration: -1,输出比例与时长基本跟随原视频。本例明确修改背景,并使用 MOV 输出;回调关联方式见左侧说明。 ```bash curl -X POST https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2-5", "content": [ { "type": "text", "text": "编辑视频 @Video1:将咖啡机周围的背景修改为明亮的现代厨房,保留产品外观、运动轨迹和原有运镜。" }, { "type": "video_url", "video_url": { "url": "https://your-cdn.com/to-edit.mp4" }, "role": "reference_video" } ], "duration": -1, "resolution": "1080p", "ratio": "adaptive", "generate_audio": true, "omni_reference_task_type": "edit", "output_format": "mov", "execution_expires_after": 172800, "callback_url": "https://your-app.com/video-callback?job_id=123" }' ``` #### 视频延长 仅 2.5:传入 role 为 reference_video 的待延长视频,设置 extend 和 ratio: "adaptive",比例跟随原视频。提示词明确“向前延长”或“向后延长”;本例设输出时长为 12 秒,可设为 4–30 秒中的整数,或传 -1 让模型自选,实际时长以任务结果为准。MP4 便于播放;注重声画衔接时,官方推荐 MOV 输入和输出。 ```bash curl -X POST https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2-5", "content": [ { "type": "text", "text": "向后延长 @Video1:从视频结尾自然延续,镜头缓慢拉远,咖啡机保持在画面中央,随后一杯咖啡平稳移入画面,光线和动作自然衔接。" }, { "type": "video_url", "video_url": { "url": "https://your-cdn.com/to-extend.mp4" }, "role": "reference_video" } ], "duration": 12, "resolution": "720p", "ratio": "adaptive", "generate_audio": true, "omni_reference_task_type": "extend", "output_format": "mp4" }' ``` ### 创建响应 文生视频通常直接进入 queued。使用普通素材 URL 时,任务可能先进入 in_progress,并在 metadata.upstream_status 中标记 preparing;已就绪的素材句柄通常直接排队。 #### 素材准备中 ```json { "id": "task_xxxxxxxxxxxxxxxx", "task_id": "task_xxxxxxxxxxxxxxxx", "object": "video", "model": "doubao-seedance-2-0-mini", "status": "in_progress", "progress": 0, "created_at": 1786350000, "metadata": { "upstream_status": "preparing", "prep": { "total": 1, "active": 0, "failed": 0, "attempt": 1 } } } ``` #### 已排队 ```json { "id": "task_xxxxxxxxxxxxxxxx", "task_id": "task_xxxxxxxxxxxxxxxx", "object": "video", "model": "doubao-seedance-2-0-mini", "status": "queued", "progress": 0, "created_at": 1786350000 } ``` ## 查询视频任务 `GET /v1/video/generations/{task_id}` 使用创建响应中的本站任务 ID(`task_...`)查询进度和结果,携带同一个本站 API Key。 | 状态 | 说明 | |---|---| | `queued` | 已提交,等待生成 | | `in_progress` | 素材准备或视频生成中 | | `completed` | 生成完成,从结果字段取下载地址 | | `failed` | 生成失败,读取 `error.message` | ### 结果读取 | 字段 | 用途 | |---|---| | `result_url` / `metadata.url` | 视频下载地址,两者兼容;完整输出列表在 `metadata.outputs` | | `metadata.last_frame_url` | 尾帧 PNG 下载地址,仅当请求开启 `return_last_frame` 时返回 | | `metadata.usage.completion_tokens` | 上游实际视频 token 用量;最终费用以本站消费记录为准 | | `metadata.upstream_status` | 素材准备时为 `preparing`;本站对外状态仍为 `in_progress` | | `metadata.prep` | 素材准备进度:`total` 总数、`active` 已就绪、`failed` 失败、`attempt` 尝试轮次;失败时可能带 `failedRefs` | | `error.message` | 失败原因,素材错误会指出 `@Image1`、`@Video1` 等编号 | 建议每 5–10 秒查询一次,直到进入终态。素材准备属于正常处理过程,收到 `in_progress` 后继续查询即可。 默认透传的上游视频 / 尾帧签名链接通常有效 24 小时,无需鉴权即可下载;需要长期保存时请及时转存。 ### 请求失败处理 提交返回 400 时按错误说明修正参数;带素材的请求也可能在受理后失败。429 按 `Retry-After` 退避,503 稍后重试。反馈问题时附上响应的 `request_id` / `x-request-id`。 已取得 `task_id` 后只需查询。创建请求发生超时时,先检查业务记录,避免重复提交并重复计费。 ### 查询请求 ```bash curl https://api.o1key.com/v1/video/generations/ \ -H "Authorization: Bearer $API_KEY" ``` ### 查询响应 #### 已完成 last_frame_url 仅在请求 return_last_frame: true 时返回。 ```json { "id": "task_xxxxxxxxxxxxxxxx", "task_id": "task_xxxxxxxxxxxxxxxx", "object": "video", "model": "doubao-seedance-2-0-mini", "status": "completed", "progress": 100, "created_at": 1786350000, "completed_at": 1786350235, "seconds": "5", "size": "720p", "result_url": "https://cdn.example.com/result.mp4", "metadata": { "url": "https://cdn.example.com/result.mp4", "outputs": [ "https://cdn.example.com/result.mp4" ], "last_frame_url": "https://cdn.example.com/last-frame.png", "usage": { "completion_tokens": 108000, "total_tokens": 108000 } } } ``` #### 素材准备中 ```json { "id": "task_xxxxxxxxxxxxxxxx", "task_id": "task_xxxxxxxxxxxxxxxx", "object": "video", "model": "doubao-seedance-2-0-mini", "status": "in_progress", "progress": 0, "created_at": 1786350000, "metadata": { "upstream_status": "preparing", "prep": { "total": 1, "active": 0, "failed": 0, "attempt": 1 } } } ``` #### 失败 ```json { "id": "task_xxxxxxxxxxxxxxxx", "task_id": "task_xxxxxxxxxxxxxxxx", "object": "video", "model": "doubao-seedance-2-0-mini", "status": "failed", "progress": 100, "created_at": 1786350000, "completed_at": 1786350020, "error": { "code": "upstream_error", "message": "Reference material @Image1 could not be prepared: url is not reachable" } } ``` ## 创建素材 `POST /v1/seedance/assets` 通过公开 URL 创建可复用素材。仅使用一次的素材可直接在视频请求中传入 URL。 | 字段 | 必填 | 类型 | 说明 | |---|---|---|---| | `type` | 是 | string | `dreamina`、`doubao` 或 `hc`(兼容旧名);须与视频模型对应 | | `url` | 是 | string | 公开素材地址;HC 要求 HTTPS,Dreamina 与 Doubao 接受 HTTP(S)。`asset://` 和 `data:` 会被拒绝 | | `name` | 否 | string | 素材名称 | | `asset_type` | 否 | string | `image`、`video` 或 `audio`;默认 `image` | | `model` | 否 | string | 用于选择渠道,并在 Dreamina / Doubao 上转发给上游。Dreamina 可省略;如填写,使用本站公开名(推荐简写如 `dreamina-seedance-2-0-mini`,兼容 `-hc` 旧名)或上游 `dreamina-*-max`。Doubao 建议省略;如填写,使用 `doubao-seedance-2-0` 或 `doubao-seedance-2-0-260128-max` | `type: "dreamina"` 转发到 `POST /v2/sd-max/assets`,`type: "doubao"` 转发到 `POST /v2/db-sd-max/assets`。这两条上游路径也可以直接调用,请求体字段为 `URL`、`AssetType`、`Name`、`Model`,响应原样返回 `Id`、`Ref`、`Status`。上传是 POST 到不带 id 的路径。 ### 国外 Dreamina 预上传流程 1. `POST /v1/seedance/assets`:`type` 为 `dreamina`,`model` 为即将用于生成的简写(示例用 `dreamina-seedance-2-0-mini`),`asset_type` 为 `image`,`url` 为公网图片。 2. `GET /v1/seedance/assets/{data.Id}?type=dreamina`:每 1–2 秒查询,直到 `data.Status` 为 `Active`。记下 `data.Ref`(形如 `asset://...`)。 3. `POST /v1/video/generations`:`model` 仍用同一个简写,把 `Ref` 填进 `content[].image_url.url`,`role` 为 `reference_image`。示例为 `resolution: "480p"`、`duration: 4`、`generate_audio: false`。 4. `GET /v1/video/generations/{id}`:使用创建响应里的本站 `task_...`,直到 `status` 为 `completed` 或 `failed`。句柄已是 `Active` 时,任务通常直接是 `queued`,而不是素材准备中的 `in_progress`。 右侧示例里的素材 ID、任务 ID 和图片地址都是占位示例,不是线上记录。只使用一次的素材不必预上传,直接把公网 URL 放进视频请求即可。上传素材免费,句柄有效期 7 天。 句柄只对**创建它时实际选中的那把上游密钥及其组织**有效。Dreamina 与豆包不能混用。同一家族若有多把密钥或多个组织,只传 `type` 会在当前分组里选优先级最高的匹配渠道;之后生成若落到另一把密钥,句柄不能用。预上传请带上与生成请求相同的公开模型名,使两边都在提供该模型的渠道中选择。即便如此,同一模型仍可能对应多把密钥,句柄不能假定在同家族或同模型的其他密钥上可用。 #### Dreamina 国外 以下四步均为示例。mva-example-mini-001 与 task_example_dreamina_mini 不是真实素材或任务。创建响应里的 Model 是上游回显;统一入口会先按渠道映射把公开简写改成上游名再转发。 #### 1. 创建素材 ```bash curl -X POST https://api.o1key.com/v1/seedance/assets \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "dreamina", "model": "dreamina-seedance-2-0-mini", "url": "https://cdn.example.com/reference-mini.png", "name": "窗台参考图", "asset_type": "image" }' ``` ```json { "success": true, "data": { "Id": "mva-example-mini-001", "Ref": "asset://mva-example-mini-001", "Status": "Processing", "AssetType": "Image", "Name": "窗台参考图", "Model": "dreamina-seedance-2-0-mini-260615-max", "Error": null } } ``` #### 2. 查询直到 Active ```bash curl "https://api.o1key.com/v1/seedance/assets/mva-example-mini-001?type=dreamina" \ -H "Authorization: Bearer $API_KEY" ``` ```json { "success": true, "data": { "Id": "mva-example-mini-001", "Ref": "asset://mva-example-mini-001", "Status": "Active", "AssetType": "Image", "Name": "窗台参考图", "Error": null } } ``` #### 3. 用 Ref 生成视频 ```bash curl -X POST https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "dreamina-seedance-2-0-mini", "content": [ { "type": "text", "text": "一只小猫在窗台上晒太阳,镜头缓慢推近。" }, { "type": "image_url", "image_url": { "url": "asset://mva-example-mini-001" }, "role": "reference_image" } ], "duration": 4, "resolution": "480p", "generate_audio": false }' ``` ```json { "id": "task_example_dreamina_mini", "task_id": "task_example_dreamina_mini", "object": "video", "model": "dreamina-seedance-2-0-mini", "status": "queued", "progress": 0, "created_at": 1786350000 } ``` #### 4. 轮询生成结果 ```bash curl https://api.o1key.com/v1/video/generations/task_example_dreamina_mini \ -H "Authorization: Bearer $API_KEY" ``` ```json { "id": "task_example_dreamina_mini", "task_id": "task_example_dreamina_mini", "object": "video", "model": "dreamina-seedance-2-0-mini", "status": "completed", "progress": 100, "created_at": 1786350000, "completed_at": 1786350235, "seconds": "4", "size": "480p", "result_url": "https://cdn.example.com/result-mini.mp4", "metadata": { "url": "https://cdn.example.com/result-mini.mp4", "outputs": [ "https://cdn.example.com/result-mini.mp4" ] } } ``` #### Doubao 国内 国内豆包示例。查询把 type 换成 doubao,路径中的 Id 使用本次响应的 data.Id。下列 ID 同样是示例。 ```bash curl -X POST https://api.o1key.com/v1/seedance/assets \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "doubao", "url": "https://upload.o1key.com/uploads/reference.png", "name": "人物参考图", "asset_type": "image" }' ``` ```json { "success": true, "data": { "Id": "mva-example-doubao-001", "Ref": "asset://mva-example-doubao-001", "Status": "Processing", "AssetType": "Image", "Error": null } } ``` ## 查询素材 `GET /v1/seedance/assets/{asset_id}?type={type}` | 字段 | 必填 | 位置 | 说明 | |---|---|---|---| | `asset_id` | 是 | path | 创建接口返回的 `data.Id` | | `type` | 是 | query | `dreamina`、`doubao` 或 `hc`(兼容旧名),须与创建时一致。查询走创建该句柄时同一类渠道;同一家族有多把密钥时,仍取决于创建时实际选中的那把密钥 | | 状态 | 说明 | |---|---| | `Processing` | 处理中 | | `Active` | 可用于视频生成 | | `Failed` | 处理失败,原因见 `Error` | 建议每 1-2 秒查询一次,直到状态变为 `Active` 或 `Failed`。 #### Dreamina 国外 示例 ID。直接代理为 GET /v2/sd-max/assets/{Id}。 ```bash curl "https://api.o1key.com/v1/seedance/assets/mva-example-mini-001?type=dreamina" \ -H "Authorization: Bearer $API_KEY" ``` #### 查询成功 200 ```json { "success": true, "data": { "Id": "mva-example-mini-001", "Ref": "asset://mva-example-mini-001", "Status": "Active", "AssetType": "Image", "Error": null } } ``` #### Doubao 国内 示例 ID。直接代理为 GET /v2/db-sd-max/assets/{Id}。 ```bash curl "https://api.o1key.com/v1/seedance/assets/mva-example-doubao-001?type=doubao" \ -H "Authorization: Bearer $API_KEY" ``` #### 查询成功 200 ```json { "success": true, "data": { "Id": "mva-example-doubao-001", "Ref": "asset://mva-example-doubao-001", "Status": "Active", "AssetType": "Image", "Error": null } } ``` --- # SD 2 / SD 2.5 视频生成 11 个按秒计费的视频模型,支持文字生成和图片、视频、音频参考。通过同一个接口提交任务、查询进度和下载 MP4。 ## Agent 调用规则 1. 向 `POST /v1/videos` 提交 JSON。按下表填写完整模型 ID,使用 `prompt` 或 `content` 传入提示词。 2. 保存返回的 `id`,轮询 `GET /v1/videos/{id}`。 3. 状态为 `completed` 时携带同一账户的密钥请求 `GET /v1/videos/{id}/content` 保存 MP4。状态为 `failed` 时读取 `error`。 ## 简明说明 ### 用一张图生成视频 选择分辨率,把图放在可以直接读取的公网网址上,再写下人物动作、拍摄方式和配乐要求。只提供提示词即可做文生视频。 ### 5 秒视频多少钱? 默认分组里,`sd-2-mini-480` 生成 5 秒为 ¥0.44,`sd-2.5-720P` 生成 5 秒为 ¥2.189。其他型号按下表的单价乘以计费秒数。 ## 创建视频 `POST /v1/videos` ### 型号、时长和售价 默认分组的人民币单价如下。分辨率由型号确定,时长为整数秒,省略时生成 5 秒。 | 模型 ID | 时长 | 元 / 秒 | |---|---|---| | `sd-2-fast-480` | 4–15 秒 | 0.165 | | `sd-2-fast-720` | 4–15 秒 | 0.22 | | `sd-2-mini-480` | 5–15 秒 | 0.088 | | `sd-2-mini-720` | 4–15 秒 | 0.132 | | `sd-2-vip-480` | 4–15 秒 | 0.22 | | `sd-2-vip-720` | 5–15 秒 | 0.264 | | `sd-2.5-480P` | 4–30 秒 | 0.3278 | | `sd-2.5-720P` | 4–30 秒 | 0.4378 | | `sd-2.5-1080P` | 4–30 秒 | 0.968 | | `sd-2.5-flash-480P` | 4–30 秒 | 0.22 | | `sd-2.5-flash-720P` | 4–30 秒 | 0.33 | ### 请求参数 - `model` 与提示词必填。`prompt` 描述画面、动作与声音。也可以通过 `content` 数组传入 `text` 和 `image_url`、`video_url`、`audio_url` 项。 - `duration`(或 `seconds`)指定整数秒。`aspect_ratio` 支持 `9:16`、`16:9`、`1:1`、`3:4`、`4:3`、`21:9`。 - `references` 的每一项提供 `type` 和 `url`,类型支持 `image`、`video` 或 `audio`,普通素材的 `role` 为 `reference`。本地文件可先通过 [素材上传接口](/docs/temporary-upload) 获取网址。 - SD 2 最多可传 9 张图片、3 段视频、3 段音频。两款 Fast 支持用 `first_frame` 指定首帧,再用 `last_frame` 指定可选尾帧。Fast 的音频参考需要搭配图片或视频。 - SD 2.5 标准版最多支持 30 张图片、10 段视频、10 段音频,Flash 最多支持 10 张图片、5 段视频、5 段音频。 ### 图生视频 · 竖屏 5 秒 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sd-2.5-720P", "duration": 5, "aspect_ratio": "9:16", "prompt": "正常速度拍摄 5 秒穿搭短片。远景走两步,近景转身展示剪裁,最后特写面料纹理,配欢快无歌词音乐。", "references": [ {"type": "image", "role": "reference", "url": "https://cdn.example.com/outfit.jpg"} ] }' ``` 把示例图片网址替换为你的服装照片。 ### 文生视频 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"sd-2-mini-480","duration":5,"prompt":"日光下展开一块棉布,镜头从布料全景切到缝线特写。"}' ``` ### 提交响应示例 ```json {"id":"task_example","object":"video","status":"queued","progress":0} ``` ## 查询任务和下载视频 `GET /v1/videos/{id}` `GET /v1/videos/{id}/content` 用任务 ID 查询状态。`queued` 表示排队,`in_progress` 表示生成中,`completed` 后可下载成片。`failed` 的任务可通过响应中的错误信息排查。 ### 查询状态 ```bash curl "https://api.o1key.com/v1/videos/$TASK_ID" \ -H "Authorization: Bearer $API_KEY" ``` ### 完成响应示例 ```json {"id":"task_example","object":"video","status":"completed","progress":100} ``` ### 保存成片 ```bash curl -fL "https://api.o1key.com/v1/videos/$TASK_ID/content" \ -H "Authorization: Bearer $API_KEY" -o outfit.mp4 ``` --- # MiniMax H3 系列视频生成 支持 H3、Highspeed、Lite、Max 和 Max Turbo。按模型选择分辨率和输入素材,通过统一异步接口提交任务并查询视频结果。 ## Agent 调用规则 1. POST `/v1/video/generations`,必填 `model`、`content`、`resolution`、`duration`,记录返回的任务 ID。 2. 每 10–20 秒 GET `/v1/videos/{task_id}`,`queued` 或 `in_progress` 时继续查询。 3. `completed`:把 `result_url` 返回给用户。 4. `failed`:把错误信息告诉用户,不要自动重试。 5. 分辨率和时长必须符合所选模型的能力表;不确定时先向用户确认。 6. Highspeed 和 Lite 的请求模型名分别为 `MiniMax-H3-Highspeed`、`MiniMax-H3-Lite`,均仅支持 `480P` / `768P`,时长 4–15 秒;不要为这两个模型请求 `2K` 或 `1080P`。 7. Lite 使用任一 `reference_*` 素材时,显式传入具体 `ratio`(如 `16:9`),不能省略或使用 `adaptive`。 8. 图片请显式填写 `role`。首尾帧与 `reference_*` 素材不能混用;Highspeed、Lite 图片未指定 `role` 时按参考图处理。 ## 简明说明 ### 这个接口做什么? 用 MiniMax H3 系列生成视频,支持文字、图片、视频和音频作为输入。接口先返回**任务编号**,之后用编号查询,完成后拿到视频地址。 ### 你需要提供的信息 - **用哪个模型**:`model`:`MiniMax-H3`、`MiniMax-H3-Highspeed`、`MiniMax-H3-Lite`、`MiniMax-H3-MAX` 或 `minimax-h3-max-turbo`。 - **想要什么画面**:`content` 数组,至少一项非空文本;图片、视频、音频也放在这里。 - **分辨率与时长**:`resolution`、`duration`,必填,取值见完整参考的模型能力表。 - **Highspeed 与 Lite 怎么选**:Highspeed 兼顾质量与速度,适合日常内容创作;Lite 侧重较低成本,适合创意探索与批量生成。两者均支持 `480P` / `768P`、4–15 秒,以及图片、视频、音频参考。 - **画面比例**:纯文本生成须填写具体 `ratio`,如 `16:9`。Lite 使用参考素材时也必须填写具体比例,不能使用 `adaptive`。 ### 怎么拿到结果 - **状态**:`queued`、`in_progress` 继续等待;`completed` 成功;`failed` 失败。 - **视频地址**:`result_url`,请及时下载或转存。 ## 创建 MiniMax H3 系列视频任务 `POST /v1/video/generations` 创建成功后立即返回 `task_id`。视频在后台生成,无需保持请求连接。 ### 模型能力与 Highspeed / Lite 选型 | 模型 | 适用需求 | 支持场景 | 分辨率 | 时长 | |---|---|---|---|---| | `MiniMax-H3` | 较高分辨率与多模态参考 | 文生视频、首帧/尾帧/首尾帧图生视频、图片/视频/音频多模态参考 | `768P`、`2K` | 4-15 秒 | | `MiniMax-H3-Highspeed` | 兼顾质量与速度,适合日常内容创作 | 文生视频、首帧/尾帧/首尾帧图生视频、图片/视频/音频多模态参考 | `480P`、`768P` | 4-15 秒 | | `MiniMax-H3-Lite` | 侧重较低成本,适合创意探索与批量生成 | 文生视频、首帧/尾帧/首尾帧图生视频、图片/视频/音频多模态参考 | `480P`、`768P` | 4-15 秒 | | `MiniMax-H3-MAX` | 文字或首尾帧输入 | 文生视频、首帧/尾帧/首尾帧图生视频 | `480P`、`768P` | 5-15 秒 | | `minimax-h3-max-turbo` | 文字或首尾帧输入,可选 1080P | 文生视频、首帧/尾帧/首尾帧图生视频 | `480P`、`768P`、`1080P` | 5-15 秒 | > 需要 `2K` 时请选择 `MiniMax-H3`;H3、Highspeed 和 Lite 均支持多模态参考。Highspeed 和 Lite 不支持 `2K` 或 `1080P`。H3 Max 和 H3 Max Turbo 不支持 `reference_*` 素材。需要 `1080P` 时请选择 `minimax-h3-max-turbo`。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `model` | string | 是 | 使用上方能力表中的完整模型名,例如 `MiniMax-H3-Highspeed` 或 `MiniMax-H3-Lite`,保持示例中的大小写。 | | `content` | array | 是 | 提示词和输入素材,至少包含一个非空文本项。 | | `resolution` | string | 是 | 取值见上方模型能力表,区分大小写。 | | `duration` | integer | 是 | 输出秒数,取值范围见上方模型能力表。 | | `ratio` | string | 条件必填 | 纯文本生成、Lite 多模态参考必须填写具体比例。首尾帧模式可使用 `adaptive`。具体规则见下表。 | | `callback_url` | string | 否 | 任务状态回调地址。建议同时保留查询任务的兜底逻辑。 | ### 画面比例规则 固定比例可选 `21:9`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`。 | 输入场景 | `ratio` 规则 | |---|---| | 纯文本生成(全部模型) | 必填固定比例,不能为 `adaptive`。 | | 首帧 / 尾帧 / 首尾帧(全部模型) | 可使用 `adaptive`,比例跟随输入图片。使用尾帧时请同时提供首帧。 | | H3、Highspeed 的多模态参考 | 可省略或使用 `adaptive`,也可指定固定比例。 | | Lite 的多模态参考 | 必填固定比例,例如 `16:9`;省略或使用 `adaptive` 会返回参数错误。 | ### `content` 项 | `type` | 数据字段 | `role` | 适用模型 | |---|---|---|---| | `text` | `text` | 不填 | 全部;提示词最多 7000 个字符 | | `image_url` | `image_url.url` | `first_frame` / `last_frame` | 全部;请显式填写 `role` | | `image_url` | `image_url.url` | `reference_image` | H3、Highspeed、Lite | | `video_url` | `video_url.url` | `reference_video` | H3、Highspeed、Lite | | `audio_url` | `audio_url.url` | `reference_audio` | H3、Highspeed、Lite | 建议所有图片都显式填写 `role`,以准确选择输入模式。Highspeed、Lite 的图片省略 `role` 时按 `reference_image` 处理;H3、H3 Max、H3 Max Turbo 则按 `first_frame` 处理。 ### 素材限制 | 素材 | 格式与大小 | 其他限制 | |---|---|---| | 图片 | JPG、JPEG、PNG、WEBP、HEIC、HEIF;单张不超过 30MB | 宽高 256-5760px,宽高比 0.4-2.5 | | 参考视频 | MP4、MOV;单个不超过 50MB | 单段 2-15 秒,总时长不超过 15 秒,23.976-60fps | | 参考音频 | WAV、MP3;单个不超过 15MB | 单段 2-15 秒,总时长不超过 15 秒 | - 请求体不超过 64MB。素材可使用公网 URL 或对应格式的 Base64 Data URI,大文件建议使用 URL。 - H3、Highspeed、Lite 最多包含 9 张参考图、3 个参考视频、3 个参考音频,全部参考素材合计不超过 12 个。 - `first_frame`/`last_frame` 不能与任一 `reference_*` 素材混用。 ### 计费说明 H3、Highspeed 和 Lite 按输出视频秒数计费;参考视频另按输入秒数计费;参考音频免费;每次请求前 5 张输入图片免费,第 6 张起按张计费。不同模型、分辨率的单价可能不同,请以账户适用价格为准。H3 Max 和 H3 Max Turbo 仅按输出视频秒数计费。 创建任务时会预扣额度,完成后按实际用量结算;包含参考视频的任务可能在完成后补扣输入视频费用。任务失败会退回已预扣额度,最终费用以消费记录为准。 ### 请求示例 #### 文生视频 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-H3", "content": [ { "type": "text", "text": "Epic space-opera trailer: a fleet jumps into warp beyond a giant observation window while the camera slowly pushes toward the captain." } ], "resolution": "2K", "duration": 5, "ratio": "16:9" }' ``` #### 首尾帧 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-H3", "content": [ { "type": "text", "text": "Create a smooth cinematic transformation from the daytime street into the same location at night." }, { "type": "image_url", "image_url": {"url": "https://cdn.example.com/day.jpg"}, "role": "first_frame" }, { "type": "image_url", "image_url": {"url": "https://cdn.example.com/night.jpg"}, "role": "last_frame" } ], "resolution": "768P", "duration": 8, "ratio": "adaptive" }' ``` #### 多模态参考 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-H3", "content": [ { "type": "text", "text": "Use the character appearance from the reference image, follow the action and camera rhythm of the reference video, and speak with the reference voice." }, { "type": "image_url", "image_url": {"url": "https://cdn.example.com/character.png"}, "role": "reference_image" }, { "type": "video_url", "video_url": {"url": "https://cdn.example.com/action.mp4"}, "role": "reference_video" }, { "type": "audio_url", "audio_url": {"url": "https://cdn.example.com/voice.mp3"}, "role": "reference_audio" } ], "resolution": "2K", "duration": 6, "ratio": "adaptive", "callback_url": "https://example.com/minimax/callback" }' ``` #### Highspeed 文生视频 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-H3-Highspeed", "content": [ { "type": "text", "text": "一只红色玩具球在白色桌面上缓慢滚动,固定镜头,自然光,无文字。" } ], "resolution": "480P", "duration": 4, "ratio": "16:9" }' ``` #### Lite 多模态参考 Lite 使用参考素材时,`ratio` 必须是具体比例。请将素材地址替换为可直接访问的实际文件地址。 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-H3-Lite", "content": [ { "type": "text", "text": "参考图1中的人物外观,参考视频1中的运镜,参考音频1中的声音,生成自然流畅的场景。" }, { "type": "image_url", "image_url": {"url": "https://cdn.example.com/character.png"}, "role": "reference_image" }, { "type": "video_url", "video_url": {"url": "https://cdn.example.com/action.mp4"}, "role": "reference_video" }, { "type": "audio_url", "audio_url": {"url": "https://cdn.example.com/voice.mp3"}, "role": "reference_audio" } ], "resolution": "768P", "duration": 4, "ratio": "16:9" }' ``` > 这些模型共用相同的提交和查询接口。Highspeed、Lite 使用 `480P` 或 `768P`、4–15 秒;Lite 参考模式需填写固定比例。H3 Max 使用 `MiniMax-H3-MAX`、`480P` / `768P`、5–15 秒。H3 Max Turbo 使用 `minimax-h3-max-turbo`,还可使用 `1080P`。单张首帧只需省略首尾帧示例中的 `last_frame`,保留 `first_frame`。 ### 创建响应 ```json { "id": "task_h3_xxxxxxxxxx", "task_id": "task_h3_xxxxxxxxxx", "object": "video", "model": "MiniMax-H3", "status": "queued", "progress": 0, "created_at": 1786350000 } ``` ## 查询 MiniMax H3 系列视频任务 `GET /v1/videos/{task_id}` 使用创建接口返回的 `task_id` 查询。建议每 10-20 秒轮询一次,直到任务变为 `completed` 或 `failed`。 | 状态 | 处理方式 | |---|---| | `queued` / `in_progress` | 任务排队或生成中,继续轮询。 | | `completed` | 读取 `result_url` 并及时下载或转存。 | | `failed` | 读取 `error.code` 和 `error.message`。 | | `unknown` | 任务刚创建时可能短暂出现,按 `queued` 处理。 | ### 响应字段 | 响应字段 | 说明 | |---|---| | `id` / `task_id` | 任务 ID,两个字段值相同。 | | `status` / `progress` | 任务状态和进度;进度仅用于展示,不代表精确剩余时间。 | | `result_url` | 任务完成后的视频地址。 | | `seconds` / `size` | 实际输出时长和分辨率。 | | `metadata.usage` | 实际输入与输出用量,包括视频秒数、音频秒数和图片数量。 | | `error` | 失败信息,仅在任务失败时返回。 | > 处理中可能没有 `result_url`、`metadata` 或完整用量信息,仅在 `completed` 后读取结果地址。 ### 请求示例 ```bash curl https://api.o1key.com/v1/videos/ \ -H "Authorization: Bearer $API_KEY" ``` ### 完成响应 ```json { "id": "task_h3_xxxxxxxxxx", "task_id": "task_h3_xxxxxxxxxx", "object": "video", "model": "MiniMax-H3", "status": "completed", "progress": 100, "created_at": 1786350000, "completed_at": 1786350417, "seconds": "5", "size": "2K", "result_url": "https://cdn.example.com/h3-result.mp4", "metadata": { "url": "https://cdn.example.com/h3-result.mp4", "ratio": "16:9", "usage": { "total_seconds": 5, "input_seconds": 0, "input_audio_seconds": 6, "output_seconds": 5, "input_image_count": 1 } } } ``` --- # 万相 Wan 3.0 视频生成 文生视频、首帧/首尾帧生视频、参考生视频和视频编辑。通过统一异步接口创建任务,并使用任务 ID 查询结果。 ## Agent 调用规则 1. POST `/v1/video/generations`,`model` 为 `wan3.0-video` 或 `wan3.0-video-prime`,`prompt` 必填,记录返回的 `task_id`。 2. 显式传 `resolution`,不传会按 1080p 生成和计费。 3. 每 15 秒左右 GET `/v1/video/generations/{task_id}`,`queued` 或 `in_progress` 时继续查询。 4. `completed`:把 `result_url` 返回给用户,提醒是限时链接。 5. `failed`:把 `error.code` 和 `error.message` 告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 用万相 3.0 生成视频:文生视频、首帧或首尾帧生视频、参考图 / 视频 / 音频生视频,也可以编辑一段已有视频。最长 30 秒。接口先返回**任务编号**,之后用编号查询。 ### 你需要提供的信息 - **用哪个模型**:`model`:`wan3.0-video`(标准)或 `wan3.0-video-prime`(更快)。 - **想要什么画面**:`prompt`,必填。用「图1」「视频1」引用素材。 - **分辨率(建议填)**:`resolution`:`480p`、`720p`、`1080p`。不传按 1080p 生成和计费。 - **时长(可选)**:`duration`,2–30 秒,不传为 5 秒。 - **素材(可选)**:`image` 作为首帧;更多素材放进 `metadata.input.media`。 ### 怎么拿到结果 - **状态**:`queued`、`in_progress` 继续等待;`completed` 成功;`failed` 失败。 - **视频地址**:`result_url`(同 `metadata.url`),是限时链接,请及时下载转存。 ## 创建万相 Wan 3.0 视频任务 `POST /v1/video/generations` 创建成功后立即返回任务 ID,视频在后台生成,单次任务通常 1-5 分钟完成。 ### 模型 | 模型 | 说明 | |---|---| | `wan3.0-video` | 标准版。 | | `wan3.0-video-prime` | 高速版,能力和参数与标准版完全相同,出片更快,单价更高。 | ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `model` | string | 是 | `wan3.0-video` 或 `wan3.0-video-prime`。 | | `prompt` | string | 是 | 提示词。只用素材时也请写一句描述。用「图1」「视频1」「音频1」引用参考素材,序号为该类型在 `media` 中出现的顺序。 | | `resolution` | string | 否 | `480p`、`720p` 或 `1080p`。**不传按 `1080p` 生成并计费**,建议显式传。 | | `duration` | integer | 否 | 输出秒数,2-30,不传为 5。智能时长用 `metadata.parameters.duration: -1`。 | | `image` / `images` | string / array | 否 | 快捷写法:1 张图作为首帧,2 张图作为首帧和尾帧。传了 `metadata.input.media` 时以 `media` 为准。 | | `metadata.input.media` | array | 否 | 素材数组,每项 `{"type": "...", "url": "..."}`,见下表。 | | `metadata.parameters.ratio` | string | 否 | `adaptive`、`16:9`、`9:16`、`1:1`、`4:3`、`3:4`、`21:9`。 | | `metadata.parameters.duration` | integer | 否 | 2-30,或 `-1` 智能时长(按实际生成秒数计费)。传了以此为准。 | | `metadata.parameters.audio` | boolean | 否 | 是否带音轨,默认 `true`。 | | `metadata.parameters.watermark` | boolean | 否 | 是否在右下角加「AI 生成」水印,默认 `false`。 | | `metadata.parameters.seed` | integer | 否 | 随机种子。相同 seed 也不保证结果完全一致。 | | `metadata.parameters.prompt_extend` | boolean | 否 | 是否先智能改写提示词,默认 `true`。传 `false` 严格按原提示词生成,出片更快。 | ### `media` 素材类型 | `type` | 含义 | 数量 | |---|---|---| | `first_frame` | 视频第一帧 | 最多 1 张 | | `last_frame` | 视频最后一帧,需与 `first_frame` 一起用 | 最多 1 张 | | `reference_image` | 参考图 | 最多 10 张 | | `reference_video` | 参考视频;也用于视频编辑、视频延长 | 最多 5 段,总时长不超过 15 秒 | | `reference_audio` | 参考音频 | 最多 5 段,总时长不超过 15 秒 | - 首尾帧与参考素材互斥:有 `first_frame`/`last_frame` 就不能再有 `reference_*`。参考图、参考视频、参考音频之间可以自由组合。 - 带参考视频时,参考视频总时长 + 输出时长不超过 30 秒。 - 素材 URL 必须是公网可直接下载的 HTTP/HTTPS 地址,不依赖登录态、Cookie 或 Referer。可先用[素材上传](/docs/temporary-upload.md)得到 URL。 - 图片:JPEG/JPG/PNG(不支持透明通道)/BMP/WEBP,单边 240-8000 像素,宽高比不超过 8:1,单张不超过 20MB。参考视频:MP4/MOV,单段 1-15 秒,帧率不低于 16fps,单个不超过 100MB。参考音频:WAV/MP3,单段 1-15 秒,单个不超过 15MB。 ### 计费 在[模型定价](/pricing)选择模型和分组,可查看已经包含分组价格的 480P、720P、1080P 售价。计费时长包含生成视频与参考视频的时长。音频开关和 `prompt_extend` 不改变单价。提交后先预留费用,确认实际用量后结算;用量暂未确认时请继续轮询,任务失败不收费。最终金额可在使用日志查看。 ### 请求示例 #### 文生视频 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wan3.0-video", "prompt": "一只小猫在月光下的屋顶上奔跑,城市的霓虹灯在远处闪烁", "resolution": "720p", "duration": 5, "metadata": { "parameters": { "ratio": "16:9", "prompt_extend": false } } }' ``` #### 首帧生视频 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wan3.0-video", "prompt": "涂鸦少年从墙上活过来,开始说唱", "image": "https://example.com/first.png", "resolution": "720p", "duration": 5, "metadata": { "parameters": { "ratio": "adaptive" } } }' ``` #### 参考生视频 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wan3.0-video", "prompt": "图1中的女孩在海边奔跑,用音频1的声音说:今天的阳光真好", "resolution": "720p", "duration": 5, "metadata": { "input": { "media": [ { "type": "reference_image", "url": "https://example.com/girl.jpg" }, { "type": "reference_audio", "url": "https://example.com/voice.mp3" } ] }, "parameters": { "ratio": "16:9" } } }' ``` #### 视频编辑 ```bash curl https://api.o1key.com/v1/video/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wan3.0-video", "prompt": "将整个画面转换为黏土风格", "resolution": "720p", "metadata": { "input": { "media": [ { "type": "reference_video", "url": "https://example.com/source.mp4" } ] }, "parameters": { "ratio": "adaptive", "duration": -1 } } }' ``` ### 创建响应 ```json { "id": "task_xxxxxxxxxx", "task_id": "task_xxxxxxxxxx", "object": "video", "model": "wan3.0-video", "status": "queued", "progress": 0, "created_at": 1794490280 } ``` ### 参数错误响应 ```json { "code": "invalid_request", "message": "wan3.0 duration must be -1 or an integer between 2 and 30", "data": null } ``` ## 查询万相 Wan 3.0 视频任务 `GET /v1/video/generations/{task_id}` 状态:`queued`、`in_progress`、`completed`、`failed`。建议每 15 秒左右查询一次。 `completed` 后从 `result_url`(同 `metadata.url`)下载视频。视频链接为限时链接,请及时下载转存。`seconds` 为实际输出秒数,`size` 为实际分辨率。 `failed` 时读取 `error.code` 和 `error.message`,常见 `DataInspectionFailed`(内容审核未通过)、`IPInfringementSuspect`(疑似知识产权侵权)、`InvalidParameter`(参数或素材组合不被接受)。 ### 查询状态 ```bash curl https://api.o1key.com/v1/video/generations/ \ -H "Authorization: Bearer $API_KEY" ``` ### 完成响应 ```json { "id": "task_xxxxxxxxxx", "task_id": "task_xxxxxxxxxx", "object": "video", "model": "wan3.0-video", "status": "completed", "progress": 100, "created_at": 1794490280, "completed_at": 1794490370, "seconds": "5", "size": "720P", "result_url": "https://cdn.example.com/video.mp4", "metadata": { "url": "https://cdn.example.com/video.mp4", "resolution": "720P" } } ``` ### 失败响应 ```json { "id": "task_xxxxxxxxxx", "task_id": "task_xxxxxxxxxx", "object": "video", "model": "wan3.0-video", "status": "failed", "progress": 100, "created_at": 1794490280, "error": { "code": "DataInspectionFailed", "message": "Input data may contain inappropriate content." } } ``` --- # Gemini Omni 视频 文生视频、图生视频、多参考图生视频和视频编辑。媒体输入只接受 Base64,完成后通过内容接口下载 MP4。 ## Agent 调用规则 1. POST `/v1/videos`,`model` 固定 `gemini-omni-flash-preview`,记录返回的任务 ID。 2. 图片和视频只能用 Base64 或 Data URI,不要传 HTTP URL。 3. 定期 GET `/v1/videos/{task_id}`,`queued` 或 `in_progress` 时继续查询。 4. `completed`:GET `/v1/videos/{task_id}/content` 下载 MP4 交给用户。 5. `failed`:把错误信息告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 用 Gemini Omni 生成视频,或编辑一段已有视频。图片和视频必须以 Base64 传入,不接受网址。接口先返回**任务编号**,完成后用内容接口下载视频文件。 ### 你需要提供的信息 - **用哪个模型**:`model`,固定 `gemini-omni-flash-preview`。 - **做什么**:`mode`:`text_to_video`、`image_to_video`、`reference_to_video` 或 `edit`。 - **想要什么画面**:`prompt`,文生视频必填。 - **素材(按模式)**:`image`、`images` 或 `video_url`,都用 Base64。 ### 怎么拿到结果 - **状态**:`queued`、`in_progress` 继续等待;`completed` 成功;`failed` 失败。 - **视频文件**:`completed` 后 GET `/v1/videos/{task_id}/content`,响应体就是 MP4。 ## 创建 Gemini Omni 视频任务 `POST /v1/videos` 固定使用 `gemini-omni-flash-preview`。返回公开任务 ID。 > **媒体输入**:仅接受 Base64 Data URI 或原始 Base64,不接受远程 URL。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `model` | string | 是 | 固定为 `gemini-omni-flash-preview`。 | | `mode` | string | 建议 | `text_to_video`、`image_to_video`、`reference_to_video` 或 `edit`。不传时会根据媒体字段推断。 | | `prompt` | string | 条件 | 文生视频必填;其余模式可选。 | | `image` | string | 条件 | 单图生视频使用一张 Base64 图片。推荐写成 `data:image/png;base64,...`。 | | `images` | string[] | 条件 | 多参考图模式使用,一张或多张 Base64 图片。单图模式最多一张。 | | `video_url` | string | 条件 | 视频编辑模式必填,使用 `data:video/mp4;base64,...` 或原始 Base64,不接受 HTTP URL。 | | `duration` | integer | 否 | 兼容字段,允许 3 到 10 的整数;也可使用 `seconds`。若两者同时出现,值必须一致。实际输出长度由模型决定,编辑模式不要传。 | | `aspect_ratio` | string | 否 | `16:9` 或 `9:16`,默认 `16:9`。编辑模式不要传。 | | `metadata.thinking_level` | string | 否 | `low` 或 `high`,默认 `low`。 | | `metadata.thinking_summaries` | string | 否 | `auto` 或 `none`,默认 `auto`。 | ### 模式约束 | `mode` | 输入要求 | 不允许的输入 | |---|---|---| | `text_to_video` | 非空 `prompt` | 图片、视频 | | `image_to_video` | 正好一张图片,可带提示词 | 多张图片、视频 | | `reference_to_video` | 一张或多张参考图片,可带提示词 | 视频 | | `edit` | 一个 Base64 视频,可带提示词 | 图片、时长、比例和尺寸参数 | ### 计费说明 系统读取上游返回的输入、文本输出、思考和视频模态 Token 分别结算。720p 视频按每秒 5,792 个视频 Token 计量;最终扣费以上游实际用量为准,不按请求中的预估时长直接结算。 ### 请求示例 #### 文生视频 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-omni-flash-preview", "mode": "text_to_video", "prompt": "A blue paper boat drifts slowly across calm studio water, fixed camera.", "aspect_ratio": "16:9", "metadata": { "thinking_level": "low", "thinking_summaries": "none" } }' ``` #### 单图生视频 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-omni-flash-preview", "mode": "image_to_video", "image": "data:image/png;base64,iVBORw0KGgoAAA...", "prompt": "Animate the abstract color field with a slow, smooth wave.", "aspect_ratio": "16:9" }' ``` #### 多参考图 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-omni-flash-preview", "mode": "reference_to_video", "images": [ "data:image/png;base64,iVBORw0KGgoAAA...", "data:image/jpeg;base64,/9j/4AAQSkZJRg..." ], "prompt": "Create a smooth transition using the colors and shapes from both references.", "aspect_ratio": "9:16" }' ``` #### 视频编辑 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-omni-flash-preview", "mode": "edit", "video_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29t...", "prompt": "Keep the motion and add a subtle warm sunset color grade.", "metadata": { "thinking_level": "low", "thinking_summaries": "none" } }' ``` ### 创建响应 ```json { "id": "task_omni_xxxxxxxxxx", "task_id": "task_omni_xxxxxxxxxx", "object": "video", "model": "gemini-omni-flash-preview", "status": "queued", "progress": 10, "created_at": 1786680000 } ``` ### 参数错误响应 ```json { "error": { "code": "invalid_duration", "message": "duration must be between 3 and 10 seconds", "type": "new_api_error" } } ``` ## 查询与下载 Gemini Omni 视频 `GET /v1/videos/{task_id}` `GET /v1/videos/{task_id}/content` 状态:`queued`、`in_progress`、`completed`、`failed`。 `completed` 后调用内容接口下载 MP4。 ### 查询状态 ```bash curl https://api.o1key.com/v1/videos/ \ -H "Authorization: Bearer $API_KEY" ``` ### 完成响应 ```json { "id": "task_omni_xxxxxxxxxx", "object": "video", "model": "gemini-omni-flash-preview", "status": "completed", "progress": 100, "created_at": 1786680000, "completed_at": 1786680632 } ``` ### 下载视频 ```bash curl https://api.o1key.com/v1/videos//content \ -H "Authorization: Bearer $API_KEY" \ --output gemini-omni-result.mp4 ``` --- # Omni Flash 1.2 视频 文生视频和视频编辑,按次计费。提交后返回任务 ID,查询到 `completed` 后下载 MP4。 ## Agent 调用规则 1. POST `/v1/videos`,`model` 固定 `omni_flash-1.2`;传 `source_video_url` 即为视频编辑。记录返回的任务 ID。 2. 定期 GET `/v1/videos/{task_id}`,`queued` 或 `in_progress` 时继续查询。 3. `completed`:GET `/v1/videos/{task_id}/content` 下载 MP4 交给用户。 4. `failed`:把错误信息告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 用 Omni Flash 1.2 生成视频,或编辑一段已有视频,按次计费。接口先返回**任务编号**,完成后用内容接口下载视频文件。 ### 你需要提供的信息 - **用哪个模型**:`model`,固定 `omni_flash-1.2`。 - **想要什么画面**:`prompt`;编辑视频时写明要改什么。 - **待编辑视频(编辑时必填)**:`source_video_url`,公网 URL,可先用素材上传得到。 - **时长与分辨率(可选)**:`seconds`、`resolution`、`aspect_ratio`。 ### 怎么拿到结果 - **状态**:`queued`、`in_progress` 继续等待;`completed` 成功;`failed` 失败。 - **视频文件**:`completed` 后 GET `/v1/videos/{task_id}/content`,响应体就是 MP4。 ## 创建 Omni Flash 1.2 视频任务 `POST /v1/videos` 固定使用 `omni_flash-1.2`,请求体为 JSON。 > **时长字段**:只用 `seconds`,且必须是整数(写 `8`,不要写 `"8"`)。传 `duration` 会被拒绝。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `model` | string | 是 | 固定为 `omni_flash-1.2`。 | | `prompt` | string | 是 | 视频内容描述;视频编辑时写明要修改的内容。 | | `seconds` | integer | 否 | 输出时长(秒),整数。 | | `resolution` | string | 否 | `720p`、`1080p` 或 `4k`。不传按 `720p` 计费。 | | `aspect_ratio` | string | 否 | `16:9` 或 `9:16`。 | | `source_video_url` | string | 条件 | 视频编辑时必填,待编辑视频的公网 URL。可先用[素材上传](/docs/temporary-upload.md)得到 URL。也可写作 `video_url`。 | ### 计费 按次计费,与时长无关。传入 `source_video_url` 或 `video_url` 即按视频编辑计费,否则按视频生成计费。密钥若有分组倍率,再乘该倍率。任务失败不扣费。 | 操作 | 720p | 1080p | 4K | |---|---|---|---| | 视频生成 | ¥1.00 / 次 | ¥1.00 / 次 | ¥1.50 / 次 | | 视频编辑 | ¥1.50 / 次 | ¥1.50 / 次 | ¥2.00 / 次 | ### 请求示例 #### 文生视频 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "omni_flash-1.2", "prompt": "一只小猫在阳光下轻轻挥手", "seconds": 8, "resolution": "720p", "aspect_ratio": "16:9" }' ``` #### 视频编辑 ```bash curl https://api.o1key.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "omni_flash-1.2", "prompt": "保持人物动作不变,把背景换成雨夜街道", "source_video_url": "https://cdn.example.com/source.mp4", "resolution": "1080p" }' ``` ### 创建响应 ```json { "id": "task_xxxxxxxxxx", "task_id": "task_xxxxxxxxxx", "object": "video", "model": "omni_flash-1.2", "status": "queued", "progress": 0, "created_at": 1794490280 } ``` ### 参数错误响应 ```json { "code": "invalid_request", "message": "seconds must be an integer", "data": null } ``` ## 查询与下载 Omni Flash 1.2 视频 `GET /v1/videos/{task_id}` `GET /v1/videos/{task_id}/content` 状态:`queued`、`in_progress`、`completed`、`failed`。 `completed` 后调用内容接口下载 MP4。 ### 查询状态 ```bash curl https://api.o1key.com/v1/videos/ \ -H "Authorization: Bearer $API_KEY" ``` ### 完成响应 ```json { "id": "task_xxxxxxxxxx", "object": "video", "model": "omni_flash-1.2", "status": "completed", "progress": 100, "created_at": 1794490280, "completed_at": 1794490324 } ``` ### 下载视频 ```bash curl https://api.o1key.com/v1/videos//content \ -H "Authorization: Bearer $API_KEY" \ --output omni-flash-result.mp4 ``` --- # Grok 视频生成 支持视频生成、视频编辑和视频延长三种操作。三个接口共用同一查询端点。 ## Agent 调用规则 1. 按需求选择接口:生成 POST `/grok/v1/videos/generations`,编辑 `/grok/v1/videos/edits`,延长 `/grok/v1/videos/extensions`。记录返回的 `request_id`。 2. 定期 GET `/grok/v1/videos/{request_id}`,`pending` 时继续查询。 3. `done`:把 `video.url` 返回给用户。 4. `failed` 或 `expired`:把 `error` 告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 用 Grok 生成视频,也可以编辑或延长一段已有视频。三种操作提交后都返回 `request_id`,并用同一个查询接口拿结果。 ### 你需要提供的信息 - **用哪个模型**:`model`,例如 `grok-imagine-video-1.5`。 - **想要什么画面**:`prompt`;编辑和延长时写要改什么、接着发生什么。 - **素材(按操作)**:图生视频传 `image`;编辑和延长传 `video`,公网 URL 或 Base64。 ### 怎么拿到结果 - **状态**:`pending` 继续等待;`done` 完成;`failed`、`expired` 失败。 - **视频地址**:`video.url`,时长见 `video.duration`。 ## 视频生成 `POST /grok/v1/videos/generations` 从文本、图片或多模态参考素材生成视频。 ### 模型 | 模型名称 | 最高分辨率 | 说明 | |---|---|---| | `grok-imagine-video` | 720p | 支持文生、图生和多参考素材生成 | | `grok-imagine-video-1.5` | 1080p | 文生和图生支持 1080p;多参考素材上限 720p | ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `model` | string | 是 | 模型名称 | | `prompt` | string | 条件 | 文生视频和多参考素材必填;图生可选 | | `duration` | integer | 否 | 1-15 秒,默认 8 秒 | | `aspect_ratio` | string | 否 | `16:9`(默认)、`9:16`、`1:1`、`4:3`、`3:4`、`3:2`、`2:3` | | `resolution` | string | 否 | `480p`(默认)、`720p`、`1080p` | | `image` | object | 条件 | 图生视频输入,填 `url` 或 `image_url`;公网 URL 或 Base64 | | `reference_images` | array | 否 | 参考图数组,最多 7 张 | | `reference_audios` | array | 否 | 参考音频,每项可用 `url` 或 `voice_id`,最多 3 个 | > **互斥规则**:`image` 和 `reference_images` 不能同时使用。 ### 请求示例 #### 文生视频 ```bash curl https://api.o1key.com/grok/v1/videos/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine-video-1.5", "prompt": "A spacecraft crosses Saturn rings, cinematic tracking shot.", "duration": 10, "resolution": "1080p", "aspect_ratio": "16:9" }' ``` #### 图生视频 ```bash curl https://api.o1key.com/grok/v1/videos/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine-video-1.5", "image": {"url": "https://cdn.example.com/ref.jpg"}, "prompt": "让画面中的人物微笑并挥手", "duration": 10, "resolution": "1080p" }' ``` #### 多参考素材 ```bash curl https://api.o1key.com/grok/v1/videos/generations \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine-video-1.5", "prompt": "Fashion film with character from first image and style from second.", "reference_images": [ {"url": "https://cdn.example.com/char.jpg"}, {"url": "https://cdn.example.com/style.jpg"} ], "reference_audios": [{"voice_id": "nova"}], "duration": 8, "resolution": "720p" }' ``` ### 响应 ```json {"request_id": "task_grok_xxxxxxxxxx"} ``` ## 查询任务 `GET /grok/v1/videos/{task_id}` 使用创建接口返回的 `request_id` 查询任务状态和结果。 | 响应字段 | 说明 | |---|---| | `status` | `pending`(处理中)、`done`(完成)、`failed`(失败)、`expired`(过期) | | `model` | 使用的模型名称 | | `progress` | 进度百分比(0-100) | | `video.url` | 视频下载地址(完成后可用) | | `video.duration` | 视频时长(秒) | | `error` | 失败时的错误信息 | ### 请求 ```bash curl https://api.o1key.com/grok/v1/videos/ \ -H "Authorization: Bearer $API_KEY" ``` ### 响应示例 #### 完成 ```json { "status": "done", "model": "grok-imagine-video-1.5", "video": { "url": "https://cdn.example.com/grok-result.mp4", "duration": 15 }, "progress": 100 } ``` #### 处理中 ```json { "status": "pending", "model": "grok-imagine-video-1.5", "progress": 42 } ``` #### 失败 ```json { "status": "failed", "model": "grok-imagine-video", "error": { "code": "content_policy_violation", "message": "The request could not be completed." } } ``` ## 视频编辑 `POST /grok/v1/videos/edits` 基于提示词编辑输入视频。输出保持输入的时长和宽高比,分辨率上限 720p。 > **时长限制**:输入视频不超过 8.7 秒。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `model` | string | 是 | 模型名称 | | `prompt` | string | 是 | 编辑指令 | | `video` | object | 是 | 输入视频,填 `url` 或 `file_id`;公网 URL 或 Base64 | **不支持的参数**:`duration`、`aspect_ratio`、`resolution`、`image`、`reference_images`、`reference_audios` ### 请求 ```bash curl https://api.o1key.com/grok/v1/videos/edits \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine-video-1.5", "prompt": "Make the sky turn golden with a dramatic sunset, keep everything else unchanged.", "video": {"url": "https://cdn.example.com/input.mp4"} }' ``` ### 响应 ```json {"request_id": "task_grok_edit_xxxxxxxxxx"} ``` ## 视频延长 `POST /grok/v1/videos/extensions` 延长输入视频。`duration` 参数控制延长部分的时长,输出总时长 = 输入时长 + duration。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `model` | string | 是 | 模型名称 | | `prompt` | string | 是 | 延长部分的内容描述 | | `video` | object | 是 | 输入视频,填 `url` 或 `file_id`;公网 URL 或 Base64 | | `duration` | integer | 否 | 延长部分时长 2-10 秒,默认 6 秒 | **不支持的参数**:`aspect_ratio`、`resolution`、`image`、`reference_images`、`reference_audios` ### 请求 ```bash curl https://api.o1key.com/grok/v1/videos/extensions \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine-video-1.5", "prompt": "Continue the camera movement smoothly, revealing more of the landscape.", "video": {"url": "https://cdn.example.com/clip.mp4"}, "duration": 5 }' ``` 输入 10 秒视频 + duration=5 → 输出 15 秒视频。 ### 响应 ```json {"request_id": "task_grok_extend_xxxxxxxxxx"} ``` --- # Kling VIDEO 4.0 / Flash 可灵 4.0 与 4.0 Flash 的文生视频、图生视频(多关键帧)和 Omni 多素材 / 视频编辑。路径与可灵官方一致。客户端使用任务 ID 轮询状态,提交时请省略 `callback_url`。 ## Agent 调用规则 1. 按需求选路径 POST `/{text-to-video|image-to-video|omni-video}/{kling-4.0|kling-4.0-flash}`,请求体不传 `model`。记录 `data.id`。 2. Flash 只用 720p、3–20 秒;4.0 时长 3–30 秒。 3. 定期 GET `/tasks?task_ids={id}`,`submitted` 或 `processing` 时继续查询。 4. `succeeded`:把 `outputs[].url` 返回给用户,提醒约 30 天有效。 5. `failed`:把 `message` 告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 用可灵 4.0 或 4.0 Flash 生成视频。用法和可灵官方完全一样,只需把 Base URL 换成本站、使用本站 API Key。模型由路径决定,请求体里不用写 `model`。 ### 你需要提供的信息 - **做什么**:选路径:文生视频 `text-to-video`、图生视频 `image-to-video`、多素材与编辑 `omni-video`。 - **用哪个版本**:路径末尾 `kling-4.0` 或 `kling-4.0-flash`。Flash 只支持 720p、3–20 秒。 - **想要什么画面**:文生视频填 `prompt`;其余两种用 `contents` 数组放提示词和素材。 - **时长与分辨率(可选)**:`settings.duration`、`settings.resolution`、`settings.aspect_ratio`。 ### 怎么拿到结果 - **状态**:`submitted`、`processing` 继续等待;`succeeded` 成功;`failed` 失败。 - **视频地址**:`data[].outputs[].url`,通常保留 30 天,请及时保存。 ## 路径、参数与价格 > **Flash**:使用相应的 Flash 路径,将路径里的 `kling-4.0` 换成 `kling-4.0-flash`。只支持 `720p`(默认也是 `720p`),时长 3–20 秒。不要传 `1080p`,也不要超过 20 秒。 ### 创建与单任务查询 | 类型 | 提交 | 按任务 ID 查询 | |---|---|---| | 文生视频 | `POST /text-to-video/kling-4.0` | `GET /text-to-video/kling-4.0/{task_id}` | | 图生视频 | `POST /image-to-video/kling-4.0` | `GET /image-to-video/kling-4.0/{task_id}` | | Omni | `POST /omni-video/kling-4.0` | `GET /omni-video/kling-4.0/{task_id}` | | Flash 文生视频 | `POST /text-to-video/kling-4.0-flash` | `GET /text-to-video/kling-4.0-flash/{task_id}` | | Flash 图生视频 | `POST /image-to-video/kling-4.0-flash` | `GET /image-to-video/kling-4.0-flash/{task_id}` | | Flash Omni | `POST /omni-video/kling-4.0-flash` | `GET /omni-video/kling-4.0-flash/{task_id}` | - 请求头:`Authorization: Bearer `,`Content-Type: application/json`。 - 路径与可灵官方完全一致,Base URL 换成本站即可。模型由路径决定,请求体不要传 `model`。 - 创建和查询的响应与可灵官方一致:`{code, message, request_id, data}`。`data.id` 是任务 ID;`data.external_id` 对应 `options.external_task_id`。状态:`submitted`、`processing`、`succeeded`、`failed`。 - 单任务 GET 的响应也是任务数组。批量查询和游标查询与官方相同,见下表。 ### 批量与游标查询 | 查询 | 方法 | 说明 | |---|---|---| | 按任务 ID | `GET /tasks?task_ids=id1,id2` | 系统任务 ID,逗号分隔。不能与 `external_task_ids` 同时使用。 | | 按自定义 ID | `GET /tasks?external_task_ids=a,b` | 对应 `options.external_task_id`。同一 API Key 下必须唯一。 | | 游标 | `POST /tasks` | `start_time`、`end_time` 为毫秒时间戳。`cursor` 用上次返回的 `next_cursor`,传入后忽略起止时间。`limit` 默认 100,最大 500。 | ### 通用设置 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `settings.duration` | integer | 否 | 4.0:3–30 秒;Flash:3–20 秒。有填写值时以填写值为准。省略时识别提示词时长;Omni 若仍没有,则取 `base_video` 时长(取整),否则 10 秒。计费看 `usage.output_duration`。 | | `settings.resolution` | string | 否 | 4.0 支持 `720p`、`1080p`、`4k`,默认 `1080p`。Flash 只支持 `720p`,默认也是 `720p`。 | | `settings.dynamic_range` | string | 否 | 标准版默认 `sdr`。1080p 和 4K 也可设为 `hdr`。Flash 使用默认 SDR。 | | `settings.aspect_ratio` | string | 否 | 仅文生视频和 Omni:`21:9`、`16:9`、`9:16`、`1:1`、`4:3`、`3:4`。Omni 另支持 `adaptive`。图生视频不能传。 | | `settings.audio` | string | 否 | 仅 Omni。`native`(默认)按画面生成音频;`original` 保留输入视频原声。`original` 不能同时引用 `voice`,且至少要有一条 `base_video` 或 `feature_video`。有 `base_video` 用它的声音,否则用 `contents` 第一条 `feature_video` 的声音。 | | `options.external_task_id` | string | 否 | 自定义任务 ID,不覆盖 `data.id`。同一 API Key 下必须唯一。用 `GET /tasks?external_task_ids=` 查询。 | | `options.watermark_info.enabled` | boolean | 否 | 是否同时生成带水印结果,默认 `false`。传入 `false` 也会按 `false` 提交,不会省掉。不支持自定义水印。 | 提示词用 `@id` 引用素材,并写明每项用途。可灵说明:[文生视频](https://kling.ai/document-api/api/video/4-0/text-to-video)、[图生视频](https://kling.ai/document-api/api/video/4-0/image-to-video)、[Omni](https://kling.ai/document-api/api/video/4-0/video-omni)、[Flash](https://kling.ai/document-api/api/video/4-0-flash/text-to-video)。 ### 价格 打开[模型定价](/pricing),选择模型和分组即可查看当前售价。标准版列出 720p、1080p、4K 及相应的 HDR 加价。HDR 按输出视频时长收费,订单金额可在使用日志查看。 ### 创建响应 · 200 ```json { "code": 0, "message": "", "request_id": "req_xxxxxxxxxx", "data": { "id": "task_xxxxxxxxxx", "status": "submitted", "create_time": 1781080778802, "update_time": 1781080778802, "external_id": "" } } ``` 用 `data.id` 查询。时间戳单位为毫秒。 ## 文生视频 `POST /text-to-video/kling-4.0` `POST /text-to-video/kling-4.0-flash` | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `prompt` | string | 是 | 可含正向和负向描述。纯英文最多 26,000 字符,纯非英文最多 11,000 字符;混合输入须满足 E/26000 + N/11000 ≤ 1。 | | `settings.aspect_ratio` | string | 否 | `21:9`、`16:9`、`9:16`、`1:1`、`4:3`、`3:4`,默认 `16:9`。 | 也可传通用设置里的 `settings.duration`、`settings.resolution` 和 `options`。 ### 请求示例 · Kling 4.0 ```bash curl https://api.o1key.com/text-to-video/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A sunrise over a quiet harbor, gentle waves, cinematic camera movement and ambient sound.", "settings": {"duration": 10, "resolution": "1080p", "aspect_ratio": "16:9"}, "options": {"watermark_info": {"enabled": false}} }' ``` ### 请求示例 · Kling 4.0 Flash ```bash curl https://api.o1key.com/text-to-video/kling-4.0-flash \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A sunrise over a quiet harbor, gentle waves, cinematic camera movement and ambient sound.", "settings": {"duration": 8, "resolution": "720p", "aspect_ratio": "16:9"}, "options": {"watermark_info": {"enabled": false}} }' ``` ## 图生视频 · 多关键帧 `POST /image-to-video/kling-4.0` `POST /image-to-video/kling-4.0-flash` | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `contents` | array | 是 | 至少 1 张关键帧,可附提示词。图片最多 10 张。 | | `contents[].type` | string | 是 | `prompt`、`first_frame`、`middle_frame`、`last_frame`。 | | `contents[].text` | string | 条件 | `type=prompt` 时必填。字符限制与文生视频 `prompt` 相同。 | | `contents[].url` | string | 条件 | 图片项必填。可传公开 URL 或 Base64。 | | `contents[].id` | string | 否 | 任务内唯一,提示词里用 `@id` 引用。多个 `middle_frame` 时,每张图都要指定 ID。 | - 图片:JPG、JPEG、PNG。单张不超过 30 MB,宽高均不小于 300px,宽高比 2:5 至 5:2。文件属性由可灵校验。 - 不支持 `refer_image`、视频、元素、声音、`settings.aspect_ratio`、`settings.audio`。需要这些素材请用 Omni。 ### 请求示例 · 首帧 + 中间帧 + 尾帧 ```bash curl https://api.o1key.com/image-to-video/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "Transition smoothly from @first through @middle to @last; keep the character consistent."}, {"type": "first_frame", "url": "https://cdn.example.com/first.png", "id": "first"}, {"type": "middle_frame", "url": "https://cdn.example.com/middle.png", "id": "middle"}, {"type": "last_frame", "url": "https://cdn.example.com/last.png", "id": "last"} ], "settings": {"resolution": "1080p", "duration": 12} }' ``` ## Omni 多素材与视频编辑 `POST /omni-video/kling-4.0` `POST /omni-video/kling-4.0-flash` | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `contents` | array | 是 | 提示词、图片、视频、元素、声音引用的集合。 | | `contents[].type` | string | 是 | `prompt`、`first_frame`、`middle_frame`、`last_frame`、`refer_image`、`feature_video`、`base_video`、`element`、`voice`。 | | `contents[].text` | string | 条件 | 提示词项必填。字符限制与文生视频 `prompt` 相同。写明各素材用途,以及要修改和保留的内容。 | | `contents[].url` | string | 条件 | 图片或视频项必填。图片可传公开 URL 或 Base64,视频传公开 URL。 | | `contents[].element_id` | string | 条件 | `type=element` 时必填,来自下方主体接口。 | | `contents[].voice_id` | string | 条件 | `type=voice` 时必填。可用自定义或系统预设声音 ID。 | | `contents[].id` | string | 条件 | 任务内唯一,供 `@id` 引用。`element` 和 `voice` 必填;多个中间帧或参考图时也必填。 | | `settings.audio` | string | 否 | `native` 或 `original`,默认 `native`。省略即按 `native` 处理,不必为了默认值传入。 | | `settings.aspect_ratio` | string | 否 | `21:9`、`16:9`、`9:16`、`1:1`、`4:3`、`3:4`、`adaptive`,默认 `adaptive`。省略或设为 `adaptive` 时:先用提示词中的比例,再参考基础视频、关键帧及其他视频,最后默认 16:9。 | ### 素材限制 | 素材 | 数量 | 规格 | |---|---|---| | 图片 | 最多 10 张 | JPG、JPEG、PNG。单张不超过 30 MB,宽高均不小于 300px,宽高比 2:5 至 5:2。 | | 参考视频 | 最多 5 个;`base_video` 最多 1 个;与视频角色元素合计最多 5 个 | MP4、MOV,单个不超过 300 MB。每个及合计时长:4.0 为 3–30 秒,Flash 为 3–20 秒(含视频角色元素)。帧率 24–60 fps。宽、高各 700–4553px,总像素不超过 8,294,400,宽高比 2:5 至 5:2。 | | 元素 / 声音 | 元素最多 7 个,其中视频角色元素最多 3 个;声音最多 3 个 | 图片、视频、元素、声音总数最多 15 个。 | | 校验 | 本接口先校验字段、枚举、ID 和数量。文件大小、分辨率、输入视频时长和元素类型等媒体属性由可灵校验。 | | ### 参考视频 + 参考图 ```bash curl https://api.o1key.com/omni-video/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "Follow the movement rhythm in @video_1; preserve the character appearance from @image_1, not the video background."}, {"type": "feature_video", "url": "https://cdn.example.com/motion.mp4", "id": "video_1"}, {"type": "refer_image", "url": "https://cdn.example.com/person.png", "id": "image_1"} ], "settings": {"duration": 15, "resolution": "1080p", "aspect_ratio": "adaptive", "audio": "original"} }' ``` ### 编辑视频 + 元素 ```bash curl https://api.o1key.com/omni-video/kling-4.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "Edit @video_1: place @element_1 inside the box at the end. Preserve the earlier shots and background."}, {"type": "base_video", "url": "https://cdn.example.com/source.mp4", "id": "video_1"}, {"type": "element", "element_id": "164", "id": "element_1"} ], "settings": {"duration": 10, "resolution": "1080p", "audio": "native"} }' ``` ### 声音引用 ```json { "contents": [ {"type": "prompt", "text": "Use @image_1 as the character. She says 'Excuse me' using @voice_1, with accurate lip sync."}, {"type": "refer_image", "url": "https://cdn.example.com/person.png", "id": "image_1"}, {"type": "voice", "voice_id": "829826751244537879", "id": "voice_1"} ], "settings": {"duration": 5, "aspect_ratio": "9:16", "audio": "native"} } ``` ## 查询任务(GET / POST /tasks) `GET /tasks` `POST /tasks` 用创建响应的 `data.id`,或创建时的 `options.external_task_id`。查询使用同一 API Key。`/tasks` 也能查 [Kling 3.0、3.0 Omni、动作模仿](/docs/kling-3.md) 和 [Kling Image 4.0](/docs/image-kling.md) 的任务,返回结构相同。 | 响应字段 | 说明 | |---|---| | `code` | 成功为 `0`。 | | `data[].id` | 任务 ID,与创建响应的 `data.id` 相同。 | | `data[].status` | `submitted`、`processing`、`succeeded`、`failed`。 | | `data[].message` | 失败时为失败原因。 | | `data[].outputs` | 成功后的结果。视频项含 `type`、`id`、`url`、`watermark_url`、`duration`。`duration` 是成片时长,单位秒。结果链接通常保留 30 天,请及时保存。 | | `data[].usage.output_duration` | 计费用的输出时长,单位秒。有 `settings.duration` 时用该值;否则用提示词中的时长;都没有时,Omni 用 `base_video` 取整后的时长,再否则为 10 秒。计算费用用这个字段,不要用 `outputs[].duration`。 | | `data[].usage.input_duration` | 输入视频总时长,保留两位小数的字符串。只在有视频输入且任务结束后返回,含 `feature_video`、`base_video` 和视频角色主体。时长按归一化后的视频计算,可能和原文件略有差别。 | | `data[].external_id` | 自定义任务 ID。 | | `data[].create_time` / `update_time` | 毫秒时间戳。 | 游标查询的 `data` 是对象:任务在 `data.result`,并带 `count`、`next_cursor`、`has_more`。`filters.status` 可用 `submitted`、`processing`、`succeeded`、`failed`;`filters.product_type` 中,视频任务为 `video`。 ### 批量查询 ```bash curl "https://api.o1key.com/tasks?task_ids=task_a,task_b" \ -H "Authorization: Bearer $API_KEY" ``` ### 成功响应 ```json { "code": 0, "message": "", "request_id": "req_xxxxxxxxxx", "data": [ { "id": "task_xxxxxxxxxx", "status": "succeeded", "message": "", "create_time": 1781080778802, "update_time": 1781080794151, "external_id": "", "outputs": [ { "type": "video", "id": "video_xxxxxxxxxx", "url": "https://cdn.example.com/result.mp4", "watermark_url": "", "duration": "10.2" } ], "usage": { "input_duration": "8.03", "output_duration": "10" } } ] } ``` ID、链接仅为示例。文生、图生、Omni 的单任务 GET(`kling-4.0` 与 `kling-4.0-flash`)返回同一结构,路径见本节开头。 ## 主体与声音 主体和声音使用可灵官方路径,Base URL 换成本站即可。请求体和响应字段:`code`、`message`、`request_id`、`data`。创建类任务状态:`submitted`、`processing`、`succeed`、`failed`。 | 操作 | 路径 | |---|---| | 创建主体 | `POST /v1/general/advanced-custom-elements` | | 查询主体 | `GET /v1/general/advanced-custom-elements/{task_id}` | | 主体列表 | `GET /v1/general/advanced-custom-elements?pageNum=1&pageSize=30` | | 预设主体 | `GET /v1/general/advanced-presets-elements?pageNum=1&pageSize=30` | | 删除主体 | `POST /v1/general/delete-advanced-elements`,正文 `{"element_id":"..."}` | | 创建声音 | `POST /v1/general/custom-voices` | | 查询声音 | `GET /v1/general/custom-voices/{task_id}` | | 声音列表 | `GET /v1/general/custom-voices?pageNum=1&pageSize=30` | | 预设声音 | `GET /v1/general/presets-voices?pageNum=1&pageSize=30` | | 删除声音 | `POST /v1/general/delete-voices`,正文 `{"voice_id":"..."}` | | 操作 | 字段 | |---|---| | 创建主体 | `element_name`、`element_description`、`reference_type`(`image_refer` 或 `video_refer`)、`element_image_list` 或 `element_video_list`、`element_voice_id`、`tag_list`、`external_task_id` | | 创建声音 | `voice_name`,且 `voice_url` 与 `video_id` 只填一个 | ### 创建多图主体 ```bash curl https://api.o1key.com/v1/general/advanced-custom-elements \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "element_name": "角色甲", "element_description": "正面与侧面参考", "reference_type": "image_refer", "element_image_list": { "frontal_image": "https://cdn.example.com/front.png", "refer_images": [{"image_url": "https://cdn.example.com/side.png"}] } }' ``` --- # Kling VIDEO 3.0 可灵 3.0 文生视频、图生视频、3.0 Omni(多素材参考、视频编辑)和动作模仿。路径与可灵官方一致,提交后返回 `data.id`,用 `GET /tasks` 查询。客户端使用任务 ID 轮询状态,提交时请省略 `callback_url`。 ## Agent 调用规则 1. 按需求选路径:POST `/text-to-video/kling-3.0`、`/image-to-video/kling-3.0`、`/omni-video/kling-3.0-omni` 或 `/motion-control/kling-3.0`。请求体不传 `model`。记录 `data.id`。 2. 定期 GET `/tasks?task_ids={id}`,`submitted` 或 `processing` 时继续查询。 3. `succeeded`:把 `data[0].outputs[0].url` 返回给用户。 4. `failed`:把 `data[0].message` 告诉用户,不要自动重试。 ## 简明说明 ### 这个接口做什么? 用可灵 3.0 生成视频:文生视频只用提示词;图生视频用首帧(可加尾帧和主体);Omni 可以组合提示词、首尾帧、参考图和参考视频,也能编辑视频;动作模仿让图片中的角色按一段视频的动作动起来。用法和可灵官方完全一样,只需把 Base URL 换成本站、使用本站 API Key。 ### 你需要提供的信息 - **做什么**:文生视频 `/text-to-video/kling-3.0`,图生视频 `/image-to-video/kling-3.0`,Omni `/omni-video/kling-3.0-omni`,动作模仿 `/motion-control/kling-3.0`。 - **提示词和素材**:文生视频用 `prompt`;其他接口用 `contents` 数组:`prompt` 项写描述,图片、视频项填 `url`。 - **输出设置**:`settings`:时长、分辨率、音频;文生视频和 Omni 还可以设画面比例。 ### 怎么拿到结果 - **状态**:`submitted`、`processing` 继续等待;`succeeded` 成功;`failed` 失败。 - **视频地址**:`data[].outputs[].url`。计费时长见 `usage.output_duration`。 ## 路径与查询 ### 创建与单任务查询 | 类型 | 提交 | 按任务 ID 查询 | |---|---|---| | 文生视频 | `POST /text-to-video/kling-3.0` | `GET /text-to-video/kling-3.0/{task_id}` | | 图生视频 | `POST /image-to-video/kling-3.0` | `GET /image-to-video/kling-3.0/{task_id}` | | Omni | `POST /omni-video/kling-3.0-omni` | `GET /omni-video/kling-3.0-omni/{task_id}` | | 动作模仿 | `POST /motion-control/kling-3.0` | `GET /motion-control/kling-3.0/{task_id}` | - 请求头:`Authorization: Bearer `,`Content-Type: application/json`。 - 路径与可灵官方完全一致,Base URL 换成本站即可。模型由路径决定,请求体不要传 `model`。 - 创建和查询的响应与可灵官方一致:`{code, message, request_id, data}`。`data.id` 是任务 ID。状态:`submitted`、`processing`、`succeeded`、`failed`。 - 批量查询 `GET /tasks?task_ids=`、按自定义 ID 查询 `GET /tasks?external_task_ids=` 和游标查询 `POST /tasks` 的参数与 4.0 相同,见 [查询任务](/docs/kling-4.md)。 - 不支持 `options.callback_url`,请用任务 ID 轮询。 可灵说明:[文生视频](https://kling.ai/document-api/api/video/3-0-omni/text-to-video)、[图生视频](https://kling.ai/document-api/api/video/3-0-omni/image-to-video)、[Omni](https://kling.ai/document-api/api/video/3-0-omni/video-omni)、[动作模仿](https://kling.ai/document-api/api/video/motion-control)。 ### 价格 打开[模型定价](/pricing),选择模型和分组即可查看当前售价。实际扣费以你所在分组的倍率为准。 ### 查询任务 ```bash curl "https://api.o1key.com/tasks?task_ids=task_xxxxxxxxxx" \ -H "Authorization: Bearer $API_KEY" ``` ### 成功响应 ```json { "code": 0, "message": "SUCCEED", "request_id": "req_xxxxxxxxxx", "data": [ { "id": "task_xxxxxxxxxx", "status": "succeeded", "message": "", "create_time": 1781080778802, "update_time": 1781080794151, "external_id": "", "outputs": [ { "type": "video", "id": "video_xxxxxxxxxx", "url": "https://cdn.example.com/result.mp4", "watermark_url": "", "duration": "5.04" } ], "usage": {"output_duration": "5"} } ] } ``` ID、链接仅为示例。处理中时 `status` 为 `processing`,没有 `outputs`;失败时 `status` 为 `failed`,原因在 `message`。 ## 文生视频 `POST /text-to-video/kling-3.0` 只用提示词生成视频。要用图片或视频做参考,请用 [Omni](#/omni-video/kling-3.0-omni)。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `prompt` | string | 是 | 描述画面、动作和镜头,最多 3072 字符。 | | `settings.duration` | integer | 否 | 3–15 秒的整数。 | | `settings.resolution` | string | 否 | `720p`、`1080p`、`4k`。 | | `settings.aspect_ratio` | string | 否 | `16:9`、`9:16`、`1:1`。 | | `settings.audio` | string | 否 | `native` 按画面生成音频;`off` 无音频。 | | `settings.multi_shot` | boolean | 否 | 是否生成多镜头。多镜头提示词写法为“镜头序号, 秒数, 描述;”。 | | `options.external_task_id` | string | 否 | 自定义任务 ID,账号内唯一。用 `GET /tasks?external_task_ids=` 查询。 | | `options.watermark_info.enabled` | boolean | 否 | 是否同时生成带水印结果,默认 `false`。 | 只接受上表字段,其他字段会返回 400。 ### 请求示例 ```bash curl https://api.o1key.com/text-to-video/kling-3.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A cinematic sunrise over a quiet harbor, gentle waves and seagulls.", "settings": {"duration": 5, "resolution": "1080p", "aspect_ratio": "16:9", "audio": "native"} }' ``` ### 响应示例 #### 成功 · 200 ```json { "code": 0, "message": "", "request_id": "req_xxxxxxxxxx", "data": { "id": "task_xxxxxxxxxx", "status": "submitted", "create_time": 1781080778802, "update_time": 1781080778802, "external_id": "" } } ``` #### 失败 · 400 ```json { "code": 1201, "message": "prompt is required", "request_id": "req_xxxxxxxxxx" } ``` ## 图生视频 `POST /image-to-video/kling-3.0` 用首帧生成视频,可加尾帧和最多 3 个主体。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `contents` | array | 是 | 首帧、尾帧、提示词和主体。 | | `contents[].type` | string | 是 | `first_frame`(必须且只能 1 个)、`last_frame`(最多 1 个)、`prompt`、`element`(最多 3 个)。 | | `contents[].url` | string | 条件 | 首帧、尾帧必填。公开 URL 或 Base64。 | | `contents[].text` | string | 条件 | `type=prompt` 时必填,最多 3072 字符。 | | `contents[].element_id` | string | 条件 | `type=element` 时必填,来自 [主体管理](/docs/kling-4.md)。 | | `contents[].id` | string | 否 | 任务内唯一,可在提示词中用 `@id` 引用。 | | `settings` | object | 否 | 同文生视频的 `duration`、`resolution`、`audio`、`multi_shot`。不能传 `aspect_ratio`,比例跟随首帧。 | | `options` | object | 否 | 同文生视频。 | ### 请求示例 ```bash curl https://api.o1key.com/image-to-video/kling-3.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "The girl turns around and smiles, the camera slowly pushes in."}, {"type": "first_frame", "url": "https://cdn.example.com/start.png"}, {"type": "last_frame", "url": "https://cdn.example.com/end.png"} ], "settings": {"duration": 5, "resolution": "1080p", "audio": "off"} }' ``` ### 响应示例 #### 成功 · 200 ```json { "code": 0, "message": "", "request_id": "req_xxxxxxxxxx", "data": { "id": "task_xxxxxxxxxx", "status": "submitted", "create_time": 1781080778802, "update_time": 1781080778802, "external_id": "" } } ``` #### 失败 · 400 ```json { "code": 1201, "message": "image-to-video requires one first_frame and at most one last_frame", "request_id": "req_xxxxxxxxxx" } ``` ## Kling 3.0 Omni 视频生成 `POST /omni-video/kling-3.0-omni` 使用官方 `contents`、`settings`、`options` 结构,模型由路径决定,不要传 `model`。返回 `data.id`,用 [GET /tasks](/docs/kling-4.md) 查询。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `contents` | array | 是 | 提示词、图片和视频输入集合。 | | `contents[].type` | string | 是 | `prompt`、`first_frame`、`last_frame`、`refer_image`、`feature_video`、`base_video`。 | | `contents[].text` | string | 条件 | `type=prompt` 时必填。官方上限 3072 字符,建议不超过 2500 字符。 | | `contents[].url` | string | 条件 | 图片支持公开 URL 或 Base64;视频使用可公开访问的 URL。 | | `contents[].id` | string | 否 | 任务内唯一的引用 ID,可在提示词中以 `@id` 引用。 | | `settings` | object | 条件 | 输出设置。没有首帧或参考视频时必须提供,并填写 `aspect_ratio`。 | | `settings.multi_shot` | boolean | 否 | 是否生成多镜头,默认 `true`。 | | `settings.audio` | string | 否 | `native` 生成原生音频;`original` 保留参考视频声音;`off` 无音频。默认 `off`。 | | `settings.resolution` | string | 否 | `720p`、`1080p`、`4k`,默认 `720p`。 | | `settings.aspect_ratio` | string | 条件 | `16:9`、`9:16`、`1:1`。没有首帧或参考视频时必填。 | | `settings.duration` | integer | 否 | 3-15 秒的整数,默认 5 秒。 | | `options.external_task_id` | string | 否 | 调用方自定义且账号内唯一的任务 ID。 | | `options.watermark_info.enabled` | boolean | 否 | 是否同时生成带水印结果,默认 `false`。 | ### 素材与组合规则 - 图片支持 JPG、JPEG、PNG,单文件不超过 50MB;宽高均不低于 300px,宽高比在 1:2.5 至 2.5:1 之间。 - 首尾帧仅支持“仅首帧”或“首帧 + 尾帧”,不支持只传尾帧。 - 视频支持 MP4、MOV,单文件不超过 200MB,时长 3-15.5 秒;最多传入 1 个参考视频。 - `feature_video` 用作特征参考:`multi_shot` 必须为 `true`,`audio` 使用 `off`。 - `base_video` 用作视频编辑:不能同时传首尾帧,`multi_shot` 必须为 `false`,`audio` 可用 `original` 或 `off`。 - 多镜头提示词写法为“镜头序号, 秒数, 描述;”,支持 1-6 个镜头;各镜头时长之和必须等于 `settings.duration`。 ### 请求示例 #### 纯文本 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "A cinematic sunrise over a quiet harbor, gentle waves and native ambient sound."} ], "settings": { "resolution": "1080p", "aspect_ratio": "16:9", "duration": 5, "audio": "native", "multi_shot": false } }' ``` #### 首帧 + 参考图 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "@image_1 walks into the scene; match the color palette of @image_2."}, {"type": "first_frame", "url": "https://cdn.example.com/start.png", "id": "image_1"}, {"type": "refer_image", "url": "https://cdn.example.com/style.png", "id": "image_2"} ], "settings": {"resolution": "1080p", "duration": 5, "audio": "native", "multi_shot": false} }' ``` #### 首尾帧 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "Create a smooth cinematic transition from @start to @end."}, {"type": "first_frame", "url": "https://cdn.example.com/start.jpg", "id": "start"}, {"type": "last_frame", "url": "https://cdn.example.com/end.jpg", "id": "end"} ], "settings": {"resolution": "1080p", "duration": 8, "audio": "off", "multi_shot": false} }' ``` #### Base64 图片 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "Animate @image_1 with a slow camera push-in."}, {"type": "first_frame", "url": "data:image/png;base64,iVBORw0KGgoAAA...", "id": "image_1"} ], "settings": {"resolution": "720p", "duration": 5, "audio": "off", "multi_shot": false} }' ``` #### 多模态 · 图 + 视频 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ { "type": "prompt", "text": "Use @image_1 as the character and clothing reference; reproduce the camera movement and action rhythm of @video_1." }, { "type": "refer_image", "url": "https://cdn.example.com/character.png", "id": "image_1" }, { "type": "feature_video", "url": "https://cdn.example.com/camera-and-motion.mp4", "id": "video_1" } ], "settings": { "resolution": "1080p", "audio": "off", "multi_shot": true }, "options": { "external_task_id": "omni-multimodal-001", "watermark_info": {"enabled": false} } }' ``` #### 多镜头 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ { "type": "prompt", "text": "shot 1, 3, Wide shot: a traveler walks across a misty mountain ridge at sunrise; shot 2, 3, Close-up: the traveler stops, turns toward the warm sunlight, and smiles;" } ], "settings": { "resolution": "1080p", "aspect_ratio": "16:9", "duration": 6, "audio": "native", "multi_shot": true }, "options": { "external_task_id": "omni-multishot-001", "watermark_info": {"enabled": false} } }' ``` #### 特征视频 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "Use the camera rhythm and visual features of @video_1."}, {"type": "feature_video", "url": "https://cdn.example.com/reference.mp4", "id": "video_1"} ], "settings": {"resolution": "4k", "audio": "off", "multi_shot": true} }' ``` #### 基础视频 ```bash curl https://api.o1key.com/omni-video/kling-3.0-omni \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "Change the weather to light rain while preserving the original subject and motion."}, {"type": "base_video", "url": "https://cdn.example.com/source.mov", "id": "video_1"} ], "settings": {"resolution": "1080p", "audio": "original", "multi_shot": false} }' ``` ### 响应示例 #### 成功 · 200 ```json { "code": 0, "message": "", "request_id": "req_xxxxxxxxxx", "data": { "id": "task_xxxxxxxxxx", "status": "submitted", "create_time": 1781080778802, "update_time": 1781080778802, "external_id": "" } } ``` #### 失败 · 400 ```json { "code": 1201, "message": "settings.aspect_ratio is required when no first frame or reference video is provided", "request_id": "req_xxxxxxxxxx" } ``` ## Kling 3.0 动作模仿 `POST /motion-control/kling-3.0` 请求体沿用 Kling 3.0 Motion Control 官方结构。每个任务提供 1 张角色外观参考图和 1 个动作参考视频;模型由路径决定。返回 `data.id`,用 [GET /tasks](/docs/kling-4.md) 查询。 ### 请求参数 | 字段 | 类型 | 必填 | 说明 | |---|---|---|---| | `contents` | array | 是 | 由提示词、角色图片和动作视频组成。 | | `contents[].type` | string | 是 | 本页展示 `prompt`、`image`、`video`。 | | `contents[].text` | string | 条件 | `type=prompt` 时必填,最多 2500 字符;提示词本身可省略。 | | `contents[].url` | string | 条件 | 图片支持公开 URL 或 Base64;动作视频使用公开 URL。 | | `settings.character_orientation` | string | 是 | `video`:朝向跟随动作视频;`image`:朝向跟随参考图。 | | `settings.audio` | string | 否 | `original` 保留动作视频原声;`off` 无音频。默认 `original`。 | | `settings.resolution` | string | 否 | `720p`、`1080p`,默认 `720p`。 | | `options.external_task_id` | string | 否 | 调用方自定义且账号内唯一的任务 ID。 | | `options.watermark_info.enabled` | boolean | 否 | 是否同时生成带水印结果,默认 `false`。 | ### 素材规则 - 必须且只能传 1 个 `image` 和 1 个 `video`。 - 图片支持 JPG、JPEG、PNG,最大 50MB;宽高均不低于 300px,宽高比在 1:2.5 至 2.5:1 之间。 - 动作视频支持 MP4、MOV,最大 100MB,宽高均在 340-3850px 之间;建议使用人物完整可见、无遮挡、无切镜、无明显运镜的连续单镜头。 - `character_orientation=video` 时动作视频可为 3-30 秒;设为 `image` 时可为 3-10 秒。 - `video` 更适合复杂动作;`image` 保持参考图朝向,并更适合通过提示词控制镜头运动。 ### 请求示例 #### 朝向跟随视频 ```bash curl https://api.o1key.com/motion-control/kling-3.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "The character wears a loose gray T-shirt and denim shorts."}, {"type": "image", "url": "https://cdn.example.com/character.png"}, {"type": "video", "url": "https://cdn.example.com/dance-10s.mp4"} ], "settings": { "character_orientation": "video", "resolution": "1080p", "audio": "original" }, "options": { "external_task_id": "motion-order-001", "watermark_info": {"enabled": false} } }' ``` #### 朝向跟随图片 ```bash curl https://api.o1key.com/motion-control/kling-3.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "prompt", "text": "The camera slowly pulls back while the character performs the reference motion."}, {"type": "image", "url": "https://cdn.example.com/character.jpg"}, {"type": "video", "url": "https://cdn.example.com/motion-8s.mov"} ], "settings": { "character_orientation": "image", "resolution": "1080p", "audio": "off" } }' ``` #### Base64 图片 ```bash curl https://api.o1key.com/motion-control/kling-3.0 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [ {"type": "image", "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."}, {"type": "video", "url": "https://cdn.example.com/motion-6s.mp4"} ], "settings": { "character_orientation": "video", "resolution": "720p", "audio": "original" } }' ``` ### 响应示例 #### 成功 · 200 ```json { "code": 0, "message": "", "request_id": "req_xxxxxxxxxx", "data": { "id": "task_xxxxxxxxxx", "status": "submitted", "create_time": 1781080778802, "update_time": 1781080778802, "external_id": "" } } ``` #### 失败 · 400 ```json { "code": 1201, "message": "motion control requires exactly one image and one video", "request_id": "req_xxxxxxxxxx" } ```