# Seedance 2.0 Mini · CS — Scenepond API

模型 ID: `scenepond-cs/seedance-2.0-mini/image-to-video`

模型开发者: ByteDance

用途: 图生视频

原始页面: https://open.scenepond.ai/zh/models/scenepond-cs/seedance-2.0-mini/image-to-video#api

API 地址: `https://open.scenepond.ai/v1`

每次请求使用 Authorization: Bearer 和 Scenepond API Key 认证；密钥保存在服务器。

## Scenepond 异步任务

`POST /v1/tasks`

### 请求参数

- `model` — **必填**; `string`. 使用此处显示的完整公开模型 ID。

- `parameters` — **必填**; `object`. 此模型的生成参数。

### parameters 中的字段

仅在提供 parameters 时适用；子字段必填不代表可选的父字段也必填。

- `parameters.prompt` — **必填**; `string`. 提示词
  - 约束: 最少字符数: 1; 最多字符数: 5000; 须至少包含一个非空白字符。

- `parameters.image_url` — **条件必填**; `string`. 参考图
  - reference_assets、image_url 和 start_image_url 至少填写一项。
  - 约束: reference_assets[].url, image_url, start_image_url, end_image_url：使用 HTTP 或 HTTPS 地址。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含用户名或密码。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含空白字符。; 同时传入 image_url 和 start_image_url 时，两者的值须一致。; image_url, start_image_url, end_image_url, reference_assets[].url 也可使用你本人上传且尚未过期的 scenepond-input:// 图片引用。

- `parameters.reference_assets` — **条件必填**; `array<JSON value>`. 明确指定素材类型和角色的参考素材。
  - reference_assets、image_url 和 start_image_url 至少填写一项。
  - 约束: 最少项数: 1; 最多项数: 2; reference_assets[].url, image_url, start_image_url, end_image_url：使用 HTTP 或 HTTPS 地址。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含用户名或密码。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含空白字符。; image_url, start_image_url, end_image_url, reference_assets[].url 也可使用你本人上传且尚未过期的 scenepond-input:// 图片引用。

### parameters.reference_assets 中的字段

仅在提供 parameters.reference_assets 时适用；子字段必填不代表可选的父字段也必填。

- `parameters.reference_assets[].role` — **可选**; `string`. 必填首帧使用 first_frame，可选尾帧使用 last_frame。
  - 约束: 可选值: "first_frame", "last_frame"


- `parameters.aspect_ratio` — **可选**; `string`. 画幅
  - 默认: `"16:9"`
  - 约束: 可选值: "adaptive", "21:9", "16:9", "9:16", "4:3", "1:1", "3:4"

- `parameters.duration` — **可选**; `integer`. 时长
  - 默认: `5`
  - 约束: 最小值: 4; 最大值: 15

- `parameters.end_image_url` — **可选**; `string | null`. 尾帧
  - 约束: reference_assets[].url, image_url, start_image_url, end_image_url：使用 HTTP 或 HTTPS 地址。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含用户名或密码。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含空白字符。; image_url, start_image_url, end_image_url, reference_assets[].url 也可使用你本人上传且尚未过期的 scenepond-input:// 图片引用。

- `parameters.resolution` — **可选**; `string`. 分辨率
  - 默认: `"720p"`
  - 约束: 可选值: "480p", "720p"

<details>
<summary>兼容参数</summary>

- `parameters.start_image_url` — **条件必填**; `string`. 首帧
  - reference_assets、image_url 和 start_image_url 至少填写一项。
  - 约束: reference_assets[].url, image_url, start_image_url, end_image_url：使用 HTTP 或 HTTPS 地址。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含用户名或密码。; reference_assets[].url, image_url, start_image_url, end_image_url：地址不得包含空白字符。; 同时传入 image_url 和 start_image_url 时，两者的值须一致。; image_url, start_image_url, end_image_url, reference_assets[].url 也可使用你本人上传且尚未过期的 scenepond-input:// 图片引用。

</details>


- `callback_url` — **可选**; `string`. 可选的任务完成回调。请使用不超过 2048 字节的公网 HTTPS 地址，不能包含身份凭证或片段标识。

### 请求头

- `headers.Authorization` — **必填**; `string`. Bearer 后接你的 Scenepond API Key。

- `headers.Content-Type` — **必填**; `string`. 提交任务时使用 application/json。

- `headers.X-Scenepond-Max-Reservation` — **可选**; `string`. 可选的初始预留额度上限，以配额单位计。最终用量结算可能不同。若所需预留额度超过此上限，将在发送给供应商前以 reservation_changed 拒绝请求。
  - 约束: 整数值 = 0..2147483647

