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>",
"background": "<string>",
"n": 123
}
'import requests
url = "https://api.toapis.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"quality": "<string>",
"size": "<string>",
"background": "<string>",
"n": 123
}
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>',
background: '<string>',
n: 123
})
};
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>',
'background' => '<string>',
'n' => 123
]),
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 \"background\": \"<string>\",\n \"n\": 123\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 \"background\": \"<string>\",\n \"n\": 123\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 \"background\": \"<string>\",\n \"n\": 123\n}"
response = http.request(request)
puts response.read_bodyGPT-Image-2.5
GPT-Image-2.5 官方渠道 圖像生成
Sunburst 和 Flare 官方渠道的非同步圖片任務, R2 結果與官方 8 折 token 計費
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>",
"background": "<string>",
"n": 123
}
'import requests
url = "https://api.toapis.com/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"quality": "<string>",
"size": "<string>",
"background": "<string>",
"n": 123
}
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>',
background: '<string>',
n: 123
})
};
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>',
'background' => '<string>',
'n' => 123
]),
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 \"background\": \"<string>\",\n \"n\": 123\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 \"background\": \"<string>\",\n \"n\": 123\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 \"background\": \"<string>\",\n \"n\": 123\n}"
response = http.request(request)
puts response.read_body透過 Azure 官方渠道呼叫兩個 GPT-Image-2.5 型號. 提交後立即回傳非同步任務 ID, 背景生成圖片並將結果轉存至 R2.
呼叫時必須使用表中的完整模型名稱.
儲存提交回應的
提交回應為
提交時先預扣額度, 成功後按上游實際文字和圖片 token 用量多退少補. 五檔品質共用上述單價, 沒有按品質固定的每張價格. 呼叫前需要足夠的帳戶餘額和 API Key 額度.
費用公式, 單位為 USD:
例如一次請求使用 17 個未快取文字輸入 tokens 和 196 個圖片輸出 tokens, 費用為
| 型號 | model |
|---|---|
| Sunburst Official | gpt-image-2.5-sunburst-official |
| Flare Official | gpt-image-2.5-flare-official |
gpt-image-2.5-official 只是系列名稱, 不能作為請求的 model.
中國大陸使用者可將範例中的 https://api.toapis.com 替換為 https://api.toapis.cn. 在 控制台 建立 API Key, 並設定環境變數 TOAPIS_API_KEY.
提交與查詢
提交一張 Flare 圖片. 呼叫 Sunburst 時替換 model 即可: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-official",
"prompt": "A small blue circle on a plain white background",
"quality": "low",
"size": "1024x1024",
"n": 1
}'
{
"id": "tsk_img_example",
"object": "generation.task",
"model": "gpt-image-2.5-flare-official",
"status": "pending",
"progress": 0,
"created_at": 1789099098,
"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 取得已轉存 R2 的圖片 URL, failed 時讀取 error. 建議每隔數秒查詢同一個任務 ID; 高品質生成可能需要數分鐘, 等待期間請勿重複提交. 完整欄位見 圖片任務狀態介面.
請求參數
string
必填
使用 ToAPIs API Key, 格式為
Bearer YOUR_API_KEY. 無需提供 Azure 憑證.string
必填
gpt-image-2.5-sunburst-official / gpt-image-2.5-flare-official.string
必填
圖片描述. 使用參考圖時描述希望保留和修改的內容.
string
預設值:"high"
支援
low, medium, high, xhigh, max 五檔. 品質和尺寸會影響實際 token 用量與耗時.string
預設值:"1024x1024"
使用像素尺寸, 例如
1024x1024, 1536x1024 或 1024x1536. 自訂尺寸須符合上游驗證. 以下範例不需要額外傳入 resolution.string
可選. 傳入
transparent 請求透明背景, 省略時使用上游預設背景. 預設 PNG 輸出可保留透明通道.integer
預設值:1
目前 official 渠道每次請求固定生成一張圖片, 使用
1.參考圖 URL
需要圖生圖時, 在同一個 JSON 生成請求中加入image_urls. URL 必須可由伺服器存取. 可先使用 圖片上傳介面 取得 URL. 參考圖產生圖片輸入 token 費用, 提交與查詢仍使用同一套非同步流程.
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-official",
"prompt": "Keep the subject and replace the background with a snowy forest",
"image_urls": ["https://example.com/reference.png"],
"quality": "high",
"size": "1024x1024",
"n": 1
}'
token 價格
2026-09-11 核對的標準售價如下. 兩個 official 型號均按官方 token 價格的 80% 計費, 即官方 8 折:| 類型 | USD / 1,000,000 tokens |
|---|---|
| 文字輸入 | 4.00 |
| 快取文字輸入 | 1.00 |
| 圖片輸入 | 6.40 |
| 快取圖片輸入 | 1.60 |
| 圖片輸出 | 24.00 |
USD = (
uncached_text_input_tokens * 4
+ cached_text_input_tokens * 1
+ uncached_image_input_tokens * 6.4
+ cached_image_input_tokens * 1.6
+ image_output_tokens * 24
) / 1,000,000
(17 * 4 + 196 * 24) / 1,000,000 = $0.004772. 這不是每張圖片的固定價格.
帳戶專屬定價或折扣繼續適用. 最終扣費可在使用日誌中核對, 最新售價以 定價頁 和帳戶設定為準.
相關型號
普通版 和 VIP 版 使用各自的完整模型名稱. 呼叫本頁官方渠道時請使用-official 後綴.