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

# Edit images

> Edit images using text prompts

Edit or extend images using AI models from various providers. This endpoint accepts `multipart/form-data` requests for file uploads.

> [!NOTE]
>
> **OpenAI Compatibility**
>
> This endpoint implements the [OpenAI Images Edit API](https://platform.openai.com/docs/api-reference/images/createEdit). You can use any [OpenAI SDK](https://docs.lumenfall.ai/client-libraries/openai-sdk.md) by changing the base URL to `https://api.lumenfall.ai/openai/v1`.
>
> Lumenfall [normalizes behavior](https://docs.lumenfall.ai/unified-model-behavior.md) across all models - mapping parameters, emulating features, and standardizing errors - so your code works consistently regardless of which provider handles the request.

> [!TIP]
>
> **Upscaling uses this endpoint too.** To upscale an image, call this endpoint with an upscale model and a `scale_factor` instead of a `prompt`. See [Image upscaling](https://docs.lumenfall.ai/use-cases/image-upscaling.md) for the full guide and model list.

> [!NOTE]
>
> **Record & Replay:** this endpoint supports replaying recorded responses and instant mock responses. Set `X-Lumenfall-Replay` (and optionally `X-Lumenfall-Replay-Match`) to record, replay, or mock a call. See the [Record & Replay guide](https://docs.lumenfall.ai/replay.md).

## Request body

> [!NOTE]
>
> You can include additional parameters not listed here. They will be passed through to the underlying provider.

> [accordion] What do the parameter badges mean?
>
> Each parameter has a badge showing how Lumenfall handles it across different providers:
>
> | Badge | Meaning |
> | - | - |
> | Passthrough | Passed as-is; some providers may ignore it |
> | Renamed | Field name is mapped to the provider's expected name |
> | Converted | Value is transformed to match each provider's format |
> | Emulated | Works consistently on all models, even if the provider doesn't natively support it |
>
> Learn more about [unified model behavior](https://docs.lumenfall.ai/unified-model-behavior.md#parameter-support).

**image** `file or array` *required*

The image(s) to edit. Must be a supported image file (PNG, WebP, or JPG) or an array of images. Maximum file size varies by model.

Renamed

**prompt** `string` *required*

A text description of the desired edit. Maximum length varies by model. Not required when using an [upscale model](https://docs.lumenfall.ai/use-cases/image-upscaling.md) - pass `scale_factor` instead.

Renamed

**model** `string` *required*

The model to use for image editing. See [Models](https://docs.lumenfall.ai/models.md).

**mask** `file`

An image whose fully transparent areas (where alpha is zero) indicate where the image should be edited. Must be a valid PNG file with the same dimensions as the source image.

Passthrough

**n** `integer` (default: 1)

The number of images to generate. Must be between 1 and 10. Some models only support `n=1`.

Emulated

**size** `string` (default: 1024x1024)

The size of the generated images. Supported sizes vary by model:

* `256x256`
* `512x512`
* `1024x1024`
* `1024x1536` (portrait)
* `1536x1024` (landscape)

Converted

**quality** `string` (default: auto)

The quality of the image. Options vary by model: `auto`, `low`, `medium`, `high`, `standard`, `hd`.

Passthrough

**response\_format** `string` (default: url)

The format of the generated images. Options:

* `url` — Returns a URL to the generated image
* `b64_json` — Returns the image as base64-encoded JSON

Emulated

**output\_format** `string` (default: png)

The image file format to generate. Lumenfall supports more formats than OpenAI:

* `png` Lossless compression, supports transparency
* `jpeg` — Lossy compression, smaller file size
* `gif` — Supports animation and transparency
* `webp` — Modern format with good compression
* `avif` — Best compression, modern browsers only (Limited to 1,600px on the longest side. Larger images will fall back to the original format.)

If the provider returns a different format, Lumenfall automatically converts the image.

Emulated

**output\_compression** `integer` (default: 100)

Compression quality for lossy formats (`jpeg`, `webp`, `avif`). Range: 1-100, where 100 is highest quality.

Emulated

**scale\_factor** `number`

Used only when calling an [upscale model](https://docs.lumenfall.ai/use-cases/image-upscaling.md). Multiplies the input dimensions on each axis (e.g., `2` doubles width and height). Supported values vary by model. When omitted, each upscale model uses its default. Ignored by non-upscale models.

Renamed

**thinking** `string`

Controls the model's internal reasoning effort. Options:

* `off` — no extra reasoning
* `on` — enable reasoning at the level the model treats as sensible
* `minimal` — light reasoning
* `high` — maximum reasoning

Supported values vary by model. Each model advertises the exact set it accepts as the parameter's `enum` in its [model schema](https://docs.lumenfall.ai/api-reference/models/get.md) (`/openai/v1/models?schema=true`) - a model with simple on/off support advertises `["off", "on"]`, while a model with graded levels advertises `["off", "on", "minimal", "high"]`. Sending a value the chosen model does not support returns a `400` listing the supported set. `thinking_level` is accepted as an alias. Omit to use the model's default.

Converted

**prompt\_enhancement** `string`

Whether an LLM rewrites and expands your prompt before generation. Options: `on`, `off`. When enabled and the provider returns the rewritten prompt, it appears in the response as `revised_prompt`. If the routed model does not support enhancement, the parameter is ignored. Omit to use the model's default.

Converted

**user** `string`

A unique identifier representing your end-user. Only used by some providers.

Passthrough

## Query parameters

**dryRun** `boolean` (default: false)

If `true`, returns a cost estimate without editing the image. See [Cost estimation](https://docs.lumenfall.ai/api-reference/cost-estimation.md).

## Response

**created** `integer`

Unix timestamp of when the request was created.

**size** `string`

Actual output dimensions as `"WIDTHxHEIGHT"` (e.g., `"1024x1024"`). Extracted from the generated image. May differ from the requested `size` if the model produced a different resolution.

**data** `array`

Array of generated image objects.

**Image object**

**url** `string`

URL of the generated image. Only present if `response_format` is `url`.

**b64\_json** `string`

Base64-encoded image data. Only present if `response_format` is `b64_json`.

**revised\_prompt** `string`

The prompt that was used to generate the image, if the model revised the original prompt.

**metadata** `object`

Metadata about the request execution, including effective cost. See [Billing](https://docs.lumenfall.ai/billing.md#effective-cost-on-responses).

**Metadata object**

**provider\_name** `string`

Provider display name (e.g., `"Google Vertex AI"`).

**provider** `string`

Provider slug (e.g., `"vertex"`).

**upstream\_id** `string`

The provider's request ID, useful for reconciliation.

**model** `string`

The model string sent in the request.

**executed\_model** `string`

The model that was actually executed, as `"{provider_slug}/{provider_model}"`.

**cost** `number`

Effective cost in the currency specified by `cost_currency`.

**cost\_currency** `string`

Currency of the cost (e.g., `"USD"`).

## Headers

Optional headers that enable [Record & Replay](https://docs.lumenfall.ai/replay.md). See the [guide](https://docs.lumenfall.ai/replay.md) and [Modes & matching](https://docs.lumenfall.ai/replay/modes.md) for the full behavior matrix, response signals, and error codes.

**X-Lumenfall-Replay** `string`

Activation: `record`, `replay-or-mock`, `replay-or-error`, `replay-or-live`, `replay-or-record`, `mock`, or `off`. Omit (with no key default) to run normally.

**X-Lumenfall-Replay-Match** `string` (default: standard)

How recordings are matched: `standard`, `strict`, `specific`, or `pinned`.

**X-Lumenfall-Replay-Fields** `string`

Comma-separated fields to match on. Required for `specific`.

**X-Lumenfall-Replay-Recording** `string`

Recording ID to replay. Required for `pinned`.

**X-Lumenfall-Replay-Latency** `string` (default: instant)

Latency simulation: `instant`, `real`, or `{ttfb},{duration}` in ms.

```bash cURL theme={null}
curl https://api.lumenfall.ai/openai/v1/images/edits \
  -H "Authorization: Bearer $LUMENFALL_API_KEY" \
  -F "model=gemini-3-pro-image" \
  -F "image=@original.png" \
  -F "prompt=Add a red hat to the person" \
  -F "size=1024x1024"
```

```python Python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="your-lumenfall-api-key",
    base_url="https://api.lumenfall.ai/openai/v1"
)

response = client.images.edit(
    model="gemini-3-pro-image",
    image=open("original.png", "rb"),
    prompt="Add a red hat to the person",
    size="1024x1024"
)

print(response.data[0].url)
```

```typescript TypeScript theme={null}
import OpenAI from "openai";
import fs from "fs";

const client = new OpenAI({
  apiKey: "your-lumenfall-api-key",
  baseURL: "https://api.lumenfall.ai/openai/v1",
});

const response = await client.images.edit({
  model: "gemini-3-pro-image",
  image: fs.createReadStream("original.png"),
  prompt: "Add a red hat to the person",
  size: "1024x1024",
});

console.log(response.data[0].url);
```

```bash cURL (multiple images) theme={null}
curl https://api.lumenfall.ai/openai/v1/images/edits \
  -H "Authorization: Bearer $LUMENFALL_API_KEY" \
  -F "model=gemini-3-pro-image" \
  -F "image[]=@lotion.png" \
  -F "image[]=@candle.png" \
  -F "image[]=@soap.png" \
  -F "prompt=Create a gift basket with these items"
```

```python Python (multiple images) theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="your-lumenfall-api-key",
    base_url="https://api.lumenfall.ai/openai/v1"
)

response = client.images.edit(
    model="gemini-3-pro-image",
    image=[
        open("lotion.png", "rb"),
        open("candle.png", "rb"),
        open("soap.png", "rb"),
    ],
    prompt="Create a gift basket with these items"
)

print(response.data[0].url)
```

```typescript TypeScript (multiple images) theme={null}
import OpenAI from "openai";
import fs from "fs";

const client = new OpenAI({
  apiKey: "your-lumenfall-api-key",
  baseURL: "https://api.lumenfall.ai/openai/v1",
});

const response = await client.images.edit({
  model: "gemini-3-pro-image",
  image: [
    fs.createReadStream("lotion.png"),
    fs.createReadStream("candle.png"),
    fs.createReadStream("soap.png"),
  ],
  prompt: "Create a gift basket with these items",
});

console.log(response.data[0].url);
```

```json Response theme={null}
{
  "created": 1702345678,
  "size": "1024x1024",
  "data": [
    {
      "url": "https://media.lumenfall.ai/abc123.png",
      "revised_prompt": "Add a stylish red fedora hat to the person in the image"
    }
  ],
  "metadata": {
    "model": "gemini-3-pro-image",
    "executed_model": "vertex/gemini-3-pro-image",
    "provider": "vertex",
    "provider_name": "Google Vertex AI",
    "cost": 0.04,
    "cost_currency": "USD"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.