- `headers.Idempotency-Key` — **可选**; `string`. 可选的回执查询键，值区分大小写，作用范围为当前用户和 API 令牌。仅发送一个值；查询回执时，请保留原始请求字节和预留额度请求头。
  - 约束: 使用 8–128 个 ASCII 字符，仅限英文字母、数字、下划线（_）或连字符（-）。

### 最小调用

#### cURL

```bash
curl --fail-with-body -X POST "https://open.scenepond.ai/v1/tasks" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "image_url": "https://example.com/reference.png"
  }
}
JSON
```

#### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

payload = json.loads("{\n  \"model\": \"scenepond-cs/seedance-2.0-mini/image-to-video\",\n  \"parameters\": {\n    \"prompt\": \"A quiet lakeside at sunrise, soft light and a clear subject.\",\n    \"image_url\": \"https://example.com/reference.png\"\n  }\n}")

request = Request(
    "https://open.scenepond.ai/v1/tasks",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
    },
    data=json.dumps(payload).encode("utf-8"),
    method="POST",
)
with urlopen(request) as response:
    result = json.load(response)
print(json.dumps(result, indent=2))
```

#### JavaScript

```javascript
const response = await fetch("https://open.scenepond.ai/v1/tasks", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "image_url": "https://example.com/reference.png"
  }
})
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
const result = await response.json();
console.log(result);
```

### 可选参数示例

#### 包含可选参数的请求 1

##### cURL

```bash
curl --fail-with-body -X POST "https://open.scenepond.ai/v1/tasks" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "image_url": "https://example.com/reference.png",
    "aspect_ratio": "16:9",
    "duration": 5,
    "end_image_url": "https://example.com/reference.png",
    "resolution": "720p"
  }
}
JSON
```

##### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

payload = json.loads("{\n  \"model\": \"scenepond-cs/seedance-2.0-mini/image-to-video\",\n  \"parameters\": {\n    \"prompt\": \"A quiet lakeside at sunrise, soft light and a clear subject.\",\n    \"image_url\": \"https://example.com/reference.png\",\n    \"aspect_ratio\": \"16:9\",\n    \"duration\": 5,\n    \"end_image_url\": \"https://example.com/reference.png\",\n    \"resolution\": \"720p\"\n  }\n}")

request = Request(
    "https://open.scenepond.ai/v1/tasks",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
    },
    data=json.dumps(payload).encode("utf-8"),
    method="POST",
)
with urlopen(request) as response:
    result = json.load(response)
print(json.dumps(result, indent=2))
```

##### JavaScript

```javascript
const response = await fetch("https://open.scenepond.ai/v1/tasks", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "image_url": "https://example.com/reference.png",
    "aspect_ratio": "16:9",
    "duration": 5,
    "end_image_url": "https://example.com/reference.png",
    "resolution": "720p"
  }
})
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
const result = await response.json();
console.log(result);
```

#### 使用回执查询键提交 2

每次新的生成都应使用新的键。请完整保留原始键和请求，以便查询提交回执；不要自动另行提交生成任务。

##### cURL

```bash
curl --fail-with-body -X POST "https://open.scenepond.ai/v1/tasks" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY" \
  -H "Idempotency-Key: example_request_001" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "image_url": "https://example.com/reference.png"
  }
}
JSON
```

##### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

payload = json.loads("{\n  \"model\": \"scenepond-cs/seedance-2.0-mini/image-to-video\",\n  \"parameters\": {\n    \"prompt\": \"A quiet lakeside at sunrise, soft light and a clear subject.\",\n    \"image_url\": \"https://example.com/reference.png\"\n  }\n}")

request = Request(
    "https://open.scenepond.ai/v1/tasks",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
        "Idempotency-Key": "example_request_001",
    },
    data=json.dumps(payload).encode("utf-8"),
    method="POST",
)
with urlopen(request) as response:
    result = json.load(response)
print(json.dumps(result, indent=2))
```

##### JavaScript

```javascript
const response = await fetch("https://open.scenepond.ai/v1/tasks", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "example_request_001"
  },
  body: JSON.stringify({
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "image_url": "https://example.com/reference.png"
  }
})
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
const result = await response.json();
console.log(result);
```

<details>
<summary>兼容参数示例</summary>

#### 包含可选参数的请求 1

##### cURL

```bash
curl --fail-with-body -X POST "https://open.scenepond.ai/v1/tasks" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "start_image_url": "https://example.com/reference.png"
  }
}
JSON
```

##### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

payload = json.loads("{\n  \"model\": \"scenepond-cs/seedance-2.0-mini/image-to-video\",\n  \"parameters\": {\n    \"prompt\": \"A quiet lakeside at sunrise, soft light and a clear subject.\",\n    \"start_image_url\": \"https://example.com/reference.png\"\n  }\n}")

request = Request(
    "https://open.scenepond.ai/v1/tasks",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
    },
    data=json.dumps(payload).encode("utf-8"),
    method="POST",
)
with urlopen(request) as response:
    result = json.load(response)
print(json.dumps(result, indent=2))
```

