BananaPro 已发布,可通过 API & 第三方使用
MODEL_ID="gemini-3-pro-image-preview"
PROJECT_ID="YOUR_PROJECT_ID"
# 发送请求
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/global/publishers/google/models/${MODEL_ID}:generateContent \
-d '{
"contents": {
"role": "user",
"parts": {
"text": "Generate a hyper-realistic infographic of a gourmet cheeseburger, deconstructed to show the texture of the toasted brioche bun, the seared crust of the patty, and the glistening melt of the cheese."
}
},
"generation_config": {
"response_modalities": ["TEXT", "IMAGE"]
}
}'
pip3 install --upgrade --user google-genai
# Python代码示例
from IPython.display import Image, Markdown, display
from google import genai
from google.genai.types import GenerateContentConfig, Part
import os
PROJECT_ID = "YOUR_PROJECT_ID"
LOCATION = "global"
client = genai.Client(vertexai=True, project=PROJECT_ID, location=LOCATION)
MODEL_ID = "gemini-3-pro-image-preview"
prompt = """
Generate a hyper-realistic infographic of a gourmet cheeseburger, deconstructed to show the texture of the toasted brioche bun, the seared crust of the patty, and the glistening melt of the cheese.
"""
response = client.models.generate_content(
model=MODEL_ID,
contents=prompt,
config=types.GenerateContentConfig(
response_modalities=['IMAGE', 'TEXT'],
image_config=types.ImageConfig(
aspect_ratio="16:9",
image_size="2K",
),
),
)
# 显示图像
if response.candidates[0].finish_reason != types.FinishReason.STOP:
reason = response.candidates[0].finish_reason
raise ValueError(f"Prompt Content Error: {reason}")
for part in response.candidates[0].content.parts:
if part.thought:
continue
if part.inline_data:
display(Image(data=part.inline_data.data, width=1000))
MODEL_ID="gemini-3-pro-image-preview"
API_KEY="YOUR_API_KEY"
# 发送请求
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/global/publishers/google/models/${MODEL_ID}:generateContent \
-d '{...}'