curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.",
"size": "1024x1024",
"quality": "high",
"output_format": "png"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.",
"size": "1024x1024",
"quality": "high",
"output_format": "png"
}
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: 'Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.',
size: '1024x1024',
quality: 'high',
output_format: 'png'
})
};
fetch('https://api.tikway.ai/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.tikway.ai/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' => 'gpt-image-2',
'prompt' => 'Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.',
'size' => '1024x1024',
'quality' => 'high',
'output_format' => 'png'
]),
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/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\"\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/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/generations")
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\": \"Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\"\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。不同模型只支持下表中的参数组合。
| 模型 | 尺寸 | 质量 | 模型专属参数 |
|---|---|---|---|
gpt-image-2.5-sunburst / flare(含快照) | 任意 WIDTHxHEIGHT(16 倍数、1:3~3:1、最高 3840x2160) | auto/low/medium/high/xhigh/max | background、moderation、output_format、output_compression、stream、partial_images |
gpt-image-2(含快照) | 同上 | auto/low/medium/high | 同上;透明背景仍为预览能力 |
gpt-image-1 / 1.5 / 1-mini | auto、1024×1024、1536×1024、1024×1536 | auto/low/medium/high | background、moderation、output_format、output_compression、stream、partial_images |
dall-e-3 | 1024×1024、1792×1024、1024×1792 | standard/hd | n 只能为 1;支持 style、response_format |
dall-e-2 | 256×256、512×512、1024×1024 | standard | 支持 n=1..10、response_format |
curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.",
"size": "1024x1024",
"quality": "high",
"output_format": "png"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.",
"size": "1024x1024",
"quality": "high",
"output_format": "png"
}
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: 'Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.',
size: '1024x1024',
quality: 'high',
output_format: 'png'
})
};
fetch('https://api.tikway.ai/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.tikway.ai/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' => 'gpt-image-2',
'prompt' => 'Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.',
'size' => '1024x1024',
'quality' => 'high',
'output_format' => 'png'
]),
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/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\"\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/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/generations")
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\": \"Generate a photorealistic red apple resting on a rustic wooden table, soft window light, shallow depth of field.\",\n \"size\": \"1024x1024\",\n \"quality\": \"high\",\n \"output_format\": \"png\"\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.
请求体
必填。要生成图像的文本描述;GPT Image 模型最长 32000 字符,dall-e-2 最长 1000 字符,dall-e-3 最长 4000 字符。
1 - 32000必填。使用 Get Models 返回的模型 ID 或可用别名。
1"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"
"dall-e-2"
"dall-e-3"
背景设置,仅 GPT Image 模型支持。transparent 使用时 output_format 必须为 png 或 webp。
transparent, opaque, auto, null 内容审核级别,仅 GPT Image 模型支持。auto 为默认值。
low, auto, null 生成的图像数量。dall-e-3 仅支持 1。
1 <= x <= 10图像压缩率(0–100),仅 GPT Image 的 webp 或 jpeg 输出支持,默认 100。
0 <= x <= 100输出图像格式,仅 GPT Image 模型支持。
png, jpeg, webp, null 流式响应中返回的中间图像数量,仅 GPT Image 模型支持。
0 <= x <= 3图像质量。GPT Image 支持 auto/low/medium/high;GPT Image 2.5 额外支持 xhigh/max;dall-e-3 支持 standard/hd;dall-e-2 仅支持 standard。
auto, low, medium, high, xhigh, max, standard, hd, null Tikway 图片交付格式,url 返回图片链接,b64_json 返回纯 Base64。默认 url;该字段由网关消费,不作为上游模型参数。
b64_json, url 输出尺寸,使用 auto 或 WIDTHxHEIGHT;具体尺寸范围和约束见所选模型能力。
^(auto|[1-9][0-9]*x[1-9][0-9]*)$是否采用 SSE 流式生成,仅 GPT Image 模型支持,默认 false。
生成风格,仅 dall-e-3 支持。
vivid, natural, null 终端用户的唯一标识,用于滥用监控与检测。
响应
图像创建时的 Unix 时间戳(秒)。
实际采用的背景设置。
transparent, opaque 实际输出图像格式。
png, webp, jpeg 实际生成质量。
low, medium, high 实际生成的图像尺寸。
GPT Image 模型的 token 用量。
Hide child attributes
Hide child attributes
输入(文本和图像)的 token 数。
输出 token 数。
输入和输出 token 总数。

