> ## 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 an output size and quality, 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.

## 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": "gpt-image-2",
          "image_size": "landscape_4_3",
          "quality": "high",
          "output_format": "png"
        }
      }
    ]
  }'
```

Run the agent with no video inputs:

```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`            | `"gpt-image-2"`                                                                                                             | No          | `"gpt-image-2"`   | 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"` | Output size preset.                                               |
    | `custom_width`     | `number`                                                                                                                    | Conditional | `1280`            | Required when `image_size` is `custom`; multiple of 16, 256-3840. |
    | `custom_height`    | `number`                                                                                                                    | Conditional | `960`             | Required when `image_size` is `custom`; multiple of 16, 256-3840. |
    | `quality`          | `"low" \| "medium" \| "high"`                                                                                               | No          | `"high"`          | Generation quality.                                               |
    | `output_format`    | `"jpeg" \| "png" \| "webp"`                                                                                                 | No          | `"png"`           | Generated image format.                                           |
    | `selected_context` | `{images:string[]}`                                                                                                         | No          | empty list        | Uploaded image references.                                        |

    ### Example

    ```json theme={null}
    {
      "prompt": "A clean ecommerce hero image of white running shoes on blue acrylic",
      "model": "gpt-image-2",
      "image_size": "landscape_4_3",
      "quality": "high",
      "output_format": "png"
    }
    ```
  </Accordion>
</AccordionGroup>