##### JavaScript

```javascript
const response = await fetch("https://open.scenepond.ai/v1/tasks", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "parameters": {
    "prompt": "A quiet lakeside at sunrise, soft light and a clear subject.",
    "start_image_url": "https://example.com/reference.png"
  }
})
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
const result = await response.json();
console.log(result);
```

</details>

### 后续请求

#### 2. 查询任务状态

每隔几秒查询一次，直到 succeeded 或 failed。

`GET /v1/tasks/{task_id}`

##### cURL

```bash
curl --fail-with-body -X GET "https://open.scenepond.ai/v1/tasks/$SCENEPOND_TASK_ID" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY"
```

##### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

request = Request(
    "https://open.scenepond.ai/v1/tasks/" + quote(os.environ["SCENEPOND_TASK_ID"], safe="") + "",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
    },
    method="GET",
)
with urlopen(request) as response:
    result = json.load(response)
print(json.dumps(result, indent=2))
```

##### JavaScript

```javascript
if (!process.env.SCENEPOND_TASK_ID) throw new Error("Set SCENEPOND_TASK_ID first");
const response = await fetch("https://open.scenepond.ai/v1/tasks/" + encodeURIComponent(process.env.SCENEPOND_TASK_ID) + "", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json"
  }
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
const result = await response.json();
console.log(result);
```

#### 3. 获取生成结果

任务 succeeded 后列出产物，并使用同一个 API Key 下载各个 content_url。

`GET /v1/tasks/{task_id}/artifacts`

##### cURL

```bash
curl --fail-with-body -X GET "https://open.scenepond.ai/v1/tasks/$SCENEPOND_TASK_ID/artifacts" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY"
```

##### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

request = Request(
    "https://open.scenepond.ai/v1/tasks/" + quote(os.environ["SCENEPOND_TASK_ID"], safe="") + "/artifacts",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
    },
    method="GET",
)
with urlopen(request) as response:
    result = json.load(response)
print(json.dumps(result, indent=2))
```

##### JavaScript

```javascript
if (!process.env.SCENEPOND_TASK_ID) throw new Error("Set SCENEPOND_TASK_ID first");
const response = await fetch("https://open.scenepond.ai/v1/tasks/" + encodeURIComponent(process.env.SCENEPOND_TASK_ID) + "/artifacts", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json"
  }
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
const result = await response.json();
console.log(result);
```

#### 4. 到期前下载

将 SCENEPOND_TASK_ID 设为 task_id，将 SCENEPOND_ARTIFACT_KEY 设为 artifacts[].key。请在 expires_at 到期前下载二进制文件。内容接口支持 GET、HEAD 和 Range 请求；仅保存 content_url 无法保留媒体文件。

`GET /v1/tasks/{task_id}/artifacts/{artifact_key}/content`

##### cURL

```bash
curl --fail-with-body --output output.bin -X GET "https://open.scenepond.ai/v1/tasks/$SCENEPOND_TASK_ID/artifacts/$SCENEPOND_ARTIFACT_KEY/content" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY"
```

##### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

request = Request(
    "https://open.scenepond.ai/v1/tasks/" + quote(os.environ["SCENEPOND_TASK_ID"], safe="") + "/artifacts/" + quote(os.environ["SCENEPOND_ARTIFACT_KEY"], safe="") + "/content",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
    },
    method="GET",
)
with urlopen(request) as response:
    with open("output.bin", "wb") as output:
        output.write(response.read())
