curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-3-pro-image",
"prompt": "Generate a photorealistic red apple on a rustic wooden table.",
"size": "1:1",
"quality": "standard"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "gemini-3-pro-image",
"prompt": "Generate a photorealistic red apple on a rustic wooden table.",
"size": "1:1",
"quality": "standard"
}
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: 'gemini-3-pro-image',
prompt: 'Generate a photorealistic red apple on a rustic wooden table.',
size: '1:1',
quality: 'standard'
})
};
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' => 'gemini-3-pro-image',
'prompt' => 'Generate a photorealistic red apple on a rustic wooden table.',
'size' => '1:1',
'quality' => 'standard'
]),
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\": \"gemini-3-pro-image\",\n \"prompt\": \"Generate a photorealistic red apple on a rustic wooden table.\",\n \"size\": \"1:1\",\n \"quality\": \"standard\"\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\": \"gemini-3-pro-image\",\n \"prompt\": \"Generate a photorealistic red apple on a rustic wooden table.\",\n \"size\": \"1:1\",\n \"quality\": \"standard\"\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\": \"gemini-3-pro-image\",\n \"prompt\": \"Generate a photorealistic red apple on a rustic wooden table.\",\n \"size\": \"1:1\",\n \"quality\": \"standard\"\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
}
}
}图片生成
统一 OpenAI 兼容入口。size 表示宽高比,quality 映射到 Gemini 的图片分辨率。
| 模型 | 输出分辨率 | 参考图 | 搜索与思考 |
|---|---|---|---|
gemini-3.1-flash-image | 512px、1K、2K、4K;支持 1:4/4:1/1:8/8:1 极端比例 | 最多 14 张(最多 10 个对象 + 4 个角色) | google_search、image_search、thinking_level |
gemini-3-pro-image | 1K、2K、4K | 最多 14 张(最多 6 个对象 + 5 个角色 + 3 个风格) | google_search、thinking_level;不支持图片搜索 |
gemini-2.5-flash-image | 固定 1K | 建议最多 3 张 | 不支持 Google Search、图片搜索和思考 |
此入口不接受原生 generationConfig、aspect_ratio 或 image_size,请使用 size 和 quality。
curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-3-pro-image",
"prompt": "Generate a photorealistic red apple on a rustic wooden table.",
"size": "1:1",
"quality": "standard"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "gemini-3-pro-image",
"prompt": "Generate a photorealistic red apple on a rustic wooden table.",
"size": "1:1",
"quality": "standard"
}
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: 'gemini-3-pro-image',
prompt: 'Generate a photorealistic red apple on a rustic wooden table.',
size: '1:1',
quality: 'standard'
})
};
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' => 'gemini-3-pro-image',
'prompt' => 'Generate a photorealistic red apple on a rustic wooden table.',
'size' => '1:1',
'quality' => 'standard'
]),
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\": \"gemini-3-pro-image\",\n \"prompt\": \"Generate a photorealistic red apple on a rustic wooden table.\",\n \"size\": \"1:1\",\n \"quality\": \"standard\"\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\": \"gemini-3-pro-image\",\n \"prompt\": \"Generate a photorealistic red apple on a rustic wooden table.\",\n \"size\": \"1:1\",\n \"quality\": \"standard\"\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\": \"gemini-3-pro-image\",\n \"prompt\": \"Generate a photorealistic red apple on a rustic wooden table.\",\n \"size\": \"1:1\",\n \"quality\": \"standard\"\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.
请求体
必填。Gemini 图片模型。不同模型的分辨率、搜索、思考和参考图限制见接口说明。
gemini-3.1-flash-image, gemini-3-pro-image, gemini-2.5-flash-image 1必填。生成图片的提示词。
1 - 32000可选。参考图数组;用于图片编辑时至少 1 张。可传 URL/data URL 字符串或含 image_url 的对象;不支持 file_id。模型上限见接口说明。
1 - 14 elements输出宽高比。网关把该字段约分并映射为 Gemini aspectRatio;它不是像素尺寸。极端比例 1:4、4:1、1:8、8:1 仅 gemini-3.1-flash-image 支持。
1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9 输出分辨率映射:low→512px、standard→1K、medium→2K、high/hd→4K、auto/省略→不指定。gemini-2.5-flash-image 只支持 1K。
standard, hd, low, medium, high, auto Gemini 原生扩展,是否启用 Google Search grounding;仅支持此能力的模型可用。
Gemini 原生扩展,是否启用图片搜索 grounding;仅支持此能力的模型可用。
Gemini 原生扩展,模型思考强度;仅支持此能力的模型可用。
Minimal, High 固定返回 Base64 图片,使响应符合本接口的 Response Schema。
b64_json, url 响应
图像创建时的 Unix 时间戳(秒)。
实际采用的背景设置。
transparent, opaque 实际输出图像格式。
png, webp, jpeg 实际生成质量。
low, medium, high 实际生成的图像尺寸。
GPT Image 模型的 token 用量。
Hide child attributes
Hide child attributes
输入(文本和图像)的 token 数。
输出 token 数。
输入和输出 token 总数。