跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.crazyrouter.com/llms.txt

Use this file to discover all available pages before exploring further.

Nano Banana 2

POST /v1/images/generations
nano-banana-2nano-banana-2 的公开别名。用户侧统一使用 OpenAI Images 兼容协议;服务端会把 output_formatoutput_compressionresolutionaspect_ratio 等统一参数转换成 Gemini / Vertex 原生请求。
nano-banana-2 属于长耗时图片模型。生产接入请优先使用主承接线路 https://cn.crazyrouter.com/v1,完整生成端点为 https://cn.crazyrouter.com/v1/images/generations。账号登录、充值和控制台仍使用 https://crazyrouter.com

模型名

推荐模型名等价底层模型
nano-banana-2nano-banana-2
推荐在客户代码里使用 nano-banana-2。如果你的系统已经直接写了 nano-banana-2,也可以继续通过同一个 /v1/images/generations 入口调用。

请求参数

参数类型必填说明
modelstring推荐 nano-banana-2;也兼容 nano-banana-2
promptstring生成或编辑指令
image_inputstring 或 string[]参考图 URL;不传则为文生图
resolutionstring1K2K4K
aspect_ratiostring1:116:99:1621:9auto
output_formatstringpngjpeg / jpg
output_compressioninteger0-100,用于 JPEG 压缩质量
ninteger生成数量,默认 1
不要在客户请求里传 Gemini 原生字段,例如 generationConfigimageConfigimageOutputOptionsimage_output_options。这些字段由 Crazyrouter 在服务端按当前上游协议自动生成。

文生图示例

curl -X POST https://cn.crazyrouter.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "A clean ecommerce hero shot of a red apple on a white background",
    "resolution": "1K",
    "aspect_ratio": "16:9",
    "output_format": "jpeg",
    "output_compression": 85
  }'

参考图编辑示例

cURL
curl -X POST https://cn.crazyrouter.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "把参考图改成横幅广告图,保留主体,背景更干净",
    "image_input": [
      "https://example.com/reference.png"
    ],
    "resolution": "1K",
    "aspect_ratio": "16:9",
    "output_format": "png"
  }'

响应

响应保持 OpenAI Images 风格。默认优先读取 data[0].url;少数兼容渠道可能返回 data[0].b64_json
{
  "created": 1778990000,
  "data": [
    {
      "url": "https://media.crazyrouter.com/task-artifacts/2026/05/17/sync-image/request-id-1.png"
    }
  ]
}

迁移说明

旧代码如果直接调用:
POST /v1beta/models/nano-banana-2:generateContent
建议迁移到:
POST https://cn.crazyrouter.com/v1/images/generations
并把 Gemini 原生参数改成统一参数:
Gemini 原生概念Crazyrouter 统一参数
imageConfig.aspectRatioaspect_ratio
imageConfig.imageSizeresolution
imageOutputOptions.mimeTypeoutput_format
imageOutputOptions.compressionQualityoutput_compression