print("Saved output.bin")
```

##### JavaScript

```javascript
import { writeFile } from "node:fs/promises";
if (!process.env.SCENEPOND_TASK_ID) throw new Error("Set SCENEPOND_TASK_ID first");
if (!process.env.SCENEPOND_ARTIFACT_KEY) throw new Error("Set SCENEPOND_ARTIFACT_KEY first");
const response = await fetch("https://open.scenepond.ai/v1/tasks/" + encodeURIComponent(process.env.SCENEPOND_TASK_ID) + "/artifacts/" + encodeURIComponent(process.env.SCENEPOND_ARTIFACT_KEY) + "/content", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json"
  }
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
await writeFile("output.bin", Buffer.from(await response.arrayBuffer()));
console.log("Saved output.bin");
```

### 响应示例

响应示例仅展示结构；ID、URL 和数值为占位内容。

#### 提交响应

```json
{
  "task_id": "task_EXAMPLE",
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "status": "queued",
  "progress": 0,
  "created_at": 1700000000,
  "finished_at": 0,
  "error": null,
  "links": {
    "self": "/v1/tasks/task_EXAMPLE",
    "artifacts": "/v1/tasks/task_EXAMPLE/artifacts"
  }
}
```

#### 已完成任务的状态

```json
{
  "task_id": "task_EXAMPLE",
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "status": "succeeded",
  "progress": 100,
  "created_at": 1700000000,
  "finished_at": 1700000060,
  "error": null,
  "links": {
    "self": "/v1/tasks/task_EXAMPLE",
    "artifacts": "/v1/tasks/task_EXAMPLE/artifacts"
  }
}
```

#### 失败任务状态（HTTP 200）

```json
{
  "task_id": "task_EXAMPLE",
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "status": "failed",
  "progress": 0,
  "created_at": 1700000000,
  "finished_at": 1700000060,
  "error": {
    "code": "input_media_unavailable",
    "message": "Reference media could not be downloaded or its format is unsupported / 参考素材无法下载或格式不支持",
    "retryable": false,
    "charged": false
  },
  "links": {
    "self": "/v1/tasks/task_EXAMPLE",
    "artifacts": "/v1/tasks/task_EXAMPLE/artifacts"
  }
}
```

#### 提交被拒绝（HTTP 400）

```json
{
  "error": {
    "code": "invalid_parameters",
    "message": "Invalid generation parameters / 生成参数无效",
    "retryable": false,
    "submission": "not_submitted"
  }
}
```

#### 生成文件列表

```json
{
  "task_id": "task_EXAMPLE",
  "artifacts": [
    {
      "key": "video",
      "type": "video",
      "mime_type": "video/mp4",
      "content_url": "https://open.scenepond.ai/v1/tasks/task_EXAMPLE/artifacts/video/content",
      "expires_at": 1701209660
    }
  ]
}
```

#### 结果过期响应（API Key 鉴权）

```json
{
  "error": {
    "message": "Artifact content has expired or is no longer available",
    "type": "artifact_expired",
    "code": "artifact_expired"
  }
}
```

### 响应字段

- `response.task_id` — **必填**; `string`. 任务标识符，请原样保存；拼接 URL 路径时进行 URL 编码。

- `response.model` — **必填**; `string`. 此任务使用的公开模型 ID。

- `response.status` — **必填**; `string`. 任务状态：queued、processing、succeeded 或 failed。

- `response.progress` — **必填**; `integer`. 进度范围为 0–100；仅 succeeded 状态保证为 100。

- `response.created_at` — **必填**; `integer`. 创建时间，单位为 Unix 秒。

- `response.finished_at` — **必填**; `integer`. 完成时间，单位为 Unix 秒；任务进入终态前为 0。

- `response.error` — **必填**; `object | null`. 终态失败处理完成前为 null。

### response.error 中的字段

仅在提供 response.error 时适用；子字段必填不代表可选的父字段也必填。

- `response.error.code` — **必填**; `string`. 公开的任务失败分类。

- `response.error.message` — **必填**; `string`. 可公开的安全失败说明。

- `response.error.retryable` — **必填**; `boolean`. 重试是否可能成功；重新提交前请检查现有任务及扣费情况。

- `response.error.charged` — **必填**; `boolean`. 失败任务是否仍有扣费，仅在返回此字段时据此判断。


- `response.links` — **必填**; `object`. 查询此任务和获取产物列表的相对路径。

### response.links 中的字段

仅在提供 response.links 时适用；子字段必填不代表可选的父字段也必填。

- `response.links.self` — **必填**; `string`. 任务状态查询路径。

- `response.links.artifacts` — **必填**; `string`. 产物列表路径。


- `response.attention` — **可选**; `object`. 可选的非终态查询提示。等待时间较长的任务保持 queued 或 processing，此提示不代表生成失败。

### response.attention 中的字段

仅在提供 response.attention 时适用；子字段必填不代表可选的父字段也必填。

- `response.attention.code` — **必填**; `string`. generation_delayed、provider_query_retrying 或 provider_query_paused。

- `response.attention.message` — **必填**; `string`. 可公开的安全查询提示。

- `response.attention.required_action` — **必填**; `string`. generation_delayed 时请等待并继续查询原任务。任务查询暂停时请联系支持；此字段不代表可以重新生成或退款。


### 相关接口

#### 上传参考图片

`POST /v1/media/images`

使用 API Key 上传，然后将 data.reference 填入明确支持上传引用的图片字段。

- `file` — **必填**; `binary file`. 必须且只能包含一个名为 file、带文件名的 multipart 文件部分。服务端根据上传内容验证 PNG、JPEG 和 WebP 格式。
  - 约束: 最大值: 52428800 bytes (50 MiB); 宽高均为 1–8192 像素

- 使用相同的 Authorization: Bearer API Key 认证。将 SCENEPOND_IMAGE_PATH 设置为本地图片路径。Python 示例需要 requests 包；JavaScript 示例使用 Node.js 的 FormData 和 Blob。
- 使用 multipart/form-data，且只包含一个文件部分，不添加其他部分。由 HTTP 客户端自动生成 Content-Type 及 boundary，不要手动设置 boundary。
- 上传成功返回 HTTP 201，success 为 true，回执位于 data 中。data.id 以 img_ 开头；data.reference 为 scenepond-input:// 后接规范的小写 UUID。
- data.reference 仅可用于明确支持的图片 URL 字段，不能用于视频或音频字段。服务端检查归属和 expires_at、解析引用后，再执行所选模型更严格的媒体要求。
- 上传回执包含 content_type、以字节计的 size、width、height、sha256，以及以 Unix 秒计的 expires_at。上传不等于提交生成，也不保证所有模型均接受该图片。
- 账户预览字段仅供登录后的控制台使用，不属于 API Key 下载接口契约。此处未公开图片列表、删除图片、任务列表或取消任务接口。
- 上传校验错误返回 success: false、message 和 code：invalid_image（400）、image_too_large（413）、unsupported_image_format（415）、image_upload_interrupted（408）或 image_storage_unavailable（503）。不存在或已过期的引用会在使用时被拒绝。

##### cURL

```bash
curl --fail-with-body -X POST "https://open.scenepond.ai/v1/media/images" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY" \
  --form "file=@$SCENEPOND_IMAGE_PATH"
