GPT-Image-2.5 图像生成
curl --request POST \
--url https://api.toapis.com/v1/images/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"quality": "<string>",
"size": "<string>",
"resolution": "<string>",
"n": 123,
"reference_images": [
"<string>"
]
}
'import requests
url = "https://api.toapis.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"quality": "<string>",
"size": "<string>",
"resolution": "<string>",
"n": 123,
"reference_images": ["<string>"]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
quality: '<string>',
size: '<string>',
resolution: '<string>',
n: 123,
reference_images: ['<string>']
})
};
fetch('https://api.toapis.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.toapis.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'quality' => '<string>',
'size' => '<string>',
'resolution' => '<string>',
'n' => 123,
'reference_images' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.toapis.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"quality\": \"<string>\",\n \"size\": \"<string>\",\n \"resolution\": \"<string>\",\n \"n\": 123,\n \"reference_images\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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))
}HttpResponse<String> response = Unirest.post("https://api.toapis.com/v1/images/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"quality\": \"<string>\",\n \"size\": \"<string>\",\n \"resolution\": \"<string>\",\n \"n\": 123,\n \"reference_images\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.toapis.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"quality\": \"<string>\",\n \"size\": \"<string>\",\n \"resolution\": \"<string>\",\n \"n\": 123,\n \"reference_images\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_bodyGPT-Image-2.5
GPT-Image-2.5 图像生成
gpt-image-2.5-flare 和 gpt-image-2.5-sunburst 普通版接入指南, 包含异步任务, 参考图, 五档质量和按分辨率计价
POST
/
v1
/
images
/
generations
GPT-Image-2.5 图像生成
curl --request POST \
--url https://api.toapis.com/v1/images/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"quality": "<string>",
"size": "<string>",
"resolution": "<string>",
"n": 123,
"reference_images": [
"<string>"
]
}
'import requests
url = "https://api.toapis.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"quality": "<string>",
"size": "<string>",
"resolution": "<string>",
"n": 123,
"reference_images": ["<string>"]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
quality: '<string>',
size: '<string>',
resolution: '<string>',
n: 123,
reference_images: ['<string>']
})
};
fetch('https://api.toapis.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.toapis.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'quality' => '<string>',
'size' => '<string>',
'resolution' => '<string>',
'n' => 123,
'reference_images' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.toapis.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"quality\": \"<string>\",\n \"size\": \"<string>\",\n \"resolution\": \"<string>\",\n \"n\": 123,\n \"reference_images\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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))
}HttpResponse<String> response = Unirest.post("https://api.toapis.com/v1/images/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"quality\": \"<string>\",\n \"size\": \"<string>\",\n \"resolution\": \"<string>\",\n \"n\": 123,\n \"reference_images\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.toapis.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"quality\": \"<string>\",\n \"size\": \"<string>\",\n \"resolution\": \"<string>\",\n \"n\": 123,\n \"reference_images\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body普通版通过
中国大陆用户可将示例中的
提交响应示例:
保存返回的
任务可能经过
将
这三个价格均适用于
切换到 VIP 时, 请同时调整模型名, 参数和响应处理方式. 详见 GPT-Image-2.5 VIP.
POST /v1/images/generations 创建图片任务, 返回任务 ID. 任务完成后通过查询接口获取图片 URL. 两个模型使用相同的请求格式:
| 模型 | 请求中的 model |
|---|---|
| Flare | gpt-image-2.5-flare |
| Sunburst | gpt-image-2.5-sunburst |
gpt-image-2.5 是系列名称. 调用时请填写表中的完整模型名.
本文介绍普通版. 需要同步返回 Base64 图片和按实际 token 计费时, 请使用独立的 GPT-Image-2.5 VIP 文档.
https://api.toapis.com 替换为 https://api.toapis.cn. API Key 可在 控制台 创建.
快速开始
将自己的 ToAPIs API Key 设置为环境变量TOAPIS_API_KEY, 提交任务:
curl --fail-with-body --request POST \
--url https://api.toapis.com/v1/images/generations \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2.5-flare",
"prompt": "儿童绘本风格, 一位兽医用听诊器给小水獭检查心跳",
"quality": "high",
"size": "1:1",
"resolution": "1K",
"n": 1
}'
{
"id": "tsk_img_example",
"object": "generation.task",
"model": "gpt-image-2.5-flare",
"status": "pending",
"progress": 0,
"created_at": 1788951900,
"metadata": {}
}
id, 将下方的 TASK_ID 替换为该值后查询:
curl --fail-with-body \
--url https://api.toapis.com/v1/images/generations/TASK_ID \
--header "Authorization: Bearer $TOAPIS_API_KEY"
pending, queued, in_progress, 最终进入 completed 或 failed. completed 时从 result.data 读取图片 URL, failed 时读取 error. 建议每隔数秒查询一次. 完整字段见 图片任务状态接口.
提交成功表示任务已创建. 请等到 completed 后再下载图片; 等待期间继续查询同一个任务 ID.
请求参数
string
必填
使用
Bearer YOUR_TOAPIS_API_KEY 认证.string
必填
gpt-image-2.5-flare 或 gpt-image-2.5-sunburst.string
必填
图片描述. 使用参考图时, 描述需要保留的主体和需要修改的内容.
string
默认值:"high"
支持
low, medium, high, xhigh, max 五档, 默认 high. 使用小写值.quality 控制生成质量, 可能影响耗时. 当前普通版按 resolution 定价, 五档 quality 不单独加价.string
默认值:"1:1"
画面比例, 例如
1:1, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 16:9, 9:16, 2:1, 1:2, 21:9, 9:21.推荐使用比例并显式填写 resolution. 服务端根据二者计算输出像素尺寸. 普通版的比例写法与 VIP 版的像素尺寸写法不同.string
默认值:"1K"
分辨率档位, 支持
1K, 2K, 4K, 也接受小写形式. 该字段决定普通版的计价档位.integer
默认值:1
每次请求使用
1, 生成一张图片.string[]
比例和分辨率示例
| size | 1K | 2K | 4K |
|---|---|---|---|
1:1 | 1024x1024 | 2048x2048 | 2880x2880 |
3:2 | 1536x1024 | 2048x1360 | 3520x2336 |
2:3 | 1024x1536 | 1360x2048 | 2336x3520 |
16:9 | 1536x864 | 2048x1152 | 3840x2160 |
9:16 | 864x1536 | 1152x2048 | 2160x3840 |
4K 表示分辨率档位, 实际长宽取决于画面比例, 例如正方形 4K 输出为 2880x2880.
参考图生成
使用同一个生成接口, 增加reference_images. 下例使用 Sunburst, 返回值仍然是异步任务:
curl --fail-with-body --request POST \
--url https://api.toapis.com/v1/images/generations \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2.5-sunburst",
"prompt": "保留参考图中的小水獭和兽医, 给小水獭增加一条黄色围巾",
"reference_images": ["https://example.com/otter.png"],
"quality": "xhigh",
"size": "1:1",
"resolution": "2K",
"n": 1
}'
https://example.com/otter.png 替换为自己的参考图 URL, 然后使用返回的任务 ID 查询结果.
价格
以下为 2026-09-09 核对的标准价格, 每次生成一张图片, 两个普通版模型价格相同:| resolution | USD/张 |
|---|---|
| 1K | 0.015 |
| 2K | 0.020 |
| 4K | 0.025 |
low, medium, high, xhigh, max. 当前参考图输入没有额外的按张费用. 账户专属定价或折扣可能不同, 最新价格以 模型定价页 和账户实际配置为准.
与 VIP 版的区别
| 项目 | 普通版 | VIP 版 |
|---|---|---|
| 模型名 | 不带 -vip | 带 -vip |
| 生成结果 | 先返回任务 ID, 查询获取图片 URL | 同步返回 data[0].b64_json |
| size | 推荐比例, 如 16:9 | 像素尺寸, 如 1536x1024 |
| resolution | 1K, 2K, 4K | 省略, 由 size 表达尺寸 |
| 计费 | 按 resolution 对应的每张价格 | 按实际文本和图片 token |
| 参考图 | 生成接口中填写参考图 URL | 编辑接口上传图片文件 |