cURL
curl --request POST \
--url https://api.ttapi.org/gemini/image/generate \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"prompt": "<string>",
"model": "gemini-3-pro-image-preview",
"refer_images": [
"https://cdn.ttapi.io/xxx1.png",
"https://cdn.ttapi.io/xxx2.png"
],
"aspect_ratio": "1:1",
"image_size": "1K",
"google_search": "false",
"image_search": "false",
"sync_return": "true",
"hook_url": "<string>"
}
'import requests
url = "https://api.ttapi.org/gemini/image/generate"
payload = {
"prompt": "<string>",
"model": "gemini-3-pro-image-preview",
"refer_images": ["https://cdn.ttapi.io/xxx1.png", "https://cdn.ttapi.io/xxx2.png"],
"aspect_ratio": "1:1",
"image_size": "1K",
"google_search": "false",
"image_search": "false",
"sync_return": "true",
"hook_url": "<string>"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'gemini-3-pro-image-preview',
refer_images: ['https://cdn.ttapi.io/xxx1.png', 'https://cdn.ttapi.io/xxx2.png'],
aspect_ratio: '1:1',
image_size: '1K',
google_search: 'false',
image_search: 'false',
sync_return: 'true',
hook_url: '<string>'
})
};
fetch('https://api.ttapi.org/gemini/image/generate', 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.ttapi.org/gemini/image/generate",
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([
'prompt' => '<string>',
'model' => 'gemini-3-pro-image-preview',
'refer_images' => [
'https://cdn.ttapi.io/xxx1.png',
'https://cdn.ttapi.io/xxx2.png'
],
'aspect_ratio' => '1:1',
'image_size' => '1K',
'google_search' => 'false',
'image_search' => 'false',
'sync_return' => 'true',
'hook_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$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.ttapi.org/gemini/image/generate"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"gemini-3-pro-image-preview\",\n \"refer_images\": [\n \"https://cdn.ttapi.io/xxx1.png\",\n \"https://cdn.ttapi.io/xxx2.png\"\n ],\n \"aspect_ratio\": \"1:1\",\n \"image_size\": \"1K\",\n \"google_search\": \"false\",\n \"image_search\": \"false\",\n \"sync_return\": \"true\",\n \"hook_url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
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.ttapi.org/gemini/image/generate")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"gemini-3-pro-image-preview\",\n \"refer_images\": [\n \"https://cdn.ttapi.io/xxx1.png\",\n \"https://cdn.ttapi.io/xxx2.png\"\n ],\n \"aspect_ratio\": \"1:1\",\n \"image_size\": \"1K\",\n \"google_search\": \"false\",\n \"image_search\": \"false\",\n \"sync_return\": \"true\",\n \"hook_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.org/gemini/image/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"gemini-3-pro-image-preview\",\n \"refer_images\": [\n \"https://cdn.ttapi.io/xxx1.png\",\n \"https://cdn.ttapi.io/xxx2.png\"\n ],\n \"aspect_ratio\": \"1:1\",\n \"image_size\": \"1K\",\n \"google_search\": \"false\",\n \"image_search\": \"false\",\n \"sync_return\": \"true\",\n \"hook_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"message": "success",
"data": {
"prompt": "a cute cat",
"refer_images": null,
"image_url": "https://cdn.ttapi.io/other/2025-09-10/8b46aa28-4433-455f-bf5c-f5ccea48baf2.png",
"quota": 2
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}Nano Banana
Nano Banana 图像生成 API 文档
使用 Nano Banana API 通过文本提示生成高质量图像。
POST
/
gemini
/
image
/
generate
cURL
curl --request POST \
--url https://api.ttapi.org/gemini/image/generate \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"prompt": "<string>",
"model": "gemini-3-pro-image-preview",
"refer_images": [
"https://cdn.ttapi.io/xxx1.png",
"https://cdn.ttapi.io/xxx2.png"
],
"aspect_ratio": "1:1",
"image_size": "1K",
"google_search": "false",
"image_search": "false",
"sync_return": "true",
"hook_url": "<string>"
}
'import requests
url = "https://api.ttapi.org/gemini/image/generate"
payload = {
"prompt": "<string>",
"model": "gemini-3-pro-image-preview",
"refer_images": ["https://cdn.ttapi.io/xxx1.png", "https://cdn.ttapi.io/xxx2.png"],
"aspect_ratio": "1:1",
"image_size": "1K",
"google_search": "false",
"image_search": "false",
"sync_return": "true",
"hook_url": "<string>"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: 'gemini-3-pro-image-preview',
refer_images: ['https://cdn.ttapi.io/xxx1.png', 'https://cdn.ttapi.io/xxx2.png'],
aspect_ratio: '1:1',
image_size: '1K',
google_search: 'false',
image_search: 'false',
sync_return: 'true',
hook_url: '<string>'
})
};
fetch('https://api.ttapi.org/gemini/image/generate', 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.ttapi.org/gemini/image/generate",
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([
'prompt' => '<string>',
'model' => 'gemini-3-pro-image-preview',
'refer_images' => [
'https://cdn.ttapi.io/xxx1.png',
'https://cdn.ttapi.io/xxx2.png'
],
'aspect_ratio' => '1:1',
'image_size' => '1K',
'google_search' => 'false',
'image_search' => 'false',
'sync_return' => 'true',
'hook_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$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.ttapi.org/gemini/image/generate"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"gemini-3-pro-image-preview\",\n \"refer_images\": [\n \"https://cdn.ttapi.io/xxx1.png\",\n \"https://cdn.ttapi.io/xxx2.png\"\n ],\n \"aspect_ratio\": \"1:1\",\n \"image_size\": \"1K\",\n \"google_search\": \"false\",\n \"image_search\": \"false\",\n \"sync_return\": \"true\",\n \"hook_url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
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.ttapi.org/gemini/image/generate")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"gemini-3-pro-image-preview\",\n \"refer_images\": [\n \"https://cdn.ttapi.io/xxx1.png\",\n \"https://cdn.ttapi.io/xxx2.png\"\n ],\n \"aspect_ratio\": \"1:1\",\n \"image_size\": \"1K\",\n \"google_search\": \"false\",\n \"image_search\": \"false\",\n \"sync_return\": \"true\",\n \"hook_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.org/gemini/image/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"gemini-3-pro-image-preview\",\n \"refer_images\": [\n \"https://cdn.ttapi.io/xxx1.png\",\n \"https://cdn.ttapi.io/xxx2.png\"\n ],\n \"aspect_ratio\": \"1:1\",\n \"image_size\": \"1K\",\n \"google_search\": \"false\",\n \"image_search\": \"false\",\n \"sync_return\": \"true\",\n \"hook_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"message": "success",
"data": {
"prompt": "a cute cat",
"refer_images": null,
"image_url": "https://cdn.ttapi.io/other/2025-09-10/8b46aa28-4433-455f-bf5c-f5ccea48baf2.png",
"quota": 2
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}由于 Nano Banana 生图是同步响应,生成时间较长,建议使用 https://api.ttapi.org 网关
可用模型
| 模型 | 别名 |
|---|---|
gemini-2.5-flash-image | Nano Banana |
gemini-2.5-flash-image-preview | Nano Banana |
gemini-3-pro-image-preview | Nano Banana Pro |
gemini-3.1-flash-image-preview | Nano Banana 2 |
gemini-3.1-flash-lite-image | Nano Banana 2 Lite |
请求体
application/json
生成图像或修改图像描述词
模型版本
可用选项:
gemini-2.5-flash-image-preview, gemini-2.5-flash-image, gemini-3-pro-image-preview, gemini-3.1-flash-image-preview, gemini-3.1-flash-lite-image 参考图像列表,支持多图,图像url和base64
示例:
[
"https://cdn.ttapi.io/xxx1.png",
"https://cdn.ttapi.io/xxx2.png"
]
图片比例, 仅支持 gemini-3 及以上版本模型使用
1:4、4:1、1:8、8:1 仅 gemini-3.1-flash-image-preview 模型可用
可用选项:
1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1 图片分辨率,注意此处为大写的“K”
可用选项:
1K, 2K, 4K 是否启用谷歌网页搜索
- false:禁用
- true:启用
是否启用谷歌图片搜索
- false:禁用
- true:启用
思考等级
仅 gemini-3.1-flash-image-preview 模型可用
可用选项:
Minimal, High 是否同步。 true-同步返回图像结果,接口等待耗时较长; false-立马返回 jobId ,通过回调或查询获取图像结果。
回调通知地址
最后修改于 2026年7月1日
⌘I