> For the complete documentation index, see [llms.txt](https://docs.nebulablock.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nebulablock.com/api-reference/inference-api/images.md).

# Images

Generate and edit images through Nebula Block's OpenAI-compatible images endpoints.

Generate an image from a prompt, or edit an existing image. For a walkthrough, see [Image Generation](/products/serverless-inference/image-generation.md).

## Create an image

### HTTP Request

`POST` `{API_URL}/images/generations`

where `API_URL = https://inference.nebulablock.com/v1`.

### Body Parameters

#### model `string` *required*

The image model to use, for example `gemini/gemini-3.1-flash-image-preview`.

#### prompt `string` *required*

A text description of the image to generate.

#### n `integer`

Number of images to generate. Defaults to `1`.

#### size `string`

Output size as `WxH`. Mapped to the nearest aspect ratio the model supports — `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9`, `4:5`, or `5:4`.

#### response\_format `string`

`b64_json` or `url`. Defaults to `b64_json`.

#### user `string`

An optional identifier for the end user making the request.

#### provider\_options `dict`

Model-specific options passed through to the provider. Commonly supported keys:

* **aspect\_ratio** `string`: Set the aspect ratio directly instead of via `size`.
* **image\_size** `string`: Output resolution, where the model supports more than one.
* **image\_urls** `list`: Reference images to condition the generation on.
* **person\_generation** `string`: The model's policy for generating people.
* **output\_mime\_type** `string`: Output format, such as `image/png`.
* **compression\_quality** `integer`: Compression quality for lossy formats.
* **thinking\_level** `string`: How much the model reasons before generating.

### Response Attributes

#### created `integer`

Unix timestamp of when the images were generated.

#### data `list`

The generated images. Each entry contains **b64\_json** `string`, the base64-encoded image.

### Example

#### Request

```bash
curl -X POST "https://inference.nebulablock.com/v1/images/generations" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $NEBULA_API_KEY" \
    --data-raw '{
        "model": "gemini/gemini-3.1-flash-image-preview",
        "prompt": "A snowy street in Old Montreal at dusk, warm window light",
        "size": "1536x1024"
    }'
```

#### Response

```json
{
    "created": 1756944000,
    "data": [
        { "b64_json": "iVBORw0KGgoAAAANSUhEUg..." }
    ]
}
```

## Edit an image

### HTTP Request

`POST` `{API_URL}/images/edits`

This endpoint takes `multipart/form-data`, not JSON.

### Form Parameters

| Parameter | Requirement | Type     | Description                                                          |
| --------- | ----------- | -------- | -------------------------------------------------------------------- |
| `image`   | Required    | `file`   | The image to edit. PNG, JPEG, WebP, or GIF                           |
| `prompt`  | Required    | `string` | A description of the desired edit                                    |
| `model`   | Required    | `string` | An image-editing model, such as `gemini/gemini-2.5-flash-image-edit` |
| `size`    | Optional    | `string` | Output size as `WxH`. Defaults to `1024x1024`                        |

### Example

#### Request

```bash
curl -X POST "https://inference.nebulablock.com/v1/images/edits" \
    -H "Authorization: Bearer $NEBULA_API_KEY" \
    -F 'model=gemini/gemini-2.5-flash-image-edit' \
    -F 'prompt=Replace the sky with an aurora' \
    -F 'image=@./input.png'
```

#### Response

The same shape as image creation — a `created` timestamp and a `data` array of base64 images.

## Legacy endpoint

An older, non-OpenAI image endpoint remains available at `POST https://api.nebulablock.com/api/v1/images/generation`. It takes flat parameters — `prompt`, `negative_prompt`, `num_steps`, `guidance_scale`, `width`, `height`, `seed`, `image`, and `mask` — rather than `provider_options`. Prefer `/v1/images/generations` for new work.

## See also

* [Image Generation](/products/serverless-inference/image-generation.md)
* [Videos](/api-reference/inference-api/videos.md)
* [Model Catalog](/products/serverless-inference/model-catalog.md)
