メインコンテンツへ移動

モデルガイド

Nano Banana 2

gemini-3.1-flash-image

バランス

日常の生成と編集に適した、複数サイズ・比率を持つバランス型ルートです。

0.5K から 4K画像編集
モデル情報
モデル ID
gemini-3.1-flash-image
参考価格
$0.055/ 回
出力サイズ
512 / 1K / 2K / 4K
API 形式
Gemini native

プロンプトプリセット

以下は YingTu で現在利用できる設定です。

商品写真

A clean product photo of a matte ceramic coffee mug on a light stone table, soft window light, natural shadows, minimal styling.

エディトリアル風景

An editorial travel photograph of a mountain lake at sunrise, layered atmospheric depth, natural color, fine detail.

参照画像編集

Preserve the main subject and composition. Replace the background with a quiet modern studio using soft directional daylight.

利用できる設定

以下は画像スタジオで現在利用できる設定です。

適した用途

  • 日常の画像生成
  • 参照画像を使う編集
  • 複数の出力サイズのテスト

利用前の確認

  • 表示速度は目安であり、納期保証ではありません。
  • 編集品質は参照画像と指示に左右されます。
  • 利用前に文字、ロゴ、手、小さな細部を確認してください。
画像編集: 対応

API クイックスタート

画像スタジオと同じリクエスト形式を使った例です。

API ページを見る
gemini-3.1-flash-image
import base64
import mimetypes
import os
import sys

import requests

API_KEY = os.environ.get("LAOZHANG_API_KEY")
if not API_KEY:
    raise RuntimeError("Set the LAOZHANG_API_KEY environment variable before running this example.")

API_URL = "https://api2.laozhang.ai/v1beta/models/gemini-3.1-flash-image:generateContent"
REQUEST_TIMEOUT_SECONDS = 500

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

payload = {
    "contents": [{
        "parts": [
            {"text": "A clean product photo of a matte ceramic coffee mug on a light stone table, soft window light, natural shadows, minimal styling."}
        ]
    }],
    "generationConfig": {
        "responseModalities": ["IMAGE"],
        "imageConfig": {
            "imageSize": "2K"
        }
    }
}

try:
    response = requests.post(
        API_URL,
        headers=headers,
        json=payload,
        timeout=REQUEST_TIMEOUT_SECONDS,
    )
except requests.Timeout as error:
    print(
        "Request timed out after 500 seconds. The result status may be unknown; "
        "check call and billing logs before retrying.",
        file=sys.stderr,
    )
    raise SystemExit(1) from error

if response.status_code != 200:
    print(f"API error {response.status_code}: {response.text}", file=sys.stderr)
    raise SystemExit(1)

try:
    result = response.json()
except ValueError as error:
    print("API returned a non-JSON response.", file=sys.stderr)
    raise SystemExit(1) from error

if not isinstance(result, dict):
    print("API returned an unexpected JSON shape.", file=sys.stderr)
    raise SystemExit(1)

image_part = None
for candidate in result.get("candidates", []):
    for part in candidate.get("content", {}).get("parts", []):
        inline_data = part.get("inlineData") or part.get("inline_data")
        if inline_data and inline_data.get("data"):
            image_part = inline_data
            break
    if image_part:
        break

if not image_part:
    response_id = result.get("responseId", "not provided")
    print(f"No image data in response. responseId={response_id}", file=sys.stderr)
    raise SystemExit(1)

mime_type = image_part.get("mimeType") or image_part.get("mime_type") or "image/png"
encoded_image = image_part["data"]
if encoded_image.startswith("data:"):
    header, encoded_image = encoded_image.split(",", 1)
    mime_type = header[5:].split(";", 1)[0] or mime_type

extension_by_mime = {
    "image/jpeg": "jpg",
    "image/png": "png",
    "image/webp": "webp",
    "image/gif": "gif",
}
extension = extension_by_mime.get(mime_type, "bin")
output_path = f"output.{extension}"

with open(output_path, "wb") as output_file:
    output_file.write(base64.b64decode(encoded_image, validate=True))

print(f"Image saved: {output_path} ({mime_type})")

Studio の例

これらの画像には生成時のモデルとプロンプトが記録されていません。視覚例であり、モデルのテスト結果ではありません。

Studio の例
Studio の例
Studio の例

テスト記録

YingTu の公開テスト記録

ここには、テスト条件と生成結果を確認できる形で公開した YingTu の記録だけを掲載します。未公開の記録は表示しません。

公開テスト結果なし

商品デザインの保持

形状、比率、色、ロゴ、パッケージ上の文字に意図しない変化がないかを確認します。

公開テスト結果なし

背景の置き換え

被写体が保たれているか、輪郭が崩れていないか、指定した背景になっているかを確認します。