YM2API Developer docs
Skip to content
Docs / Nano Banana / Gemini Image Download Markdown ↓

← Back to API docs

Nano Banana · Adobe 4K

English translation. Model names, API fields and executable examples retain their original text, including prompts and comments.

Uses Gemini's native GenerateContent protocol. Covers the full Flash and Pro model names, 4K text-to-image generation, and single- or multi-reference image editing.

Gemini NativeAdobe 4KFlash / Pro Text to image Single / multiple references Base64 images

01 · Connection details

API Hosthttps://yyds.seqnode.com Authentication header x-goog-api-key: YOUR_API_KEY Generation endpoint /v1beta/models/{MODEL}:generateContent Response images inlineData.data(Base64)

Protocol: The request body is always JSON. Put reference images in contents[].parts[].inlineData; do not use multipart or send image[].

02 · Two example models

Code
curl "https://yyds.seqnode.com/v1/models" \
  -H "Authorization: Bearer YOUR_API_KEY"
Model Common name Use case 4K parameter
gemini-3.1-flash-image-preview Nano Banana 2 / Flash Speed first: batch drafts and routine generation imageSize="4K"
gemini-3-pro-image-preview Nano Banana Pro Quality first: detail, composition and multi-image blending imageSize="4K"

Use the full model name: Examples use the two Preview names above. Your key's group may also expose full non-Preview or Firefly model names. Use the actual response from GET /v1/models as the source of truth.

03 · Flash text-to-image request

Code
curl "https://yyds.seqnode.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary '{
    "contents": [{
      "role": "user",
      "parts": [{
        "text": "极简产品插画:一只戴蓝色围巾的白色小狐狸站在浅灰背景中,柔和棚拍光线,画面居中,不要文字"
      }]
    }],
    "generationConfig": {
      "responseModalities": ["IMAGE"],
      "imageConfig": {
        "aspectRatio": "1:1",
        "imageSize": "4K"
      }
    }
  }'

04 · Pro text-to-image request

Code
curl "https://yyds.seqnode.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary '{
    "contents": [{
      "role": "user",
      "parts": [{
        "text": "极简产品插画:一只戴蓝色围巾的白色小狐狸站在浅灰背景中,柔和棚拍光线,画面居中,不要文字"
      }]
    }],
    "generationConfig": {
      "responseModalities": ["IMAGE"],
      "imageConfig": {
        "aspectRatio": "1:1",
        "imageSize": "4K"
      }
    }
  }'

05 · Request parameters

Field Required Description
contents is the Conversation content array. An image-generation request must include at least one content item withrole=user.
parts[].text is the Prompt. For multiple images, explicitly describe the roles of “reference 1”, “reference 2”, and so on.
parts[].inlineData Required for reference-image requests mimeType and raw Base64 image data; do not include a Data URL prefix.
responseModalities Recommended ["IMAGE"] returns images only; for accompanying model text, use["TEXT","IMAGE"].
imageConfig.aspectRatio No Common values:1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16, 21:9.
imageConfig.imageSize Yes (in this group) Adobe 4K uses4K. Values are case-sensitive; K must be uppercase.

4K request: In generationConfig.imageConfig, include both aspectRatio and uppercase imageSize: "4K".

06 · One reference image

Put the prompt and references in the same parts array. Only the request body is shown below; replace the endpoint's {MODEL} with either model from §02.

Code
{
  "contents": [{
    "role": "user",
    "parts": [
      {
        "text": "保持参考图主体、姿势和构图,只把围巾改成红色,把背景改成浅蓝色,不要文字"
      },
      {
        "inlineData": {
          "mimeType": "image/jpeg",
          "data": "BASE64_IMAGE_1"
        }
      }
    ]
  }],
  "generationConfig": {
    "responseModalities": ["IMAGE"],
    "imageConfig": {"aspectRatio": "1:1", "imageSize": "4K"}
  }
}

Verified:gemini-3.1-flash-image-preview One PNG reference returned HTTP 200, STOP and a JPEG image.

Match the MIME type: For PNG use image/png, for JPEG use image/jpeg, and for WebP use image/webp. The Base64 string must not include data:image/...;base64,.

07 · Multiple reference images

Add one inlineData per reference image. Array order is the reference order used in the prompt.

Code
{
  "contents": [{
    "role": "user",
    "parts": [
      {
        "text": "以参考图 1 的人物和构图为主体,只采用参考图 2 的服装与光影;保持面部特征,不要文字"
      },
      {
        "inlineData": {
          "mimeType": "image/png",
          "data": "BASE64_IMAGE_1"
        }
      },
      {
        "inlineData": {
          "mimeType": "image/jpeg",
          "data": "BASE64_IMAGE_2"
        }
      }
    ]
  }],
  "generationConfig": {
    "responseModalities": ["IMAGE"],
    "imageConfig": {"aspectRatio": "16:9", "imageSize": "4K"}
  }
}

Verified:gemini-3-pro-image-preview Two PNG references returned HTTP 200, STOP and a JPEG image.

