跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com
Google logo

Nano Banana 2 Lite

Text-to-Image • Google

查看 MarkdownAgent 设置
  • Third-party
  • Zero data retention

Google 速度最快的 Gemini 图像生成模型,适用于快速创作和迭代图像。

模型信息
上下文窗口 ↗65,536 个 token
条款和许可证链接 ↗
更多信息链接 ↗
零数据保留是
定价在 Cloudflare 仪表板中查看定价 ↗

用法

const response = await env.AI.run(
  'google/nano-banana-2-lite',
  {
    prompt:
      'A playful concept sketch of a compact solar-powered delivery robot rolling through a leafy neighborhood, bright morning light, clean product design',
    aspect_ratio: '16:9',
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "google/nano-banana-2-lite",
  "input": {
    "prompt": "A playful concept sketch of a compact solar-powered delivery robot rolling through a leafy neighborhood, bright morning light, clean product design",
    "aspect_ratio": "16:9"
  }
}'
概念草图
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/google/nano-banana-2-lite/concept-sketch.jpg"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

示例

产品渲染 — 创建方形 PNG 产品图像
const response = await env.AI.run(
  'google/nano-banana-2-lite',
  {
    prompt:
      'A studio product render of translucent wireless earbuds in a frosted glass charging case, soft gradient background, premium advertising style',
    aspect_ratio: '1:1',
    output_format: 'png',
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "google/nano-banana-2-lite",
  "input": {
    "prompt": "A studio product render of translucent wireless earbuds in a frosted glass charging case, soft gradient background, premium advertising style",
    "aspect_ratio": "1:1",
    "output_format": "png"
  }
}'
产品渲染
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/google/nano-banana-2-lite/product-render.png"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

参数

prompt
stringrequired
aspect_ratio
stringenum: match_input_image, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
output_format
stringenum: jpg, png
resolution
stringenum: 1K, 2K, 4K
image
stringformat: uri

API schema(原始)

输入
输出

这篇文档对您有帮助吗?