Upload and Generate
Upload a source image and use it in a Buble generation request.
Upload and Generate
This end-to-end example uploads a source image, then uses it for image-to-image generation.
1. Upload the source image
curl https://buble.ai/api/v1/files \
-H "Authorization: Bearer $BUBLE_API_KEY" \
-F "file=@./room.png" \
-F "file_type=image" \
-F "model=google/nano-banana-pro" \
-F "mode=image_to_image"Save the returned data.url.
2. Create a generation
curl https://buble.ai/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": "Redesign this room as a premium modern Japanese-inspired interior with warm oak, paper lantern lighting, low furniture, and calm editorial styling",
"image_urls": ["https://example.com/uploaded-room.png"],
"aspect_ratio": "16:9",
"resolution": "1K",
"output_format": "png"
}'3. Poll the result
curl https://buble.ai/api/v1/generations/YOUR_GENERATION_ID \
-H "Authorization: Bearer $BUBLE_API_KEY"Node.js version
import fs from 'node:fs';
const fileForm = new FormData();
fileForm.append(
'file',
new Blob([fs.readFileSync('./room.png')], { type: 'image/png' }),
'room.png'
);
fileForm.append('file_type', 'image');
fileForm.append('model', 'google/nano-banana-pro');
fileForm.append('mode', 'image_to_image');
const upload = await fetch('https://buble.ai/api/v1/files', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.BUBLE_API_KEY}` },
body: fileForm,
});
const { data: uploaded, error: uploadError } = await upload.json();
if (uploadError) throw new Error(uploadError.message);
const generation = await fetch('https://buble.ai/api/v1/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.BUBLE_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'google/nano-banana-pro',
mode: 'image_to_image',
prompt:
'Redesign this room as a premium modern Japanese-inspired interior.',
image_urls: [uploaded.url],
aspect_ratio: '16:9',
resolution: '1K',
output_format: 'png',
}),
});
const { data: task, error } = await generation.json();
if (error) throw new Error(error.message);
console.log(task.id);