Gemini原生(图像)
curl --request POST \
--url https://api.leapx-hub.com/v1/images/generations \
--header 'Authorization: <authorization>'import requests
url = "https://api.leapx-hub.com/v1/images/generations"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.leapx-hub.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.leapx-hub.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_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.leapx-hub.com/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.leapx-hub.com/v1/images/generations")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leapx-hub.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>'
response = http.request(request)
puts response.read_body图像系列
Gemini原生(图像)
Gemini 图像生成模型,文生图与图生图
POST
/
v1
/
images
/
generations
Gemini原生(图像)
curl --request POST \
--url https://api.leapx-hub.com/v1/images/generations \
--header 'Authorization: <authorization>'import requests
url = "https://api.leapx-hub.com/v1/images/generations"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.leapx-hub.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.leapx-hub.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_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.leapx-hub.com/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.leapx-hub.com/v1/images/generations")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leapx-hub.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>'
response = http.request(request)
puts response.read_body简介
Nano Banana 对应 Google Gemini 图像生成模型,包括 Nano Banana(gemini-2.5-flash-image)与 Nano Banana Pro(gemini-3-pro-image-preview)。通过统一的图片生成接口 POST /v1/images/generations 调用,支持文生图、图生图及多图融合等能力。
完整参数与多模型说明请参见 图片生成。
认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxx支持的模型
| 模型 ID | 说明 |
|---|---|
gemini-2.5-flash-image | Nano Banana,高性价比文生图/图生图 |
gemini-3-pro-image-preview | Nano Banana Pro,更高画质与可控性 |
请求示例
- 文生图
- 图生图
curl -X POST "https://api.leapx-hub.com/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"prompt": "一只可爱的橙色小猫坐在花园里,阳光明媚,高质量摄影",
"size": "16:9",
"quality": "high",
"n": 1,
"response_format": "b64_json",
"image_size": "2K",
"mime_type": "image/png",
"response_modalities": "image"
}'
curl -X POST "https://api.leapx-hub.com/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"size": "16:9",
"quality": "high",
"image_size": "3K",
"response_format": "b64_json",
"contents": [
{
"role": "user",
"parts": [
{"text": "根据这张图生成一张俯瞰广州塔的图片"},
{"image": "data:image/png;base64,iVBORw0KGgo..."}
]
}
]
}'
常用参数
- prompt:文生图提示词
- size:宽高比,如
16:9、1:1 - quality:质量档位,如
high - image_size:输出尺寸档位,如
1K、2K、3K - response_format:Gemini 系列仅支持
b64_json,返回 base64 图片 - contents:图生图或多轮对话时使用,格式见 图片生成
⌘I
