from google import genai
from google.genai import types as gtypes
from PIL import Image
import os

client = genai.Client(
    vertexai=True,
    project=os.environ["GCP_PROJECT_ID"],
    location="global",  # gemini-3.x 이미지 모델은 글로벌 전용
)

prompt = "여기에 프롬프트"
image = Image.open("input.png")

response = client.models.generate_content(
    model="gemini-3-pro-image-preview",  # Nano Banana 2
    contents=[prompt, image],
    config=gtypes.GenerateContentConfig(
        response_modalities=["IMAGE"],
    ),
)

for part in response.candidates[0].content.parts:
    if part.inline_data:
        with open("output.png", "wb") as f:
            f.write(part.inline_data.data)
