使用 Nano Banana 2 生成和参考图驱动图像
Documentation Index
Fetch the complete documentation index at: https://www.qhaigc.net/docs/llms.txt
Use this file to discover all available pages before exploring further.
/v1/images/generations 接口调用 nano-banana-2 生成图片。除标准 prompt 和 size 外,还支持通过 extra_fields 传入参考图、原生分辨率和宽高比等高级参数。
nano-banana-2Google 图像生成模型,支持参考图、多图融合、原生 2K 分辨率和 4K 超分。nano-banana-pro适合需要更强角色一致性和复杂图像理解的场景。nano-banana-2size 外,还支持 Nano Banana 原生分辨率值。
| size | image_size | aspect_ratio | 说明 |
|---|---|---|---|
256x256 | 512 | 1:1 | OpenAI 标准 |
512x512 | 512 | 1:1 | OpenAI 标准 |
1024x1024 | 1K | 1:1 | OpenAI 标准默认值 |
1024x1792 | 1K | 9:16 | OpenAI 标准竖图 |
1792x1024 | 1K | 16:9 | OpenAI 标准横图 |
512 | 512 | - | 原生分辨率 |
1K | 1K | - | 原生分辨率 |
2K | 2K | - | 原生分辨率 |
4K | 4K | - | 原生分辨率 |
extra_fields 传入 Nano Banana 特有能力:
| 参数 | 类型 | 说明 |
|---|---|---|
reference_images | string[] | 参考图片列表,支持图片 URL 和 base64 data URI |
temperature | number | 生成温度,控制随机性,通常范围 0.0 到 2.0 |
image_size | string | 覆盖 size 推导出的分辨率,可选 512、1K、2K、4K |
aspect_ratio | string | 覆盖 size 推导出的宽高比,如 1:1、16:9、9:16、3:4 |
extra_fields.image_size 优先于 sizeextra_fields.aspect_ratio 优先于 sizeextra_fields.image_size 和 extra_fields.aspect_ratio 会覆盖 size: "1024x1024" 原本映射出的 1K 和 1:1。
| 场景 | 行为 |
|---|---|
size 不在映射表中 | 不设置分辨率映射,模型使用默认值 |
extra_fields 未传 | 仅使用 prompt 和 size,保持 OpenAI 兼容 |
extra_fields 中字段无效 | 忽略无效字段,继续按默认逻辑生成 |
| 参考图 URL 不可访问 | URL 原样传递给模型,由模型侧返回错误或降级处理 |
| 错误 | 说明 |
|---|---|
no base64 image found in response | 模型未返回图片,检查 prompt 或模型是否支持生图 |
failed to upload image | 图片上传到代理服务器失败,检查服务端图片代理配置 |
chat response contains no choices | 模型返回空响应,可能被安全策略过滤 |
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.