API 参考文档
图像放大
将图像放大到 2K、4K 或 8K。
JSON 请求体#
POST /images/upscales。所需权限范围:figures:generate。
| 字段 | 类型 | 必填 | 默认值 | 规则 |
|---|---|---|---|---|
| image | string | 是 | — | 图像的 file_id |
| scale | string | 是 | — | 2k、4k(Starter 或更高档位)或 8k(Plus 或更高档位);大于零的积分包余额按 Pro 计算 |
| scale | 积分 |
|---|---|
| 2k | 50 |
| 4k | 100 |
| 8k | 150 |
图像已达到目标尺寸时,返回 400 INVALID_REQUEST 和 details.reason = UPSCALE_ALREADY_AT_TARGET,不扣积分。生成插图约为 2K,因此请选择 4k 或 8k。放大任务超时后返还积分,且不会稍后交付。响应返回任务;字段和状态请参阅任务与有限等待,错误请参阅错误。
cURL#
curl -X POST https://scifig.ai/api/v1/images/upscales \
-H "Authorization: Bearer $SCIFIG_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Prefer: wait=25" \
-H "Content-Type: application/json" \
-d '{
"image": "<file_id>",
"scale": "4k"
}'JavaScript#
const response = await fetch('https://scifig.ai/api/v1/images/upscales', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SCIFIG_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
Prefer: 'wait=25',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"image": "<file_id>",
"scale": "4k"
}),
});
const result = await response.json();
console.log(response.status, result);Python#
import os
import uuid
import requests
headers = {
"Authorization": f"Bearer {os.environ['SCIFIG_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
"Prefer": "wait=25",
}
response = requests.post(
"https://scifig.ai/api/v1/images/upscales",
headers=headers,
json={
"image": "<file_id>",
"scale": "4k"
},
timeout=60,
)
print(response.status_code, response.json())