Skip to content

When using the model "Google: Nano Banana Pro (Gemini 3 Pro Image Preview)", I found that the "image_size" parameter could not be used. #25

@cc-320-copy

Description

@cc-320-copy

I hope the author can help answer this! @mattapperson @subtleGradient @mfbx9da4 @sheldonvaughn @louisgv

`from openai import OpenAI

client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=key,
)
messages = [
{
"role": "user",
"content": [
{
"type": 'text',
"text": 'xxxxx'
},
{
"type": 'image_url',
"image_url": {
"url": '',
}
}
],
}
]
aspect_ratio = "9:16" # "1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"
resolution = "2K" # "1K", "2K", "4K"

response = client.chat.completions.create(
model="google/gemini-3-pro-image-preview",
messages=messages,
modalities=["image", "text"],
extra_body={
"image_config": {
"aspect_ratio": aspect_ratio,
"image_size": resolution
}
}
)
try:
open("./response.txt", 'w').write(response.model_dump_json(indent=2))
except Exception as e:
print(e)

response = response.choices[0].message
if response.images:
for image in response.images:
image_url = image['image_url']['url'] # Base64 data URL
open("./t.png", 'wb').write(base64.b64decode(image_url.split(',')[1]))`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions