Nano Banana Pro API

Nano Banana Pro 是更偏专业创意生产的高质量图片模型,适合商业视觉、专业素材和精细图像改造。

模型 key

  • google/nano-banana-pro — Nano Banana Pro

支持的 mode 与输入

模型 Mode 名称 输入要求
google/nano-banana-pro text_to_image 文生图 Prompt max 10000 chars
google/nano-banana-pro image_to_image 图生图 Prompt max 10000 chars
Images reference: 1-8 files, 30 MB, formats jpg, jpeg, png, webp

参数

模型 参数 默认值 可选值 适用 mode
google/nano-banana-pro aspect_ratio 1:1 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, auto 全部 mode
google/nano-banana-pro resolution 1K 1K, 2K, 4K 全部 mode
google/nano-banana-pro output_format png png, jpg 全部 mode

价格

模型 价格
google/nano-banana-pro 每张图片 2 credits

生产建议

  • 显式传入 mode
  • 只使用上表列出的参数值。
  • 媒体输入类 mode 请先用 POST /api/v1/files 上传素材。
  • 如果页面包含多个变体,请使用你真正需要的模型 key。

示例:文生图

curl https://img2vid.net/api/v1/generations \
  -H "Authorization: Bearer $BUBLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/nano-banana-pro",
    "mode": "text_to_image",
    "prompt": "A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting",
    "aspect_ratio": "1:1",
    "resolution": "1K",
    "output_format": "png"
  }'

示例:图生图

Upload an image first, then pass the returned URL to image_urls.

curl https://img2vid.net/api/v1/generations \
  -H "Authorization: Bearer $BUBLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/nano-banana-pro",
    "mode": "image_to_image",
    "prompt": "Transform the source into a clean commercial product image while preserving the main object",
    "image_urls": ["https://example.com/source.png"],
    "aspect_ratio": "1:1",
    "resolution": "1K",
    "output_format": "png"
  }'

SDK 示例

下面的示例使用本页的公开模型 key、mode 和参数值。片段假设你已经按快速开始初始化了 SDK client,并引入了对应语言需要的 SDK 类型。媒体输入类 mode 仍然需要先上传本地文件,再把返回的 URL 放入 image_urlsstart_framevideo_urls 等公开字段。

JavaScript / TypeScript

const task = await buble.generations.create({
  model: 'google/nano-banana-pro',
  mode: 'text_to_image',
  prompt:
    'A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting',
  aspect_ratio: '1:1',
  resolution: '1K',
  output_format: 'png',
});

const result = await buble.generations.wait(task.data.id);
console.log(result.data.result?.images?.[0]?.url);

Python

task = client.generations.create(
    model="google/nano-banana-pro",
    mode="text_to_image",
    prompt="A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting",
    aspect_ratio="1:1",
    resolution="1K",
    output_format="png",
)

result = client.generations.wait(task["data"]["id"])
print(result["data"]["result"]["images"][0]["url"])

Go

task, err := client.Generations.Create(ctx, &buble.CreateGenerationRequest{
	Model:  "google/nano-banana-pro",
	Mode:   "text_to_image",
	Prompt: "A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting",
	Params: map[string]any{
		"aspect_ratio": "1:1",
		"resolution": "1K",
		"output_format": "png",
	},
})
if err != nil {
	return err
}

result, err := client.Generations.Wait(ctx, task.Data.ID)
if err != nil {
	return err
}
fmt.Println(result.Data.Result.Images[0].URL)

Rust

let task = client.generations().create(
    CreateGenerationRequest::new("google/nano-banana-pro")
        .mode("text_to_image")
        .prompt("A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting")
        .param("aspect_ratio", "1:1")?
        .param("resolution", "1K")?
        .param("output_format", "png")?,
).await?;

let result = client
    .generations()
    .wait(&task.data.id, WaitOptions::default())
    .await?;

Swift

let task = try await client.generations.create(
    try CreateGenerationRequest(model: "google/nano-banana-pro")
        .mode("text_to_image")
        .prompt("A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting")
        .param("aspect_ratio", "1:1")
        .param("resolution", "1K")
        .param("output_format", "png")
)

let result = try await client.generations.wait(task.data.id)
print(result.data.result?.images?.first?.url.absoluteString ?? "")

Dart / Flutter

final task = await client.generations.create(
  CreateGenerationRequest(
    model: 'google/nano-banana-pro',
    mode: 'text_to_image',
    prompt: 'A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting',
  ).withParam('aspect_ratio', '1:1').withParam('resolution', '1K').withParam('output_format', 'png'),
);

final result = await client.generations.wait(task.data.id);
print(result.data.result?.images.firstOrNull?.url);

Elixir

{:ok, task} =
  Buble.Generations.create(client, %{
    model: "google/nano-banana-pro",
    mode: "text_to_image",
    prompt: "A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting",
    aspect_ratio: "1:1",
    resolution: "1K",
    output_format: "png"
  })

{:ok, result} = Buble.Generations.wait(client, task["data"]["id"])
IO.puts(result["data"]["result"]["images"] |> List.first() |> Map.fetch!("url"))

Java

Envelope<GenerationTask> task = client.generations().create(
        CreateGenerationRequest.builder()
                .model("google/nano-banana-pro")
                .mode("text_to_image")
                .prompt("A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting")
                .param("aspect_ratio", "1:1")
                .param("resolution", "1K")
                .param("output_format", "png")
                .build());

Envelope<GenerationTask> result = client.generations().wait(task.getData().getId());

.NET

var task = await client.Generations.CreateAsync(new CreateGenerationRequest
{
    Model = "google/nano-banana-pro",
    Mode = "text_to_image",
    Prompt = "A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting"
}.WithParam("aspect_ratio", "1:1").WithParam("resolution", "1K").WithParam("output_format", "png"));

var result = await client.Generations.WaitAsync(task!.Data!.Id!);

PHP

$task = $client->generations()->create(
    CreateGenerationRequest::make(
        model: 'google/nano-banana-pro',
        mode: 'text_to_image',
        prompt: 'A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting',
    )
    ->withParam('aspect_ratio', '1:1')
    ->withParam('resolution', '1K')
    ->withParam('output_format', 'png')
);

$result = $client->generations()->wait($task['data']['id']);

Ruby

task = client.generations.create(
  model: "google/nano-banana-pro",
  mode: "text_to_image",
  prompt: "A premium editorial product image of a minimalist ceramic coffee grinder on a warm walnut counter, soft studio lighting",
  aspect_ratio: "1:1",
  resolution: "1K",
  output_format: "png"
)

result = client.generations.wait(task.dig("data", "id"))
puts result.dig("data", "result", "images", 0, "url")