API 參考
圖片生成與編輯
使用 OpenAI 兼容圖片接口生成或編輯圖片。
圖片接口支持生成與編輯。具體尺寸、質量、格式和是否支持流式輸出由模型與上游渠道決定。
端點
| 方法 | 路徑 | 說明 |
|---|---|---|
POST | /v1/images/generations | 生成圖片 |
POST | /v1/images/edits | 編輯圖片,支持 JSON 或 multipart 表單 |
POST | /v1/edits | 兼容路徑,推薦優先使用 /v1/images/edits |
請求參數
| 字段 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 圖片模型 ID |
prompt | string | 生成必填 | 圖片描述 |
n | integer | 否 | 返回圖片數量,默認 1 |
size | string | 否 | 圖片尺寸,例如 1024x1024。不要使用乘號 × |
quality | string | 否 | 圖片質量,例如 standard、hd、auto |
response_format | string | 否 | 返回格式,例如 url 或 b64_json,取決於模型 |
style | any | 否 | OpenAI 圖片擴展字段 |
background、moderation | any | 否 | 新版圖片模型擴展字段 |
output_format、output_compression | any | 否 | 輸出格式與壓縮參數 |
partial_images、stream | any | 否 | 支持流式圖片模型時使用 |
image、images | file/string/array | 編輯必填 | 待編輯圖片。multipart 可用 image、image[] 或 image[n] |
mask | file/string | 否 | 編輯蒙版 |
input_fidelity | any | 否 | 輸入保真度,取決於模型 |
watermark | boolean | 否 | 是否加水印,取決於渠道支持 |
生成圖片
curl https://api.tensoraxis.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-d '{
"model": "gpt-image-1",
"prompt": "一張極簡風格的未來城市海報",
"size": "1024x1024"
}'編輯圖片
multipart 表單適合上傳本地文件:
curl https://api.tensoraxis.com/v1/images/edits \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-F model="gpt-image-1" \
-F prompt="把背景改成夜晚城市" \
-F image="@input.png"也可以按模型支持使用 JSON 圖片 URL:
{
"model": "gpt-image-1",
"prompt": "把背景改成夜晚城市",
"image": "https://example.com/input.png"
}響應結構
{
"created": 1710000000,
"data": [
{
"url": "https://example.com/result.png",
"b64_json": "",
"revised_prompt": "..."
}
]
}視頻生成不是圖片接口。Seedance / Doubao 視頻模型請使用視頻生成裡的異步任務請求體。