<!-- https://bobabanana.com/docs/api/quickstart/ · Quickstart for the BobaBanana API: upload a reference image, generate an image, animate it into a video and download it with curl, Python or JavaScript. -->

# BobaBanana API quickstart: your first image and video

**This quickstart takes you from an API key to a finished image and a finished video in five steps, using curl, Python or JavaScript.** Every generation call returns a job immediately; you then wait for it and download the result.

## What you need before you start

- An API key that starts with `bb_` ([get one](https://bobabanana.com/docs/api/authentication/))
- One reference picture, for example a product photo or a character portrait
- `curl`, Python 3.9+ with `requests`, or Node 18+ (built-in `fetch`)

```bash
export BOBABANANA_API_KEY="bb_your_key_here"
```

## Step 1: upload a reference image

```bash
curl https://bobabanana.com/api/v1/files \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" \
  -F "file=@sofa.jpg"
```

```json
{"id": "file_3f9c2a1b7d4e", "object": "file", "type": "image", "name": "sofa.jpg", "bytes": 912345, "width": 1600, "height": 1200, "warnings": []}
```

You can skip uploading and pass a public `https://` URL or base64 data directly in the next step. Uploading first is best when you reuse the same reference in many requests.

## Step 2: generate an image with the reference

```bash
curl https://bobabanana.com/api/v1/images \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "the sofa in a bright Scandinavian living room, plants, morning light",
    "reference_images": [{"file_id": "file_3f9c2a1b7d4e", "label": "a mustard yellow three-seat sofa with oak legs"}],
    "aspect_ratio": "16:9"
  }'
```

```json
{"id": "x_8d21c0f4a9b3", "object": "job", "type": "image", "status": "queued", "eta_seconds": 140, "poll_after_seconds": 35, "output": {}, "error": null}
```

## Step 3: wait for the job

Long-poll: the call returns as soon as the job finishes, or after 30 seconds with the current status.

```bash
curl "https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3?wait=30" \
  -H "Authorization: Bearer $BOBABANANA_API_KEY"
```

Repeat until `status` is `succeeded`, `failed` or `canceled`. For production, use a [webhook](https://bobabanana.com/docs/api/webhooks/) instead.

## Step 4: download the result

```json
{"id": "x_8d21c0f4a9b3", "status": "succeeded",
 "output": {"image": {"url": "https://bobabanana.com/api/v1/files/content/out/...png?expires=...&signature=...", "content_type": "image/png"}}}
```

Result URLs are signed and need no API key, so you can hand them to a browser or another service. They expire after 24 hours; fetch the job again for a fresh link, and store files you want to keep.

## Step 5: animate it into a 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/living-room.png", "motion": "slow dolly-in toward the sofa, curtains moving in a breeze", "duration_seconds": 5}'
```

## Complete example in Python

```python
import os, time, requests

API = "https://bobabanana.com/api/v1"
H = {"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}"}

def wait(job):
    while job["status"] in ("queued", "running"):
        job = requests.get(f"{API}/jobs/{job['id']}", params={"wait": 30}, headers=H).json()
    if job["status"] != "succeeded":
        raise RuntimeError(job["error"])
    return job

ref = requests.post(f"{API}/files", headers=H, files={"file": open("sofa.jpg", "rb")}).json()
img = wait(requests.post(f"{API}/images", headers=H, json={
    "prompt": "the sofa in a bright Scandinavian living room",
    "reference_images": [{"file_id": ref["id"], "label": "a mustard yellow sofa"}],
}).json())
vid = wait(requests.post(f"{API}/videos", headers=H, json={
    "image": img["output"]["image"]["url"], "motion": "slow dolly-in", "duration_seconds": 5,
}).json())
open("living-room.mp4", "wb").write(requests.get(vid["output"]["video"]["url"]).content)
```

## Complete example in JavaScript (Node 18+)

```javascript
const API = "https://bobabanana.com/api/v1";
const H = { Authorization: `Bearer ${process.env.BOBABANANA_API_KEY}`, "Content-Type": "application/json" };

async function wait(job) {
  while (job.status === "queued" || job.status === "running") {
    job = await (await fetch(`${API}/jobs/${job.id}?wait=30`, { headers: H })).json();
  }
  if (job.status !== "succeeded") throw new Error(job.error?.message);
  return job;
}

const job = await (await fetch(`${API}/images`, {
  method: "POST", headers: H,
  body: JSON.stringify({ prompt: "a fox mascot with aviator goggles waving", aspect_ratio: "1:1" }),
})).json();
const done = await wait(job);
console.log(done.output.image.url);
```

## Next steps

- [Generate images with several references](https://bobabanana.com/docs/api/images/)
- [Make talking videos with a cloned voice](https://bobabanana.com/docs/api/videos/)
- [Give an AI agent BobaBanana as a tool](https://bobabanana.com/docs/api/agents/)