```

##### Python

```python
import os
import requests

with open(os.environ["SCENEPOND_IMAGE_PATH"], "rb") as image:
    response = requests.post(
        "https://open.scenepond.ai/v1/media/images",
        headers={"Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"]},
        files={"file": image},
        timeout=60,
    )
response.raise_for_status()
print(response.json())
```

##### JavaScript

```javascript
import { readFile } from "node:fs/promises";
import { basename } from "node:path";

if (!process.env.SCENEPOND_IMAGE_PATH) throw new Error("Set SCENEPOND_IMAGE_PATH first");
const form = new FormData();
form.append("file", new Blob([await readFile(process.env.SCENEPOND_IMAGE_PATH)]), basename(process.env.SCENEPOND_IMAGE_PATH));
const response = await fetch("https://open.scenepond.ai/v1/media/images", {
  method: "POST",
  headers: { "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}` },
  body: form
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
console.log(await response.json());
```

##### 图片上传响应（HTTP 201）

```json
{
  "success": true,
  "data": {
    "id": "img_123e4567-e89b-42d3-a456-426614174000",
    "reference": "scenepond-input://123e4567-e89b-42d3-a456-426614174000",
    "content_type": "image/png",
    "size": 1024,
    "width": 512,
    "height": 512,
    "sha256": "0000000000000000000000000000000000000000000000000000000000000000",
    "expires_at": 1701209600
  }
}
```

##### 图片上传错误（HTTP 413）

```json
{
  "success": false,
  "message": "Invalid request",
  "code": "image_too_large"
}
```

#### 查询任务提交回执

`GET /v1/tasks/receipts/{idempotency_key}`

将 SCENEPOND_IDEMPOTENCY_KEY 设为原始 Idempotency-Key 值，并使用原始 API 令牌认证。

- `idempotency_key` — **必填**; `string`. URL 路径中的原始回执查询键，值区分大小写。
  - 约束: 使用 8–128 个 ASCII 字符，仅限英文字母、数字、下划线（_）或连字符（-）。

- 已确认的提交回执返回 HTTP 200 和普通任务对象。HTTP 202 且 status 为 pending、submission 为 unknown，表示仍无法确认是否已受理。
- 回执缺失、查询失败或 HTTP 409，均不能证明没有执行生成。使用同一个键但更改请求字节或预留额度请求头，可能返回 409。再次提交前，请检查原始回执和用量记录。
- 回执查询仅适用于这些 Seedance 任务提交，不为其他模型或兼容协议提供通用幂等保证。

##### cURL

```bash
curl --fail-with-body -X GET "https://open.scenepond.ai/v1/tasks/receipts/$SCENEPOND_IDEMPOTENCY_KEY" \
  -H "Authorization: Bearer $SCENEPOND_API_KEY"
```

##### Python

```python
import os
import json
from urllib.parse import quote
from urllib.request import Request, urlopen

request = Request(
    "https://open.scenepond.ai/v1/tasks/receipts/" + quote(os.environ["SCENEPOND_IDEMPOTENCY_KEY"], safe="") + "",
    headers={
        "Authorization": "Bearer " + os.environ["SCENEPOND_API_KEY"],
        "Content-Type": "application/json",
    },
    method="GET",
)
with urlopen(request) as response:
    result = json.load(response)
print(json.dumps(result, indent=2))
```

##### JavaScript

```javascript
if (!process.env.SCENEPOND_IDEMPOTENCY_KEY) throw new Error("Set SCENEPOND_IDEMPOTENCY_KEY first");
const response = await fetch("https://open.scenepond.ai/v1/tasks/receipts/" + encodeURIComponent(process.env.SCENEPOND_IDEMPOTENCY_KEY) + "", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.SCENEPOND_API_KEY}`,
    "Content-Type": "application/json"
  }
});
if (!response.ok) throw new Error(`API error: ${response.status} ${await response.text()}`);
const result = await response.json();
console.log(result);
```

##### 已确认的提交回执（HTTP 200）

```json
{
  "task_id": "task_EXAMPLE",
  "model": "scenepond-cs/seedance-2.0-mini/image-to-video",
  "status": "queued",
  "progress": 0,
  "created_at": 1700000000,
  "finished_at": 0,
  "error": null,
  "links": {
    "self": "/v1/tasks/task_EXAMPLE",
    "artifacts": "/v1/tasks/task_EXAMPLE/artifacts"
  }
}
```

##### 待确认的提交回执（HTTP 202）

```json
{
  "status": "pending",
  "submission": "unknown"
}
```

### 调用注意事项

- 请求顶层只接受 model、parameters 和 callback_url。生成设置必须放在 parameters 内。
- 图片和视频使用同一套 Scenepond 任务接口。选择模型并设置生成参数即可。
- 每次请求使用 Authorization: Bearer 和 Scenepond API Key 认证；密钥保存在服务器。
- 提交一次并保存 task_id，轮询至 succeeded 或 failed，再通过结果接口下载。
- 请求受理后返回任务 ID；部分任务可能在返回 ID 时已完成。
- 首次提交被接受后返回 HTTP 202，并带有 Location: /v1/tasks/{task_id}。特定服务的提交恢复机制并非已公开的通用幂等接口。
- 生成产物保存 14 天。请在 expires_at 前下载；过期后无法恢复。
- POST 超时后请勿自动重提，任务可能已创建并产生费用。
- GET 任务状态接口没有公开的筛选或分页参数。此契约不包含公开的任务列表或取消任务路由。
- 任务提交错误使用 error.code、error.message 和 error.retryable；提交前被拒绝时，error.submission 可能为 not_submitted。提交错误不保证返回 charged 信息。认证或路由失败可能采用不同的错误结构，请同时检查 HTTP 状态码。
- 当前任务失败码为 content_policy_violation、invalid_parameters、reservation_changed、input_media_unavailable、generation_timeout、upstream_unavailable、artifact_storage_failed 和 generation_failed。排障中的旧别名仅为兼容说明，不是新增的当前任务失败码。
- 任务失败时，状态查询仍返回 HTTP 200，并包含 error.retryable 和 error.charged。retryable 不代表可以安全地自动提交另一个可能计费的任务。
- 可选的 attention 提示出现时，任务保持非终态，error 为 null。generation_delayed 表示原任务等待时间较长，保持 queued 或 processing，不代表已确认排队位置或实际生成进度。provider_query_retrying 表示正在重试查询；provider_query_paused 表示需要人工处理。此处不承诺公开的恢复、提交核对或人工操作接口。
- 可选的 callback_url 必须为非 null 字符串，使用不超过 2048 个 UTF-8 字节的公网 HTTPS URL，不能含凭据、片段或空白字符。公网 DNS 和目标地址由服务端检查。
- 完成回调会在扣费结算完成后，以 POST 发送终态任务 JSON。请验证 Scenepond-Signature: t=<unix_seconds>,v1=<hex_hmac> 和 Scenepond-Event-ID；HMAC-SHA256 签名原文为 timestamp + "." + event_id + "." + 完整的原始请求体。
- 使用账户完整的 whsec_ 签名密钥（包括前缀）作为 UTF-8 HMAC 密钥；它与 API Key 不同。获取和轮换密钥需要已登录账户的安全流程及重新认证。此处未公开可凭 API Key 获取该密钥的接口；启用回调前请联系支持安排验签。
- 请使用恒定时间比较验证签名，并限制可接受的时间戳窗口。按 Scenepond-Event-ID 去重，及时返回 2xx，并持久化处理事件。同一事件 ID 和请求体可能重复投递；每次尝试都会使用新的签名时间戳。
- 回调投递超时为 5 秒，不跟随重定向，仅将 2xx 视为成功。最多尝试 6 次，失败后的重试间隔依次为 10、20、40、80 和 160 秒。投递失败时仍可轮询任务状态。
- 默认生成音频。
- 图生视频请通过 reference_assets、image_url 或 start_image_url 提供首帧。end_image_url 可选且接受 null。若同时传入 image_url 和 start_image_url，两者必须解析为同一张图片。
- reference_assets 不可与 image_url、start_image_url 或 end_image_url 同时传入，即使别名值为 null 也不允许。
- 提交前，请将示例素材网址替换为你自己的公网可访问文件。
- 生成的图片和视频只保存 14 天，请在到期前下载并保存到本地。
- 已存储的结果包含 expires_at，表示该文件到期时间的 Unix 时间戳（秒）。请逐个文件使用此字段，不要按任务创建时间推算。
- 部分历史结果可能没有 expires_at，这不代表永久保存，请尽快下载。
- 到期后，使用 API Key 鉴权且不带 access 查询参数的内容请求返回 HTTP 410，错误码为 artifact_expired。私有访问链接在内容不可用时可能返回 404。过期文件无法继续下载或恢复。
- 请勿公开 content_url。保存链接不等于保存文件，请在 expires_at 到期前将文件内容下载到自己的存储。
- 视频费用按公布的每秒参考价估算。

### 模型参数（JSON）

```json
{
  "x-scenepond-constraints": {
    "version": 1,
    "rules": [
      {
        "kind": "public-http-url",
        "paths": [
          "/reference_assets/*/url",
          "/image_url",
          "/start_image_url",
          "/end_image_url"
        ],
        "allowCredentials": false,
        "allowWhitespace": false
      },
      {
        "kind": "matching-aliases",
        "path": "/image_url",
        "otherPath": "/start_image_url"
      },
      {
        "kind": "reference-image-input",
        "paths": [
          "/image_url",
          "/start_image_url",
          "/end_image_url",
          "/reference_assets/*/url"
        ],
        "scheme": "scenepond-input"
      }
    ]
  },
  "type": "object",
  "properties": {
    "aspect_ratio": {
      "type": "string",
      "enum": [
        "adaptive",
        "21:9",
        "16:9",
        "9:16",
        "4:3",
        "1:1",
        "3:4"
      ],
      "default": "16:9"
    },
    "duration": {
      "default": 5,
      "allOf": [
        {
          "type": "integer",
          "minimum": 4,
          "maximum": 15
        },
        {
          "type": "number",
          "maximum": 3600,
          "exclusiveMinimum": 0
        }
      ]
    },
    "end_image_url": {
      "anyOf": [
        {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 65536,
              "pattern": "^https?://[^\\s/?#@\\\\\\x00]+(?:[/?][^\\s#\\\\\\x00]*)?$"
            },
            {
              "type": "null"
            }
          ]
        },
        {
          "type": "string",
          "format": "uri",
          "pattern": "^scenepond-input://[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        }
      ]
    },
    "image_url": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 65536,
          "pattern": "^https?://[^\\s/?#@\\\\\\x00]+(?:[/?][^\\s#\\\\\\x00]*)?$"
        },
        {
          "type": "string",
          "format": "uri",
          "pattern": "^scenepond-input://[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        }
      ]
    },
    "prompt": {
      "type": "string",
      "minLength": 1,
      "maxLength": 5000,
      "pattern": "\\S"
    },
    "reference_assets": {
      "allOf": [
        {
          "type": "array",
          "minItems": 1,
          "maxItems": 12,
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "media_type": {
                    "const": "image"
                  },
                  "role": {
                    "enum": [
                      "reference",
                      "first_frame",
                      "last_frame"
                    ]
                  },
                  "uri": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4096,
                    "allOf": [
                      {
                        "not": {
                          "pattern": "^[\\s/]|\\s$|[\\r\\n\\x00\\\\]"
                        }
                      },
                      {
                        "anyOf": [
                          {
                            "pattern": "^[tT][oO][sS]:"
                          },
                          {
                            "not": {
                              "pattern": "^[^/?#]*:"
                            }
                          }
                        ]
                      },
                      {
                        "not": {
                          "pattern": "%(?:[^0-9a-fA-F]|$)|%[0-9a-fA-F](?:[^0-9a-fA-F]|$)"
                        }
                      }
                    ]
                  }
                },
                "required": [
                  "role",
                  "media_type",
                  "uri"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "media_type": {
                    "const": "audio"
                  },
                  "role": {
                    "const": "reference"
                  },
                  "vid": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "pattern": "^[^ \\t\\r\\n\\x00]+$",
                    "not": {
                      "pattern": "://"
                    }
                  }
                },
                "required": [
                  "role",
                  "media_type",
                  "vid"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "media_type": {
                    "const": "image"
                  },
                  "role": {
                    "enum": [
                      "reference",
                      "first_frame",
                      "last_frame"
                    ]
                  },
                  "url": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 65536,
                        "pattern": "^https?://[^\\s/?#@\\\\\\x00]+(?:[/?][^\\s#\\\\\\x00]*)?$"
                      },
                      {
                        "type": "string",
                        "format": "uri",
                        "pattern": "^scenepond-input://[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
                      }
                    ]
                  }
                },
                "required": [
                  "role",
                  "media_type",
                  "url"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "media_type": {
                    "const": "video"
                  },
                  "role": {
                    "enum": [
                      "reference"
                    ]
                  },
                  "url": {
                    "type": "string",
                    "maxLength": 65536,
                    "pattern": "^https?://[^\\s/?#@\\\\\\x00]+(?:[/?][^\\s#\\\\\\x00]*)?$"
                  }
                },
                "required": [
                  "role",
                  "media_type",
                  "url"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "media_type": {
                    "const": "audio"
                  },
                  "role": {
                    "enum": [
                      "reference"
                    ]
                  },
                  "url": {
                    "type": "string",
                    "maxLength": 65536,
                    "pattern": "^https?://[^\\s/?#@\\\\\\x00]+(?:[/?][^\\s#\\\\\\x00]*)?$"
                  }
                },
                "required": [
                  "role",
                  "media_type",
                  "url"
                ],
                "additionalProperties": false
              }
            ]
          },
          "allOf": [
            {
              "minContains": 0,
              "maxContains": 9,
              "contains": {
                "properties": {
                  "media_type": {
                    "const": "image"
                  }
                },
                "required": [
                  "media_type"
                ]
              }
            },
            {
              "minContains": 0,
              "maxContains": 3,
              "contains": {
                "properties": {
                  "media_type": {
                    "const": "audio"
                  }
                },
                "required": [
                  "media_type"
                ]
              }
            },
            {
              "minContains": 0,
              "maxContains": 3,
              "contains": {
                "properties": {
                  "media_type": {
                    "const": "video"
                  }
                },
                "required": [
                  "media_type"
                ]
              }
            },
            {
              "minContains": 0,
              "maxContains": 1,
              "contains": {
                "type": "object",
                "properties": {
                  "role": {
                    "enum": [
                      "first_frame"
                    ]
                  }
                },
                "required": [
                  "role"
                ]
              }
            },
            {
              "minContains": 0,
              "maxContains": 1,
              "contains": {
                "type": "object",
                "properties": {
                  "role": {
                    "enum": [
                      "last_frame"
                    ]
                  }
                },
                "required": [
                  "role"
                ]
              }
            },
            {
              "not": {
                "allOf": [
                  {
                    "contains": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "enum": [
                            "first_frame",
                            "last_frame"
                          ]
                        }
                      },
                      "required": [
                        "role"
                      ]
                    }
                  },
                  {
                    "contains": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "enum": [
                            "reference"
                          ]
                        }
                      },
                      "required": [
                        "role"
                      ]
                    }
                  }
                ]
              }
            }
          ]
        },
        {
          "maxItems": 2,
          "minContains": 1,
          "maxContains": 1,
          "items": {
            "properties": {
              "media_type": {
                "const": "image"
              },
              "role": {
                "enum": [
                  "first_frame",
                  "last_frame"
                ]
              }
            }
          },
          "contains": {
            "type": "object",
            "properties": {
              "role": {
                "enum": [
                  "first_frame"
                ]
              }
            },
            "required": [
              "role"
            ]
          }
        }
      ]
    },
    "resolution": {
      "type": "string",
      "enum": [
        "480p",
        "720p"
      ],
      "default": "720p"
    },
    "start_image_url": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 65536,
          "pattern": "^https?://[^\\s/?#@\\\\\\x00]+(?:[/?][^\\s#\\\\\\x00]*)?$"
        },
        {
          "type": "string",
          "format": "uri",
          "pattern": "^scenepond-input://[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        }
      ]
    }
  },
  "required": [
    "prompt"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "not": {
        "required": [
          "reference_assets",
          "image_url"
        ]
      }
    },
    {
      "not": {
        "required": [
          "reference_assets",
          "start_image_url"
        ]
      }
    },
    {
      "not": {
        "required": [
          "reference_assets",
          "end_image_url"
        ]
      }
    }
  ],
  "anyOf": [
    {
      "required": [
        "reference_assets"
      ]
    },
    {
      "required": [
        "image_url"
      ]
    },
    {
      "required": [
        "start_image_url"
      ]
    }
  ]
}
```
