WaveSpeedAI Nano Banana 2 Image Generation/Editing
by @chengzeyi
Generate and edit images using Google's Nano Banana 2 model via WaveSpeed AI. Supports text-to-image generation and image editing with natural language promp...
import wavespeed from 'wavespeed';const output_url = (await wavespeed.run(
"google/nano-banana-2/text-to-image",
{
prompt: "A red vintage Porsche 911 on a winding mountain road at golden hour, photorealistic",
aspect_ratio: "16:9",
resolution: "2k",
output_format: "png"
}
))["outputs"][0];
Image Editing
Model ID: google/nano-banana-2/edit
Edit existing images using natural language prompts. Supports up to 14 input images.
#### Parameters
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| images | string[] | Yes | [] | URLs of input images to edit (1-14 images) |
| prompt | string | Yes | -- | Text description of the desired edit |
| aspect_ratio | string | No | -- | Output aspect ratio. One of: 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1 |
| resolution | string | No | 1k | Image resolution. One of: 1k, 2k, 4k |
| output_format | string | No | png | Output format. One of: png, jpeg |
#### Example
import wavespeed from 'wavespeed';// Upload local images first, or use existing URLs
const imageUrl = await wavespeed.upload("/path/to/living-room.png");
const output_url = (await wavespeed.run(
"google/nano-banana-2/edit",
{
images: [imageUrl],
prompt: "Change the wall color to warm terracotta and add indoor plants",
aspect_ratio: "16:9",
resolution: "4k",
output_format: "png"
}
))["outputs"][0];
#### Multi-Image Editing
// Upload multiple local images
const faceUrl = await wavespeed.upload("/path/to/face.png");
const hairstyleUrl = await wavespeed.upload("/path/to/hairstyle.png");const output_url = (await wavespeed.run(
"google/nano-banana-2/edit",
{
images: [faceUrl, hairstyleUrl],
prompt: "Apply the hairstyle from the second image to the person in the first image"
}
))["outputs"][0];
clawhub install wavespeed-nano-banana-2