<!-- https://bobabanana.com/docs/api/videos/ · POST /v1/videos turns a picture or prompt into a 2-15 s video, copies the motion of your clip onto a character, extends a clip, and adds lip sync or sound. -->

# AI video generation API: image to video, text to video, motion transfer and extend

**`POST /v1/videos` makes a video clip in one of four modes, the same as in the Video Studio: Image to video (optionally ending on a last frame you choose), Text to video (optionally with reference images or library assets), Motion transfer and Extend. A clip runs 2 to 10 seconds at `720p` and 3 to 15 at `1080p` and `2160p`; a motion transfer follows its clip (1 to 15 seconds).** Optionally the character speaks a script in a saved or cloned voice with lip sync, the clip follows your own recorded audio, or a generated sound effect is mixed in. With motion transfer, a character or object of yours performs the motion of a clip you send, for as long as the clip (up to 15 seconds).

## Four video modes

| Mode | Send | Result |
|---|---|---|
| **Image to video** | `image` + `motion` | Your picture, animated |
| **Image to video with a last frame** | `image` + `last_frame` + `motion` | The clip moves from your picture to the last frame ([example](#example-image-to-video-with-a-last-frame)) |
| **Text to video** | `prompt` (+ optional `motion`) | BobaBanana generates a first frame from your prompt, then animates it |
| **Text to video with references** | `prompt` + `reference_images` / `assets` + `motion` | A first frame that keeps your characters, objects or places consistent, then animated |
| **Motion transfer** | `motion_video` (a 1-15 s clip) + `image` or one entry in `assets` + optional `prompt` | Your subject performs the motion, gestures and camera move of the clip, with the clip's sound when it has any ([details](#motion-transfer)) |
| **Extend** | `extend_video` (a clip of 15 s at most) + `prompt` | A new clip that starts on the last frame of yours ([example](#example-extend-a-video)) |

Text to video and Extend can also take a `last_frame` to choose how the clip ends.

## Add speech or sound

| Add | Send | Result |
|---|---|---|
| **Cloned voice** | a mode above + `voice` (sample) + `script` + `voice_consent: true` | The character says the script in that voice, lip-synced |
| **Saved voice** | a mode above + `voice: "@handle"` + `script` | Same, with a voice from your library |
| **Your own audio** | a mode above + `audio` | The clip follows your speech or soundtrack |
| **Sound effect** | a mode above + `sound_effect` | A generated sound mixed under the clip |

Speech, audio and sound effects work in every mode except motion transfer (which keeps the clip's own sound instead). Speech and audio are not available at `1080p` and `2160p`.

## Request fields

| Field | Type | Description |
|---|---|---|
| `image` | [media input](https://bobabanana.com/docs/api/files/#media-inputs) | Start frame to animate. Leave out to generate one |
| `last_frame` | media input | Last frame: the clip ends on this picture. Priced as a first + last frame video |
| `motion_video` | media input (`url` or `data`) | [Motion transfer](#motion-transfer): a clip whose motion is copied onto the subject (`image`, or one character or object in `assets`). MP4 or MOV, H.264 or H.265, 1 to 15 s, at most 50 MB (about 25 MB as `data`), 23.976 to 60 fps, each side 256 to 4096 px, width / height between 0.4 and 2.5; `file_id` is not accepted. The video lasts as long as the clip (rounded to whole seconds); `duration_seconds` and `resolution` are ignored. `aspect_ratio` is optional: with `match_pose` the video takes the clip's shape, otherwise `aspect_ratio` or the subject's shape. Not with `last_frame`, `reference_images`, `extend_video`, `voice`, `script`, `audio` or `sound_effect` |
| `match_pose` | boolean | Motion transfer only. Default `true`: the subject is first redrawn in the poses, framing and shape of the clip's opening, middle and closing frames (the opening frame only for clips under 2 s), and the video is guided by those pictures. `false` animates your picture as it is |
| `keep_sound` | boolean | Motion transfer only. Default `true`: the clip's own sound is put on the result (when the clip has sound) |
| `first_shot_only` | boolean | Motion transfer only. Default `false`. When the clip has [cuts](#clips-with-cuts), `true` makes only its first shot, at the normal price of a clip that long; `false` makes every scene and joins them at 1.5 times the price |
| `extend_video` | media input (`url` or `data`) | An MP4, MOV or WEBM clip of 15 seconds at most (100 MB by `url`, about 25 MB as `data`). Its last frame becomes the start frame. Not with `image`, `reference_images` or `assets`; `file_id` is not accepted |
| `prompt` | string, up to 1500 chars | The scene. Required without `image`; also the motion prompt when `motion` is empty |
| `reference_images` | array of media inputs | References for the generated first frame (not with `image`) |
| `assets` | array of `@handles` | Library assets for the first frame (not with `image`) |
| `motion` | string, up to 400 chars | Camera and subject movement, e.g. "slow push-in, she turns and smiles" |
| `duration_seconds` | number, 2 to 15 | Default 5. 2 to 10 at `720p`; 3 to 15 at `1080p` and `2160p` (10 at most with `last_frame`); outside these a 400 `invalid_request`. A started second counts as a whole second |
| `aspect_ratio` | `16:9`, `9:16`, `1:1`, `4:3`, `3:4` | Default `16:9`. At `1080p` and `2160p` only `16:9` and `9:16` are made; any other shape is a 400 `invalid_request` |
| `resolution` | `720p`, `1080p`, `2160p` | Default `720p` (standard). `1080p` and `2160p` (4K) use premium rendering and cost more; not with `voice`, `script` or `audio` |
| `voice` | `"@handle"` or [voice sample](https://bobabanana.com/docs/api/speech/#voice-samples) | Voice that speaks `script` |
| `voice_consent` | boolean | Must be `true` with an uploaded voice sample |
| `script` | string, up to 600 chars | Words the character says |
| `audio` | media input (audio) | Pre-recorded speech or soundtrack that drives the clip (instead of `voice` + `script`) |
| `sound_effect` | `{"prompt": "...", "duration_seconds": 8}` | Generated sound mixed under the clip |
| `webhook_url`, `metadata`, `name` | | As for [images](https://bobabanana.com/docs/api/images/) |

## Video sizes

| `aspect_ratio` | Size in pixels |
|---|---|
| `16:9` | 832 × 480 |
| `9:16` | 480 × 832 |
| `1:1` | 640 × 640 |
| `4:3` | 768 × 576 |
| `3:4` | 576 × 768 |

These are the sizes from the BobaBanana studio. When a busy queue sends a video to busy-time rendering, it keeps the same aspect ratio but can come out larger (for example 1024 × 768 for 4:3).

A video with `last_frame` (including `extend_video` with `last_frame`) uses premium rendering first, at 768 pixels high in the requested aspect ratio, so it can come out larger than the table above; if that is not available, it is made in the BobaBanana studio. A video with `reference_images` or `assets` is made in the studio and moves to busy-time rendering, at 720 pixels high, only when the queue is long. Either way it costs the same credits. Both need "Make work quickly at busy times" on in the workspace's Settings, and content with people also needs "Make work that shows people quickly at busy times".

## Example: image to video

```bash
curl https://bobabanana.com/api/v1/videos \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"image": "https://example.com/beach.png", "motion": "waves roll in, camera slowly pans right", "duration_seconds": 6}'
```

## Example: text to video

```bash
curl https://bobabanana.com/api/v1/videos \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "a lighthouse on a rocky coast at sunset, waves breaking below", "motion": "slow aerial orbit around the lighthouse", "duration_seconds": 5}'
```

BobaBanana generates the first frame from `prompt`, then animates it. The job returns that frame as `output.image`.

## Example: text to video with references

```json
{
  "prompt": "Maya stands at a bus stop in the rain holding a red umbrella",
  "reference_images": [{"file_id": "file_a1", "label": "Maya, curly red hair, green raincoat"}],
  "motion": "she looks up at the sky and smiles, rain falling",
  "aspect_ratio": "9:16",
  "duration_seconds": 5
}
```

## Example: talking video with a cloned voice and lip sync

```json
{
  "image": {"file_id": "file_portrait"},
  "voice": {"file_id": "file_voice", "transcript": "Hi, I'm Sam, and this is how I sound when I talk normally."},
  "voice_consent": true,
  "script": "Welcome back! Today I'll show you three tricks for faster mornings.",
  "motion": "she talks warmly to the camera with small natural head movements",
  "duration_seconds": 6,
  "aspect_ratio": "9:16"
}
```

If you leave out `transcript`, BobaBanana transcribes the sample first (adds a few seconds).

## Example: saved voice by @handle plus a sound effect

```json
{
  "prompt": "@captain_fox on the deck of a ship in a storm",
  "assets": ["@captain_fox"],
  "voice": "@fox_voice",
  "script": "Hold steady, crew! The harbour is just past those rocks.",
  "sound_effect": {"prompt": "howling wind, crashing waves, creaking wood", "duration_seconds": 8},
  "duration_seconds": 7
}
```

## Example: drive the clip with your own audio

```json
{"image": "https://example.com/host.png", "audio": "https://example.com/intro.mp3", "motion": "the host speaks to camera", "duration_seconds": 8}
```

## Example: image to video with a last frame

```bash
curl https://bobabanana.com/api/v1/videos \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"image": {"file_id": "file_day"}, "last_frame": {"file_id": "file_night"}, "motion": "time-lapse from day to night", "duration_seconds": 6}'
```

The clip starts on `image` and ends on `last_frame`. Use two pictures with the same framing for the smoothest result.

## Example: extend a video

```bash
curl https://bobabanana.com/api/v1/videos \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"extend_video": {"url": "https://example.com/clip.mp4"}, "prompt": "she keeps walking and turns to the camera", "duration_seconds": 5}'
```

The new clip starts exactly where yours ends. The job's `input.extend_video` shows the extracted frame's `file_id` and
the length of your clip (`source_seconds`). A clip longer than 15 seconds, or one that cannot be read, is a 400
`invalid_video`. Join the two clips yourself if you want one longer video.

## 1080p and 4K

Set `resolution` to `1080p` or `2160p` for a sharper clip (1080p or 4K), in `16:9` or `9:16`. These
always use premium rendering (the workspace needs "Make work quickly at busy times" on in Settings; content with people
also needs "Make work that shows people quickly at busy times") and cost more than standard videos. They do not wait in the studio's
queue, but premium jobs are sent one at a time across the platform, so a job can still wait its turn.
Their price comes from premium rendering's live price when the job is accepted: `cost.credits_estimate` is the most the job
can cost and is held when it is accepted, and the job is charged what it really cost once it is done (never more than
the estimate). Send `max_credits` to refuse a job that would cost more. The request answers `400
resolution_unavailable` when the resolution cannot be made for the workspace now ("Make work quickly at busy times" off, a person
with "Make work that shows people quickly at busy times" off, the workspace's monthly premium spending limit reached). If the live price rises above what the job
was accepted at before it renders, or the render fails, the job fails and its credits are released; send it again
for a new price.

```bash
curl https://bobabanana.com/api/v1/videos -H "Authorization: Bearer $BB_KEY" -H "Content-Type: application/json" \
  -d '{"image": "https://example.com/beach.png", "motion": "slow aerial push-in", "resolution": "2160p", "duration_seconds": 8, "max_credits": 900}'
```

## Motion transfer

Send a clip of someone moving (a dance, a gesture, a walk, a camera move) as `motion_video`, and the subject to move as
`image` or as one character or object in `assets` (its main view is used). The result is a new video of your subject
performing that motion with the clip's timing, framing and camera move, for as long as the clip (1 to 15 seconds). The
subject keeps its own face, hair, clothing and proportions; the person in the clip is not copied.

```bash
curl https://bobabanana.com/api/v1/videos \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"motion_video": {"url": "https://example.com/dance.mp4"}, "assets": ["@captain_fox"], "prompt": "keep the red jacket"}'
```

1. **Pose match** (`match_pose`, on by default): your subject is redrawn three times, standing exactly like the person
   in the clip's opening, middle and closing frames: the same pose, position and size in the frame, camera angle,
   framing and shape, with your subject's own natural proportions. Clips under 2 seconds use the opening frame only.
   Matching the start, middle and end keeps your character steady through the whole clip and makes the result follow
   the clip much more closely; turn it off only when your picture already matches the clip's first frame.
2. **Motion:** the clip's motion is applied to your subject, guided by the pose-matched pictures, in the studio
   when it can make the clip, otherwise with premium rendering (never busy-time rendering). Premium rendering needs both
   of the workspace's Settings switches, "Make work quickly at busy times" and "Make work that shows people quickly at busy times", whatever the subject is, because the clip usually shows a person. When it cannot be made for the workspace now, the request answers `400 motion_unavailable` with the reason.
3. **Sound** (`keep_sound`, on by default): the clip's own sound is put back on the result.

`prompt` (or `motion`) is optional: add details to keep, such as clothing or the background. The job's
`input.motion_video.seconds`, `input.duration_seconds`, `input.aspect_ratio`, `input.match_pose`, `input.keep_sound`
and `input.keyframes` (how many pose-matched pictures were made first: 3, 1 or 0) show what was made. If the render
fails, the job fails and its credits are released. For the best result use a clip with one person, fully in view, on a steady camera, and a subject picture with a similar framing.

### Clips with cuts

A clip that cuts between several shots (a tutorial, an edited reel) is recognised automatically when you send it.
Quick motion, a hand or a brush passing in front of the lens and on-screen text are not cuts. Each scene is then made
on its own, so your subject follows every shot's framing instead of blending them together:

1. every scene gets its own pose-matched pictures, from that scene's own frames (its opening frame, and its middle and
   closing frames for a scene of 2 seconds or more);
2. every scene's motion is applied to your subject the normal way;
3. the scenes are joined in their original order, each exactly as long as in your clip, under the clip's own sound
   (with `keep_sound`).

Because every scene is matched and made separately, a clip with cuts costs **1.5 times** what one continuous clip of
the same length costs, and never less than its scenes cost on their own (several short scenes can cost more than
that). The job's `input.scenes` shows `count`, `made`, `scene_seconds`, `price_multiplier`, `first_shot_only` and
`reason` (for example "This clip has 3 scenes"); a continuous clip has no `input.scenes`.

A clip can have up to **6 scenes**, each at least **1 second** long: every scene needs its own pictures and its own
render, and a shorter scene has too little motion to follow. Otherwise the request answers `400 motion_scenes` with the
reason (`too_many` or `too_short`), `scenes`, `scene_seconds`, `max_scenes`, `min_scene_seconds` and
`first_shot_ok`. Send `first_shot_only: true` to make just the clip's first shot (it must be at least 1 second long),
at the normal price of a clip that long; its own sound is kept up to the cut.

To see the scenes and the price before you send a job, post the same body to `POST /v1/videos/estimate`. Nothing is
queued, held or stored:

```bash
curl https://bobabanana.com/api/v1/videos/estimate \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" -H "Content-Type: application/json" \
  -d '{"motion_video": {"url": "https://example.com/tutorial.mp4"}, "image": "https://example.com/me.png"}'
```

```json
{"object": "estimate", "credits_estimate": 342, "duration_seconds": 12, "scenes": 3, "scenes_made": 3,
 "scene_seconds": [4.5, 3.6, 3.9], "price_multiplier": 1.5, "normal_credits": 228, "first_shot_only": false,
 "reason": "This clip has 3 scenes"}
```

`credits_estimate` is what the job would hold if you sent it now; `normal_credits` is what one continuous clip of the
same length costs. A clip whose scenes cannot be made answers `400 motion_scenes`, as the job itself would.

## What a video costs

Videos are priced by class, so a plain clip costs less than one that keeps references consistent:

| Class | When | Price key (no voice / voice) |
|---|---|---|
| Plain | `image` or `extend_video` alone, or `prompt` with no references or assets | `video` / `video_voice` |
| References | any `reference_images` or `assets` | `video_ref` / `video_voice_ref` |
| First + last frame | `last_frame` is given | `video_frames` / `video_voice_frames` |
| Motion transfer | `motion_video` is given | `video_motion` |

A `1080p` or `2160p` video uses one key per resolution, `video_1080` or `video_2160`, priced from premium rendering's live
price (see above) whatever its class. A generated first frame costs an `image` on top. The job's `cost.video_price_key`
and `cost.resolution` show the price used, and
[`GET /v1/prices`](https://bobabanana.com/docs/api/credits/) lists the current prices. `video_1080` and `video_2160` show `"pricing":
"live_quote"` there: their credits are the most they cost at the regular rate, and the job's
`cost.credits_estimate` is what it is held at.

A motion transfer (`video_motion`) is priced from the length of your clip, plus one `image` for each pose-matched
picture when `match_pose` is on (three, or one for a clip under 2 seconds): `cost.credits_estimate` is the most it can cost, and you are charged what it really cost, never
more. Clips of 3 seconds or less can be made on a dearer route with a minimum length, so they cost more per second
than longer clips. A clip with cuts costs 1.5 times as much, or the normal price with `first_shot_only` ([details](#clips-with-cuts)). `GET /v1/prices` shows `video_motion` with `"pricing": "live_quote"`: its `base_credits` plus
`per_second_credits` for each second of the clip is the most any clip of that length costs. Rely on the job's
`cost.credits_estimate`.

## How a video job runs

1. **First frame:** skipped when you send `image`; otherwise generated from `prompt` and references.
   With `last_frame`, the clip is guided to end on that picture.
2. **Speech:** with `voice` + `script`, the line is spoken in that voice (after a transcript step if needed).
3. **Sound effect:** generated if requested.
4. **Animation:** the frame is animated, driven by the speech or `audio` when present.

When it succeeds, `output.video.url` is an MP4. A generated first frame is also returned as `output.image`, and generated speech as `output.speech`, so you can reuse them.

## Tips for better AI videos

1. **Describe motion, not the picture**, in `motion`: camera moves, gestures, what changes.
2. **Keep scripts short**: about 2.5 words per second of `duration_seconds`.
3. **Use a front-facing, well-lit portrait** for talking videos.
4. **Use a clean voice sample**: 5 to 30 seconds, one speaker, no music.
5. **Start with 5 seconds** while you iterate, then go longer.

## Frequently asked questions

### How long can a video be?
2 to 10 seconds per job at `720p`, up to 15 at `1080p` and `2160p`, and as long as your clip (up to 15 seconds) for a
motion transfer. For longer pieces, generate several clips that share references and join them.

### Does the API support lip sync?
Yes. With `voice` + `script`, or with your own `audio`, the character's mouth follows the speech.

### Is voice cloning allowed for any voice?
Only voices that are yours or that you have the speaker's explicit permission to clone. `voice_consent: true` records that confirmation.

### Can I animate an image that BobaBanana generated earlier?
Yes. Pass the earlier job's `output.image.url` as `image`.

### What format is the output?
MP4 (H.264) video. With speech, `audio` or a sound effect, that sound is in the file; otherwise the clip may carry generated ambient sound.
