curl --request POST 'https://api.voicecheap.ai/v1/actions/thumbnails_generate' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"2fcb6b7f-4e5d-421a-b35b-b68548dfd83e","prompt":"A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.","referenceImageKeys":["uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"]}'
const input = {
requestId: '2fcb6b7f-4e5d-421a-b35b-b68548dfd83e',
prompt: 'A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.',
referenceImageKeys: ['uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png'],
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/thumbnails_generate', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/thumbnails_generate",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e", "prompt": "A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.", "referenceImageKeys": ["uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"]},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"generationId": "109c61cb35dbdc01a94aabb3b1a128519ed1f8823800a7a327b9d8d8c2c0e10b",
"status": "completed",
"width": 1280,
"height": 720,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144800000,
"expiresAt": 1792749600000
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"operation": "thumbnails_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"operation": "thumbnails_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
缩略图
生成 YouTube 缩略图
为已连接账户生成 1280×720 的缩略图,使用网页应用的媒体限额。重试同一请求时请复用 requestId;使用 thumbnails_download 获取结果。
POST
/
v1
/
actions
/
thumbnails_generate
curl --request POST 'https://api.voicecheap.ai/v1/actions/thumbnails_generate' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"2fcb6b7f-4e5d-421a-b35b-b68548dfd83e","prompt":"A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.","referenceImageKeys":["uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"]}'
const input = {
requestId: '2fcb6b7f-4e5d-421a-b35b-b68548dfd83e',
prompt: 'A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.',
referenceImageKeys: ['uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png'],
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/thumbnails_generate', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/thumbnails_generate",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e", "prompt": "A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.", "referenceImageKeys": ["uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"]},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"generationId": "109c61cb35dbdc01a94aabb3b1a128519ed1f8823800a7a327b9d8d8c2c0e10b",
"status": "completed",
"width": 1280,
"height": 720,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144800000,
"expiresAt": 1792749600000
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"operation": "thumbnails_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"operation": "thumbnails_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
为已连接账户生成 1280×720 的缩略图,使用网页应用的媒体限额。重试同一请求时请复用 requestId;使用 thumbnails_download 获取结果。
所需权限:
POST https://api.voicecheap.ai/v1/actions/thumbnails_generate
身份验证和权限
string
必填
在此请求头中发送 VoiceCheap API 密钥。也支持通过 Authorization: Bearer 发送同一 API 密钥。OAuth 访问令牌仅适用于 MCP,此 REST 端点不接受 OAuth
访问令牌。
thumbnails:write.
需要有效的付费订阅。权限不会改变团队角色、资源归属、媒体额度或套餐限制。
参数
string
在传输层可选:如果省略,服务器会在验证前注入标识符。请自行提供稳定的 UUID v4,以便在响应丢失后安全恢复。格式: “uuid”. 匹配模式:
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$.string
必填
文本值。最小长度: 10. 最大长度: 1200.
array
值列表。项目结构请参阅完整输入架构。最多项目数: 3. 默认值: [].
完整输入架构
完整输入架构
以下 JSON Schema 保留了发现接口公开的确切字段名、嵌套类型、默认值、范围和可接受值。其他跨字段规则列于操作说明中。
{
"type": "object",
"properties": {
"requestId": {
"type": "string",
"format": "uuid",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"description": "UUID v4 for this action. Reuse the same ID with identical arguments on retries."
},
"prompt": {
"type": "string",
"minLength": 10,
"maxLength": 1200
},
"referenceImageKeys": {
"default": [],
"maxItems": 3,
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 512,
"description": "An uploaded JPG, PNG or WebP object key under uploads/{yourUserId}/. Remote URLs are not accepted."
}
}
},
"required": ["prompt"],
"additionalProperties": false
}
幂等性
为每次修改操作在 requestId 或 Idempotency-Key HTTP 请求头中提供 UUID v4。网络故障后,请使用相同标识符和完全相同的参数重试。如果同时提供这两个值,它们必须一致。重放已保存的请求不会重复执行操作,也不会再次扣除月度调用次数。失败或中断的请求不会自动重新执行。 对于每次修改操作,如果重试时发现同一请求仍在运行,即使首次执行通常为同步操作,也可能返回 HTTP 202。如果执行已完成但 resultStored 为 false,重试会返回 HTTP 200 和已保存的请求状态,而非原始结果。请通过对应领域的历史记录、结果或下载操作获取输出。请求示例
请将示例资源标识符和媒体键替换为账户返回的值。重试同一次修改操作时,请保持请求标识符不变。curl --request POST 'https://api.voicecheap.ai/v1/actions/thumbnails_generate' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"2fcb6b7f-4e5d-421a-b35b-b68548dfd83e","prompt":"A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.","referenceImageKeys":["uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"]}'
const input = {
requestId: '2fcb6b7f-4e5d-421a-b35b-b68548dfd83e',
prompt: 'A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.',
referenceImageKeys: ['uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png'],
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/thumbnails_generate', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/thumbnails_generate",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e", "prompt": "A clean YouTube thumbnail showing a mountain sunrise, with the text “A new adventure”.", "referenceImageKeys": ["uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"]},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
响应
此操作在运行期间返回 HTTP 202。请保存 requestId,并使用该标识符和原始操作名称轮询 action_request_get。轮询状态包括 running、completed、failed 和 interrupted。已完成的结果可能指向独立的媒体任务;请继续使用该操作对应的状态或输出操作。 生成完成后返回的最终缩略图元数据。输出尺寸为 1280 × 720 像素;不包含图像字节、previewDataUrl 或交接令牌。{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"generationId": "109c61cb35dbdc01a94aabb3b1a128519ed1f8823800a7a327b9d8d8c2c0e10b",
"status": "completed",
"width": 1280,
"height": 720,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144800000,
"expiresAt": 1792749600000
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"operation": "thumbnails_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"operation": "thumbnails_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e"
}
结果字段
| 字段 | 说明 |
|---|---|
data.generationId | 原样传给 thumbnails_get 或 thumbnails_download 的标识符。 |
data.status | completed、expired 或 deleted。已删除的记录即使超过过期时间也仍为 deleted。 |
data.width | 输出宽度,单位为像素:1280。 |
data.height | 输出高度(像素):720。 |
data.referenceImageCount | 使用的参考图片数量:0 至 3。 |
data.createdAt | 创建时间,以 Unix 毫秒表示。 |
data.updatedAt | 上次更新时间,采用 Unix 毫秒时间戳。 |
data.expiresAt | 生成的缩略图在此时间之后无法下载,采用 Unix 毫秒时间戳。 |
恢复并轮询此请求
即使连接丢失,也应使用同一标识符。如果 resultStored 为 false,请通过相应的历史记录、结果或下载操作获取输出。切勿仅为查看进度而启动第二次生成。curl --request POST 'https://api.voicecheap.ai/v1/actions/action_request_get' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"2fcb6b7f-4e5d-421a-b35b-b68548dfd83e","operation":"thumbnails_generate"}'
HTTP 200
{
"data": {
"requestId": "2fcb6b7f-4e5d-421a-b35b-b68548dfd83e",
"operation": "thumbnails_generate",
"status": "completed",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"resultStored": true,
"result": {
"generationId": "109c61cb35dbdc01a94aabb3b1a128519ed1f8823800a7a327b9d8d8c2c0e10b",
"status": "completed",
"width": 1280,
"height": 720,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144800000,
"expiresAt": 1792749600000
}
}
}
操作说明
- 需要 thumbnails:write。prompt 会去除首尾空白,且须包含 10–1200 个字符;生成前还会进行规范化。referenceImageKeys 默认为 [],最多接受三个键。
- 这是一个长时间运行的操作。初始 API/MCP 响应通常报告 running;使用 operation thumbnails_generate 和相同的 requestId 轮询 action_request_get,以获取此处所示的最终结果。
- 使用账户常规的每日缩略图生成限额。账户新建的缩略图在创建七天后过期;请在 expiresAt 之前下载结果。
- 此操作使用已连接用户自己的生成内容和上传文件,包括凭据在团队上下文中连接时。
- 引用键必须指向 uploads/{yourUserId}/ 下已完成的上传,且以 .jpg、.jpeg、.png 或 .webp 结尾。不允许远程 URL、其他用户的键、路径穿越片段、反斜杠、百分号转义、查询字符串、片段标识符和控制字符。
- 每张参考图片必须非空,最大为 8 MiB(8,388,608 字节),解码后的图片类型必须与扩展名一致,且每边尺寸为 128–4096 像素。解码后的像素总数也受限。已上传的参考图片可以重复使用;这些生成操作不会消耗或删除其上传文件。
- 请使用 UUID v4 requestId 或 HTTP Idempotency-Key 标头,并在重试时以完全相同的输入重复使用。集成层会记录每次变更,并返回其已记录的状态或结果,不会重新执行。失败或中断的请求不会自动重试。
- 已完成的请求可以返回现有缩略图。此前失败或中断的集成请求不会自动重新执行。开始新请求前,请检查请求状态和 thumbnails_list。
- 使用 thumbnails_get 或 thumbnails_list 获取元数据,使用 thumbnails_download 获取 WebP 字节。生成标识符是不透明字符串,不是 requestId。
用量
每次成功调用消耗一次月度 API/MCP 调用额度。媒体额度和操作本身的生成限额也适用。错误
| HTTP 状态 | 代码 | 含义或恢复方式 |
|---|---|---|
| 400 | CREDENTIAL_IN_QUERY | 凭证通过 access_token 或 api_key 查询参数提供。请在标头中发送凭证。 |
| 400 | IDEMPOTENCY_CONFLICT | Idempotency-Key 请求头必须与请求体中的 requestId 字段一致。 |
| 400 | INVALID_REQUEST_ID | requestId 或 Idempotency-Key 不是 UUID v4。 |
| 400 | REFERENCE_IMAGE_INVALID | 参考图片键或其字节未通过归属、类型、大小、尺寸或解码检查。 |
| 400 | THUMBNAIL_PROMPT_INVALID | 规范化后的提示词不在 10–1200 个字符的范围内。 |
| 400 | VALIDATION_ERROR | 某个参数缺失、值不受支持、超出限额,或不属于严格输入架构。 |
| 401 | API_KEY_EXPIRED | API 密钥已过期。 |
| 401 | INVALID_API_KEY | 请提供有效且未过期的 API 密钥。 |
| 401 | INVALID_CREDENTIAL | Authorization 标头格式错误或与 x-api-key 冲突。 |
| 401 | MISSING_CREDENTIAL | 未提供可用的请求头凭据,或其长度超过 4096 个字符。 |
| 401 | USER_NOT_FOUND | 该凭据对应的账户已不存在。 |
| 403 | ACCOUNT_UNAVAILABLE | 调用者账户或计费账户不可用,或正在删除。 |
| 403 | AMBIGUOUS_TEAM_API_KEY | 此凭据对应的用户属于多个团队,因此计费上下文不明确。 |
| 403 | INSUFFICIENT_SCOPE | 请授予全部所需权限,或选择其他凭据。 |
| 403 | INTEGRATION_PLAN_UNSUPPORTED | 无法验证该账户的集成限制。 |
| 403 | SUBSCRIPTION_REQUIRED | 请使用有效的付费订阅。 |
| 403 | TEAM_OWNER_NOT_FOUND | 找不到实际生效的团队所有者账户。 |
| 409 | CONCURRENT_ACTION_LIMIT_REACHED | 此账户已有 10 个集成操作正在运行。请先轮询现有请求,再启动另一个操作。 |
| 409 | IDEMPOTENCY_CONFLICT | 该请求标识符已用于不同参数;请求头与请求体中的标识符不一致时,也会返回相同代码及 HTTP 400。 |
| 409 | THUMBNAIL_GENERATION_IN_PROGRESS | 缩略图请求已在处理中。 |
| 409 | THUMBNAIL_REQUEST_FAILED | 此次缩略图生成尝试先前已失败。决定是否发起新请求前,请检查其状态。 |
| 409 | THUMBNAIL_REQUEST_ID_REUSED | 该缩略图请求标识符已与不同的输入关联。 |
| 410 | THUMBNAIL_NOT_FOUND | 此请求先前已完成的结果已过期或不再可用。 |
| 422 | THUMBNAIL_REQUEST_REJECTED | 无法根据此提示词或参考文件生成缩略图。请更改内容后发起新请求。 |
| 429 | INTEGRATION_MONTHLY_LIMIT_REACHED | 请等待月度额度重置,或更改套餐。 |
| 429 | INTEGRATION_RATE_LIMIT_REACHED | 如果提供了 Retry-After,请等待其指定的时间,并采用退避重试。 |
| 429 | THUMBNAIL_DAILY_LIMIT_REACHED | 此账户的每日缩略图生成限额已用尽。 |
| 500 | INTERNAL_ERROR | 在决定是否重试修改操作前,请检查已保存的请求状态和资源历史记录。 |
| 502 | INTERNAL_ERROR | 缩略图生成或准备失败。在决定开始另一次生成前,请检查请求状态。 |
| 503 | ACTION_RESULT_UNAVAILABLE | 操作已执行,但未能保存结果。在启动新的生成前,请检查已保存的请求状态和资源历史记录。 |
| 503 | INTERNAL_ERROR | 缩略图生成或其已存储结果暂时不可用。重试前,请检查请求状态。 |
| 503 | SERVER_RESTARTING | 服务器正在重启。请稍后重试;对于修改操作,请保持请求标识符不变。 |
{
"code": "INSUFFICIENT_SCOPE",
"message": "This credential does not permit the requested action.",
"status": 403,
"details": {
"requiredScopes": ["thumbnails:write"]
}
}
此页面对您有帮助吗?

