> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mosaic.so/llms.txt
> Use this file to discover all available pages before exploring further.

# 7. Image Generation

> Generate images from prompts and optional image context.

Image Generation creates still images from text prompts. Use it for thumbnails, reference frames, product concepts, style exploration, or as input context for Video Generation.

## How It Works

Write a prompt, choose a model, format, aspect ratio, and quality setting, and optionally attach image references. Mosaic stores the generated image as a workspace asset so it can be reused by downstream tiles or API runs.

Nano Banana Lite is the default image model. Nano Banana and Nano Banana Pro add selectable output resolution. GPT Image 2 remains available with its low, medium, and high quality settings.

Image context accepts selected upstream image assets only. Nano Banana models can use up to 14 selected images. GPT Image 2 can use up to 3 selected images. Video and audio inputs are not sent to Image Generation.

## API Usage

Create an agent shell:

```bash theme={null}
curl -X POST "https://api.mosaic.so/agent/create" \
  -H "Authorization: Bearer mk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Hero frame generator",
    "visibility": "private"
  }'
```

Add an Image Generation node:

```bash theme={null}
curl -X POST "https://api.mosaic.so/agent/AGENT_ID/update" \
  -H "Authorization: Bearer mk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "operations": [
      {
        "op": "create_node",
        "node_type_id": "18b998a0-2ea7-4676-a5d3-3ae6c8ac0b72",
        "params_used": {
          "prompt": "A premium studio product photo of a chrome espresso machine on a marble counter",
          "model": "nano-banana-lite",
          "aspect_ratio": "auto",
          "output_format": "png"
        }
      }
    ]
  }'
```

Run the agent:

```bash theme={null}
curl -X POST "https://api.mosaic.so/agent/AGENT_ID/run" \
  -H "Authorization: Bearer mk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "callback_url": "https://your-webhook.com/mosaic"
  }'
```

## API Info

<AccordionGroup>
  <Accordion title="Node Params & API Details" icon="code">
    * **Node ID:** `18b998a0-2ea7-4676-a5d3-3ae6c8ac0b72`

    ### Node params

    | Param              | Type                                                                                                                                      | Required    | Default              | Notes                                                                                                                |
    | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------------- | -------------------------------------------------------------------------------------------------------------------- |
    | `prompt`           | `string`                                                                                                                                  | Yes         | `""`                 | Image prompt.                                                                                                        |
    | `model`            | `"nano-banana-lite" \| "nano-banana" \| "nano-banana-pro" \| "gpt-image-2"`                                                               | No          | `"nano-banana-lite"` | Image model.                                                                                                         |
    | `image_size`       | `"square_hd" \| "square" \| "portrait_4_3" \| "portrait_16_9" \| "landscape_4_3" \| "landscape_16_9" \| "auto" \| "custom"`               | No          | `"landscape_4_3"`    | GPT Image 2 output size preset.                                                                                      |
    | `custom_width`     | `number`                                                                                                                                  | Conditional | `1280`               | GPT Image 2 only. Required when `image_size` is `custom`; multiple of 16, 256-3840.                                  |
    | `custom_height`    | `number`                                                                                                                                  | Conditional | `960`                | GPT Image 2 only. Required when `image_size` is `custom`; multiple of 16, 256-3840.                                  |
    | `quality`          | `"low" \| "medium" \| "high"`                                                                                                             | No          | `"high"`             | GPT Image 2 generation quality.                                                                                      |
    | `aspect_ratio`     | `"auto" \| "21:9" \| "16:9" \| "3:2" \| "4:3" \| "5:4" \| "1:1" \| "4:5" \| "3:4" \| "2:3" \| "9:16" \| "4:1" \| "1:4" \| "8:1" \| "1:8"` | No          | `"auto"`             | Nano Banana image aspect ratio. Nano Banana Pro supports up to `21:9` through `9:16`.                                |
    | `resolution`       | `"0.5K" \| "1K" \| "2K" \| "4K"`                                                                                                          | No          | `"1K"`               | Nano Banana output resolution. Nano Banana Pro supports `1K`, `2K`, and `4K`. Nano Banana Lite uses standard output. |
    | `output_format`    | `"jpeg" \| "png" \| "webp"`                                                                                                               | No          | `"png"`              | Generated image format.                                                                                              |
    | `selected_context` | `{images:string[]}`                                                                                                                       | No          | empty list           | Selected upstream image references. Nano Banana models support up to 14; GPT Image 2 supports up to 3.               |

    ### Example

    ```json theme={null}
    {
      "prompt": "A clean ecommerce hero image of white running shoes on blue acrylic",
      "model": "nano-banana",
      "aspect_ratio": "16:9",
      "resolution": "1K",
      "output_format": "png"
    }
    ```
  </Accordion>
</AccordionGroup>
