Nano Banana 2 (Gemini 3.1 Flash Image)

    google/gemini-3.1-flash-image

    Mid-tier image generation and editing model in the series, with near-flagship visual quality at higher generation speed. Renders legible text and photorealistic subjects, suited for infographics and marketing visuals.

    Creative GenerationHigh-Quality GenerationContent Generation
    模態
    輸入 / 輸出價格
    $0.5 / $3M tokens
    上下文
    131072
    發布時間
    2026-02-26

    價格

    Token 類型輸入輸出快取讀快取寫
    文字$0.5/ M tokens$3/ M tokens$0/ M tokens$0/ M tokens
    圖片$0/ M tokens$60/ M tokens$0/ M tokens$0/ M tokens

    快速開始

    可直接貼上執行下方範例程式碼。Gate.AI API 與 OpenAI 相容,多數 SDK 只需替換 base URL;切換模型時,只需修改模型 ID。

    1

    Get your API key

    Sign in to the Gate.AI console and create a new key under "API Keys". Keep it safe and send it via the Authorization header on every request.

    前往控制台建立金鑰
    2

    Make a request

    Send a POST request to the Chat Completions endpoint with a model ID and an array of messages to get a reply.

    POSThttps://api.gate.ai/openai/v1/chat/completions
    curl --location "https://api.gate.ai/openai/v1/chat/completions" \
      --header "Authorization: Bearer {API_KEY}" \
      --header "Content-Type: application/json" \
      --data '{
      "model": "gemini-3.1-flash-image",
      "messages": [
        {"role": "user", "content": "Hello"}
      ]
    }'
    3

    Handle the response \\\\\& streaming

    By default a full JSON response is returned. Add "stream": true to the request body to receive incremental chunks over SSE.

    POSThttps://api.gate.ai/openai/v1/chat/completions
    curl --no-buffer --location "https://api.gate.ai/openai/v1/chat/completions" \
      --header "Authorization: Bearer {API_KEY}" \
      --header "Content-Type: application/json" \
      --data '{
      "model": "gemini-3.1-flash-image",
      "messages": [
        {"role": "user", "content": "Hello"}
      ],
      "stream": true
    }'

    端點

    基礎 URL、請求方法與必要請求頭,皆依當前模型的協議模板渲染。

    POSThttps://api.gate.ai/openai/v1/chat/completions
    欄位
    值
    Authorization
    驗證請求頭,使用 Bearer {API_KEY} 格式傳遞 API Key
    Content-Type
    請求內容型別,固定為 application/json
    model
    Model ID; the current model is gemini-3.1-flash-image
    messages
    Ordered array of conversation messages
    stream
    Whether to return the result as an SSE stream

    基礎 URL、請求方法與必要請求頭,皆依當前模型的協議模板渲染。

    POSThttps://api.gate.ai/openai/v1/images/generations
    欄位
    值
    Authorization
    驗證請求頭,使用 Bearer {API_KEY} 格式傳遞 API Key
    Content-Type
    請求內容型別,固定為 application/json
    model
    Image model ID; the current model is gemini-3.1-flash-image
    prompt
    Required text description of the image
    n
    Optional number of images, from 1 to 10; default is 1
    size
    Optional output image size; supported values depend on the model
    response_format
    Optional url or b64_json; not supported by every model
    stream
    Optional pass-through field; the current image flow is synchronous

    基礎 URL、請求方法與必要請求頭,皆依當前模型的協議模板渲染。

    POSThttps://api.gate.ai/openai/v1/images/edits
    欄位
    值
    Authorization
    驗證請求頭,使用 Bearer {API_KEY} 格式傳遞 API Key
    Content-Type
    請求內容型別,固定為 application/json
    model
    Required image model ID; the current model is gemini-3.1-flash-image
    image
    Required reference image file used as editing input
    mask
    Optional PNG mask whose transparent area is edited
    prompt
    Required editing description, up to 1000 characters
    n
    Optional number of images, from 1 to 10; default is 1
    size
    Optional output image size; supported values depend on the model
    response_format
    Optional url or b64_json; not supported by every model

    基礎 URL、請求方法與必要請求頭,皆依當前模型的協議模板渲染。

    POSThttps://api.gate.ai/v1beta/models/{{model_id}}:generateContent
    欄位
    值
    Authorization
    驗證請求頭,使用 Bearer {API_KEY} 格式傳遞 API Key
    Content-Type
    請求內容型別,固定為 application/json
    model
    Model ID in the URL path; the current model is gemini-3.1-flash-image
    contents
    Array of conversation contents sent to the model
    contents[].role
    Message role; use user for user messages
    contents[].parts[].text
    Text content sent to the model
    alt
    Response format parameter for streaming requests; set it to sse

    相關模型

    Gemini 3.8 Flash

    Flash tier in Gemini 3.8 with gains over 3.7 Flash across software engineering, agent workflows, and multi-step reasoning.

    Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image)

    The lightest image model in its series, producing images in about four seconds with consistent character rendering and precise edits. Suited for high-throughput pipelines and interactive visual iteration.

    Gemini 3.5 Flash

    Designed for efficient multimodal AI tasks, offering strong coding, reasoning, real-time chat, and agent execution at Flash-tier cost and speed.

    Gemini 3.1 Flash Lite

    A high-efficiency multimodal lite model for low-latency, high-volume workloads like translation, classification, and data extraction, priced at about half of Gemini 3 Flash.

    Gemma-4-31B

    Open-weights dense model with stronger math and coding, plus native function calling for self-hosted agent workflows.

    Gemini 3.1 Pro

    Google's latest. Strong reasoning with native image and video.

    Gemini 3 Flash

    Speed-tier variant in the Gemini 3 line, pairing Pro-grade reasoning with Flash-level latency and cost, built for agent workflows and high-throughput interactive apps.

    Nano Banana Pro (Gemini 3 Pro Image)

    Built-in reasoning; complex multi-turn creation; up to 4K; optional web grounding.

    Nano Banana (Gemini 2.5 Flash Image)

    Built for fast generation and conversational editing; low latency and cost; multimodal text-and-image input.

    Gemini 2.5 Flash Lite

    A lightweight reasoning model in the Gemini 2.5 family, optimized for ultra-low latency and cost efficiency, with faster token generation and higher throughput. Thinking is disabled by default but can be enabled via API.