<!-- https://bobabanana.com/docs/api/images/ · Generate AI images that keep characters, products and places consistent: a prompt plus up to 10 labelled reference images or @handles to POST /v1/images. -->

# Image generation API with reference images

**`POST /v1/images` creates a new picture from a text prompt and up to 10 reference images, keeping the people, products and places in those references recognisably the same.** Each reference can carry a short label so the model knows which picture is which, which is what makes multi-subject scenes work.

## When to use reference-based image generation

- **Character consistency:** the same person or mascot in new poses, outfits and settings.
- **Product shots:** your exact product, label and colour in lifestyle scenes.
- **Interior and place continuity:** the same room or location from a new angle or at a new time of day.
- **Composite scenes:** several characters, objects and a place combined into one coherent picture.
- **Storyboards:** a series of frames that keep one cast, ready to animate with the [video API](https://bobabanana.com/docs/api/videos/).

## Request

```http
POST https://bobabanana.com/api/v1/images
Authorization: Bearer bb_...
Content-Type: application/json
```

| Field | Type | Required | Description |
|---|---|---|---|
| `prompt` | string, up to 1500 chars | yes | What to create |
| `reference_images` | array of [media inputs](https://bobabanana.com/docs/api/files/#media-inputs) | no | Pictures to keep consistent. Each may have a `label` |
| `assets` | array of strings | no | Approved library assets by handle, e.g. `["@maya", "@red_sofa"]` |
| `aspect_ratio` | `16:9`, `9:16`, `1:1`, `4:3`, `3:4` | no | Default `16:9` |
| `webhook_url` | https URL | no | Receives a signed POST when the job finishes |
| `metadata` | object | no | Up to 16 string keys, echoed back on the job |
| `name` | string | no | Label shown in the BobaBanana studio |

The `Idempotency-Key` header is supported: repeating a request with the same key within 24 hours returns the original job instead of creating a new one.

## Output sizes by aspect ratio

| `aspect_ratio` | Size in pixels |
|---|---|
| `16:9` | 1344 × 768 |
| `9:16` | 768 × 1344 |
| `1:1` | 1024 × 1024 |
| `4:3` | 1152 × 896 |
| `3:4` | 896 × 1152 |

## Example: one product, new scene

```bash
curl https://bobabanana.com/api/v1/images \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "prompt": "the sneaker on a wet city street at night, neon reflections, low angle",
    "reference_images": [{"url": "https://example.com/sneaker.png", "label": "a white leather sneaker with a green heel tab"}],
    "aspect_ratio": "4:3"
  }'
```

## Example: several references in one scene

```json
{
  "prompt": "Maya sits on the sofa reading, the floor lamp beside her, evening light",
  "reference_images": [
    {"file_id": "file_a1", "label": "Maya, a woman in her thirties with curly red hair"},
    {"file_id": "file_b2", "label": "a mustard yellow three-seat sofa"},
    {"file_id": "file_c3", "label": "a brass arc floor lamp"}
  ],
  "aspect_ratio": "16:9"
}
```

BobaBanana tells the model "Picture 1 is Maya…, Picture 2 is a mustard yellow sofa…" before your prompt and asks it to keep every referenced subject exactly as pictured.

## Example: library assets by @handle

```json
{"prompt": "@maya walking her dog through an autumn park", "assets": ["@maya"], "aspect_ratio": "9:16"}
```

A character asset from the library brings its approved face picture and, when available, its full-body picture (it counts as two of the 10 references). See [assets](https://bobabanana.com/docs/api/assets/).

## Response

`202 Accepted` with a [job](https://bobabanana.com/docs/api/jobs/). When it succeeds:

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

## Tips for better reference-consistent images

1. **Label every reference** with what it shows and its key details ("navy wool coat with brass buttons"), not just a name.
2. **Use clear, well-lit references** at least 512 px on the short side; the upload response warns about low resolution.
3. **One subject per reference** works better than a crowded photo.
4. **Say what must stay the same** in the prompt ("keep the logo text exactly").
5. **Reuse the same references** across a series for the most consistent results.

## Frequently asked questions

### How many reference images can I send?
Up to 10 per request, counting the pictures brought in by library assets.

### Which image formats are accepted?
PNG, JPG, WEBP, GIF and BMP, up to 25 MB. Images over 2048 px on the long side are scaled down.

### Can I generate without any reference?
Yes. With no references `POST /v1/images` is plain text-to-image.

### How do I make a series of images with the same character?
Send the same reference images (or the same `@handle`) with every request and keep the character description in the labels the same.