Do not send multipart summaries:{"parts":[{"field":"image[]"...}]} is a packet-capture tool's debug description, not a Gemini payload. Here, parts must be the Gemini JSON content array shown above.

08 · Complete Windows PowerShell example

Code
$model = "gemini-3.1-flash-image-preview"
$imageBase64 = [Convert]::ToBase64String(
  [IO.File]::ReadAllBytes((Resolve-Path ".\reference.jpg"))
)

$body = @{
  contents = @(@{
    role = "user"
    parts = @(
      @{ text = "保持主体不变,只把围巾改成红色" }
      @{ inlineData = @{ mimeType = "image/jpeg"; data = $imageBase64 } }
    )
  })
  generationConfig = @{
    responseModalities = @("IMAGE")
    imageConfig = @{ aspectRatio = "1:1"; imageSize = "4K" }
  }
} | ConvertTo-Json -Depth 12 -Compress

$request = @{
  Uri = "https://yyds.seqnode.com/v1beta/models/$model`:generateContent"
  Method = "Post"
  Headers = @{ "x-goog-api-key" = $env:YM2API_KEY }
  ContentType = "application/json"
  Body = $body
}
$result = Invoke-RestMethod @request

$imagePart = $result.candidates[0].content.parts |
  Where-Object { $_.inlineData } |
  Select-Object -First 1
$extension = if ($imagePart.inlineData.mimeType -eq "image/jpeg") { ".jpg" } else { ".png" }
[IO.File]::WriteAllBytes(
  (Join-Path $PWD "result$extension"),
  [Convert]::FromBase64String($imagePart.inlineData.data)
)

09 · Responses and saving images

Code
{
  "candidates": [{
    "content": {
      "parts": [{
        "inlineData": {
          "mimeType": "image/jpeg",
          "data": "/9j/4AAQSkZJRgABAQ..."
        }
      }]
    },
    "finishReason": "STOP"
  }],
  "usageMetadata": {
    "promptTokenCount": 11,
    "candidatesTokenCount": 1096,
    "totalTokenCount": 1107
  }
}

Do not assume the output is PNG. Read inlineData.mimeType first to choose the extension, then Base64-decode the image from inlineData.data.

10 · Common errors and fixes

Symptom Likely cause Fix
401 Missing or invalid key, or incorrect header name Use this group's key and sendx-goog-api-key or Bearer authentication
404 Not Found The model is not in this group, or its name is missing-preview Copy the full model name returned in §02
400 invalid argument Incorrect JSON nesting, field casing, aspect ratio or size Compare with §03–§07; usegenerationConfig.imageConfig and uppercase4K
MissinginlineData The request did not ask forIMAGE, or the model declined the content AddresponseModalities:["IMAGE"] and inspectfinishReason and the error body
Base64 decoding fails Truncated data, an included Data URL prefix, or a text part was selected Select the part containinginlineData and directly decode itsdata
concurrency_limit The image-generation queue is full Wait 10–30 seconds, then retry with exponential backoff

11 · Adobe 4K ratios and pixels

Aspect ratio 4K pixels Applies to
1:1 4096×4096 Flash / Pro
3:2 / 2:3 5056×3392 / 3392×5056 Flash / Pro
4:3 / 3:4 4800×3584 / 3584×4800 Flash / Pro
5:4 / 4:5 4608×3712 / 3712×4608 Flash / Pro
16:9 / 9:16 5504×3072 / 3072×5504 Flash / Pro
21:9 6336×2688 Flash / Pro

Aspect-ratio parameter: Send only the ratio string, such as "16:9". Pixel dimensions follow the model's 4K tier; do not send separate width and height.

For Gemini's native fields, see Google Gemini image-generation documentation.

Updated 2026-09-14 · Separate documentation for Site 2

Reference-image support (2026-09-16)

These results apply to Banana 2 gemini-3.1-flash-image-preview, 1K, 1:1, and Gemini generateContent. No boundary result is recorded for Banana Pro or 2K/4K.

Group Supported range Visual verification
#142 Banana 2 channel A Confirmed maximum: 14. 15 returns HTTP 400 with an explicit 14-image limit 14 succeeds; all numbers 1–14 appear
#125 Banana 2/pro AS/AD mixed 15 accepted, hard maximum unconfirmed 15 produced numbers 1–10; counts 14 through 10 produced only 1–6; 9, 7 and 6 were complete; 8 produced only 1–6
#139 Banana 2/pro Adobe 15 accepted, hard maximum unconfirmed Counts 15 through 9 produced only 1–6; one 8-image request was complete; 7 produced 1–6; 6 was complete

Group #125 results varied with the selected route. Neither #125 nor #139 has a confirmed effective reference limit. Missing items may result from upstream processing or generation; these images alone do not prove a fixed truncation limit. HTTP 200 is not evidence that all 15 references were used. Six references is not a guarantee for complex materials either.

Add one contents[].parts[].inlineData entry per reference, in the intended order. n is not a Gemini native reference-count field. Describe each reference's purpose and check the output for missing material.