Copyable examples
Run against the live API
These snippets call https://nanobananavideo.com/api/v1/. Parameter lists live in /docs/.
curl, text to video
curl
export NB_API_KEY=nb_YOUR_API_KEY
curl https://nanobananavideo.com/api/v1/text-to-video.php \
-X POST \
-H "Authorization: Bearer $NB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Aerial of a pine forest at dawn, light fog, 16:9",
"video_model": "seedance2",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}'JavaScript
generate.mjs
const res = await fetch("https://nanobananavideo.com/api/v1/text-to-video.php", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NB_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "A luxury watch on wet slate, slow orbit, rain",
video_model: "seedance2",
resolution: "720p",
duration: 5,
aspect_ratio: "16:9",
}),
});
const data = await res.json();
if (!data.success) throw new Error(data.error);
console.log(data.video_id, data.video_url);Python
generate.py
import json, os, urllib.request
req = urllib.request.Request(
"https://nanobananavideo.com/api/v1/text-to-video.php",
data=json.dumps({
"prompt": "A luxury watch on wet slate, slow orbit, rain",
"video_model": "seedance2",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9",
}).encode(),
headers={
"Authorization": f"Bearer {os.environ['NB_API_KEY']}",
"Content-Type": "application/json",
},
method="POST",
)
with urllib.request.urlopen(req) as res:
print(json.loads(res.read().decode())["video_url"])Image to video
image-to-video
curl https://nanobananavideo.com/api/v1/image-to-video.php \
-X POST \
-H "Authorization: Bearer $NB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://example.com/frame.jpg",
"prompt": "Gentle camera push-in, natural motion",
"video_model": "sora2",
"duration": 10,
"aspect_ratio": "9:16"
}'Official org: github.com/nanobananavideo. Copy from this page when you need snippets that match production.