gemini-3-pro-image ( nano banana pro )
本文介绍 gemini-3-pro-image-preview (模型ID: gemini-3-pro-image-preview) 模型调用 API 的输入输出参数,供您使用接口时查阅字段含义。
以下只展示部分使用到的字段说明,详细说明请参考官方文档 Gemini 3 Pro 图片功能的新变化
请求参数
请求体
响应参数
示例
Gemini 兼容接口
POST https://api.modelverse.cn/v1beta/models/gemini-3-pro-image-preview:generateContent
图片生成(文本转图片)
⚠️ 注意:您必须在配置中添加 responseModalities: [“TEXT”, “IMAGE”]。
curl
curl -s -X POST \
"https://api.modelverse.cn/v1beta/models/gemini-3-pro-image-preview:generateContent" \
-H "x-goog-api-key: $MODELVAULTS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English."}]}],
"tools": [{"google_search": {}}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {"aspectRatio": "1:1", "imageSize": "1K"}
}
}' | jq -r '.candidates[0].content.parts[] | select(.inlineData and (.thought | not)) | .inlineData.data' | head -1 | base64 --decode > butterfly.pngpython
from google import genai
from google.genai import types
import os
client = genai.Client(
api_key=os.getenv("MODELVAULTS_API_KEY", "<MODELVAULTS_API_KEY>"), # 您的API_KEY
http_options=types.HttpOptions(
base_url="https://api.modelverse.cn"
),
)
prompt = "Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English."
aspect_ratio = "1:1" # "1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"
resolution = "1K" # "1K", "2K", "4K"
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=prompt,
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"],
image_config=types.ImageConfig(
aspect_ratio=aspect_ratio, image_size=resolution
),
),
)
for part in response.parts:
# 跳过思考过程中的中间图片,只保留最终输出图片
if getattr(part, "thought", False):
continue
if part.text is not None:
print(part.text)
elif image := part.as_image():
image.save("butterfly.png")
响应示例
{
"candidates": [
{
"content": {
"parts": [
{
"text": "Here is the anatomical sketch of a dissected Monarch butterfly in Da Vinci style..."
},
{
"inlineData": {
"data": "iVBORw0KGgoAAAANSUhEUgAA...",
"mimeType": "image/png"
}
}
],
"role": "model"
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"candidatesTokenCount": 1315,
"totalTokenCount": 1331
}
}{
"error": {
"message": "error_message",
"type": "error_type",
"param": "request_id",
"code": "error_code"
}
}








