curl --request POST \
--url https://api.tikway.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"quality": "high",
"output_format": "png",
"images": [
{
"image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658"
}
]
}
'import requests
url = "https://api.tikway.ai/v1/images/edits"
payload = {
"model": "gpt-image-2",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"quality": "high",
"output_format": "png",
"images": [{ "image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658" }]
}
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: 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
size: '1024x1024',
quality: 'high',
output_format: 'png',
images: [
{
image_url: 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
}
]
})
};
fetch('https://api.tikway.ai/v1/images/edits', 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.tikway.ai/v1/images/edits",
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' => 'gpt-image-2',
'prompt' => 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
'size' => '1024x1024',
'quality' => 'high',
'output_format' => 'png',
'images' => [
[
'image_url' => 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.tikway.ai/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\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))
}HttpResponse<String> response = Unirest.post("https://api.tikway.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"created": 1713833628,
"data": [
{
"b64_json": "..."
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 50,
"output_tokens": 50,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 40
}
}
}图片编辑
网关要求显式传入 model、images 和 prompt。GPT Image 最多接收 16 张参考图;dall-e-2 只接收单张 PNG 输入;dall-e-3 不支持编辑。
GPT Image 2/2.5 支持任意合规 WIDTHxHEIGHT,其他 GPT Image 使用标准三档尺寸。input_fidelity、background、moderation、output_format、output_compression、stream 和 partial_images 仅用于 GPT Image 系列。
curl --request POST \
--url https://api.tikway.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"quality": "high",
"output_format": "png",
"images": [
{
"image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658"
}
]
}
'import requests
url = "https://api.tikway.ai/v1/images/edits"
payload = {
"model": "gpt-image-2",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"quality": "high",
"output_format": "png",
"images": [{ "image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658" }]
}
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: 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
size: '1024x1024',
quality: 'high',
output_format: 'png',
images: [
{
image_url: 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
}
]
})
};
fetch('https://api.tikway.ai/v1/images/edits', 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.tikway.ai/v1/images/edits",
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' => 'gpt-image-2',
'prompt' => 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
'size' => '1024x1024',
'quality' => 'high',
'output_format' => 'png',
'images' => [
[
'image_url' => 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.tikway.ai/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\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))
}HttpResponse<String> response = Unirest.post("https://api.tikway.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"created": 1713833628,
"data": [
{
"b64_json": "..."
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 50,
"output_tokens": 50,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 40
}
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
必填。期望如何编辑或扩展图像的文字描述。
1必填。用于图片编辑的模型。dall-e-3 不支持图片编辑。
gpt-image-2.5-sunburst, gpt-image-2.5-sunburst-2026-09-08, gpt-image-2.5-flare, gpt-image-2.5-flare-2026-09-08, gpt-image-2, gpt-image-2-2026-04-21, gpt-image-1.5, gpt-image-1, gpt-image-1-mini, chatgpt-image-latest, dall-e-2 输出背景,仅 GPT Image 模型支持。transparent 时 output_format 必须为 png 或 webp。
transparent, opaque, auto, null 与原始输入图像保持一致的程度,仅受支持的 GPT Image 模型适用。
high, low, null 内容审核级别,仅 GPT Image 模型支持。
low, auto, null 要生成的编辑后图像数量。
1 <= x <= 10jpeg 或 webp 输出的压缩率(0–100),仅 GPT Image 模型支持。
0 <= x <= 100输出图片格式,仅 GPT Image 模型支持。
png, jpeg, webp, null 流式响应中生成的中间图数量。
0 <= x <= 3输出质量。GPT Image 支持 low/medium/high/auto;GPT Image 2.5 额外支持 xhigh/max。
low, medium, high, xhigh, max, auto, null 图像尺寸。GPT Image 2/2.5 支持 WIDTHxHEIGHT:宽高均为 16 的倍数、比例 1:3~3:1,最高 3840x2160;其他 GPT Image 使用 auto、1024x1024、1536x1024 或 1024x1536;dall-e-2 支持 256x256、512x512、1024x1024;dall-e-3 支持 1024x1024、1792x1024、1024x1792。
auto, 1024x1024, 1536x1024, 1024x1536, null 是否以 SSE 事件流返回中间和最终结果。
终端用户唯一标识,用于滥用监控和检测。
dall-e-2 可用 url 或 b64_json。GPT Image 模型固定返回 Base64。
b64_json, url 响应
编辑结果创建时的 Unix 时间戳(秒)。
实际采用的输出背景。
transparent, opaque 实际输出格式。
png, webp, jpeg 实际使用的输出质量。
low, medium, high, auto 实际生成的图片尺寸。
GPT Image 模型的 token 用量。
Hide child attributes
Hide child attributes
输入文本和图像的 token 数。
输出 token 数。
输入和输出 token 总数。