Google AI Studio logo
Google AI Studio

Gemini 3 Pro Image (AI Studio)

Google AI Studio 文生图预览模型,支持 1K/2K/4K 分辨率、思维链推理与 Search Grounding

类型 图像模型 Model ID gemini-3-pro-image-preview
上下文长度输入 65K / 输出 32K tokens
分辨率默认 1K,可选 2K / 4K,支持多种纵横比
参考图数量最多 14 张参考图,支持人物一致性

定价与规格

💰 定价

输入$2 / M tokens
输出$12 / M tokens

⚙️ 规格

上下文长度输入 65K / 输出 32K tokens
分辨率默认 1K,可选 2K / 4K,支持多种纵横比
参考图数量最多 14 张参考图,支持人物一致性
特色能力Search grounding、Thinking 推理、多轮生成与编辑
提供商Google AI Studio

API 调用示例

Python

from google import genai
from google.genai import types
from google.api_core.client_options import ClientOptions

client = genai.Client(
    api_key="your-api-key",
    client_options=ClientOptions(api_endpoint="https://api.xairouter.com")
)

resp = client.models.generate_content(
    model="gemini-3-pro-image-preview",
    contents="生成一张 2K 复古科幻城市夜景,霓虹灯和飞行汽车",
    config=types.GenerateContentConfig(
        response_modalities=["IMAGE", "TEXT"],
        image_config=types.ImageConfig(
            aspect_ratio="16:9",
            image_size="2K"
        ),
        tools=[{"google_search": {}}]   # 可选:Search Grounding
    )
)

for part in resp.parts:
    if image := part.as_image():
        image.save("city.png")
    elif part.text:
        print(part.text)

cURL

curl -X POST \
  "https://api.xairouter.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts":[{"text":"Generate a 1K studio portrait of a tech founder in soft rim light"}]}],
    "generationConfig": {
      "responseModalities": ["IMAGE"],
      "imageConfig": {"aspectRatio": "3:4", "imageSize": "1K"}
    },
    "tools": [{"googleSearch": {}}]
  }'