创建图片任务
创建 GPT Image 2 异步生图任务。
POST
/
v1
/
images
Create image task
curl --request POST \
--url https://sigrunai.com/v1/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "极简产品静物,白色背景,柔光",
"quality": "medium",
"n": 1,
"ratio": "1:1"
}
'import requests
url = "https://sigrunai.com/v1/images"
payload = {
"model": "gpt-image-2",
"prompt": "极简产品静物,白色背景,柔光",
"quality": "medium",
"n": 1,
"ratio": "1:1"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2',
prompt: '极简产品静物,白色背景,柔光',
quality: 'medium',
n: 1,
ratio: '1:1'
})
};
fetch('https://sigrunai.com/v1/images', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sigrunai.com/v1/images"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"极简产品静物,白色背景,柔光\",\n \"quality\": \"medium\",\n \"n\": 1,\n \"ratio\": \"1:1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"code": 20000,
"msg": "<string>",
"data": {
"task_id": "<string>",
"status": "<string>",
"progress": 123,
"model": "<string>",
"created_at": 123,
"completed_at": 123,
"cost": 123,
"error_message": "<string>",
"result": {
"image_url": "<string>",
"video_url": "<string>"
}
}
}创建 GPT Image 2 异步生图任务。成功后返回
当
成功响应示例:
task_id,请用 查询图片任务 轮询,完成后从 result.image_url 取图。
模型
model | 说明 | 计费 |
|---|---|---|
gpt-image-2 | 推荐写法;用 quality 选择档位 | 见下 |
gpt-image-2-low | 低价档 | per_task |
gpt-image-2-medium | 中档 | per_task |
gpt-image-2-high | 高档 | per_task |
model 为 gpt-image-2 且 quality 为 low / medium / high 时,按对应 gpt-image-2-* 计费模型扣费。quality 默认 auto。
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 见上表 |
prompt | string | 是 | 提示词,1–4000 字符 |
quality | string | 否 | auto(默认)、low、medium、high |
n | int | 否 | 生成张数,1–4,默认 1;费用按张数 × 单价 |
ratio | string | 否 | 画面比例;也可用 size |
size | string | 否 | ratio 别名 |
resolution | string | 否 | 可选分辨率提示(如 1k / 2k) |
images | string[] | 否 | 参考图公网 URL,最多 15 张 |
示例
curl -X POST 'https://sigrunai.com/v1/images' \
-H 'Authorization: Bearer sk_xxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-2",
"prompt": "极简产品静物,白色背景,柔光",
"quality": "medium",
"n": 1,
"ratio": "1:1"
}'
{
"code": 20000,
"msg": "提交成功",
"data": {
"task_id": "img_xxxxxxxx",
"status": "queued",
"progress": 0,
"model": "gpt-image-2",
"cost": 0.2,
"result": {}
}
}
授权
API key from the console. Format: Bearer sk_xxx
请求体
application/json
gpt-image-2 或 gpt-image-2-low / medium / high
示例:
"gpt-image-2"
Required string length:
1 - 4000可用选项:
auto, low, medium, high 必填范围:
1 <= x <= 4ratio 别名
Maximum array length:
15最后修改于 2026年10月15日
⌘I
Create image task
curl --request POST \
--url https://sigrunai.com/v1/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "极简产品静物,白色背景,柔光",
"quality": "medium",
"n": 1,
"ratio": "1:1"
}
'import requests
url = "https://sigrunai.com/v1/images"
payload = {
"model": "gpt-image-2",
"prompt": "极简产品静物,白色背景,柔光",
"quality": "medium",
"n": 1,
"ratio": "1:1"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2',
prompt: '极简产品静物,白色背景,柔光',
quality: 'medium',
n: 1,
ratio: '1:1'
})
};
fetch('https://sigrunai.com/v1/images', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sigrunai.com/v1/images"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"极简产品静物,白色背景,柔光\",\n \"quality\": \"medium\",\n \"n\": 1,\n \"ratio\": \"1:1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"code": 20000,
"msg": "<string>",
"data": {
"task_id": "<string>",
"status": "<string>",
"progress": 123,
"model": "<string>",
"created_at": 123,
"completed_at": 123,
"cost": 123,
"error_message": "<string>",
"result": {
"image_url": "<string>",
"video_url": "<string>"
}
}
}