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

# Generate and edit images with AI using Maxi AI Core

> Create and modify images via OpenAI, Replicate, and BFL — all sideloaded directly into your WordPress media library on a Pro plan.

Image generation and editing are Pro plan features that let your AI agent create and modify images without leaving the MCP session. Generated images are automatically sideloaded into your WordPress media library as attachment posts — you get back an attachment ID you can immediately use in content, featured images, or product galleries. Editing works by describing the change you want; for most providers you do not need to supply a mask.

<Note>
  Image generation and editing require a Pro license and an API key for at least one supported provider. Set your key via `maxi/update-ai-settings` — see [Managing AI provider credentials](/security/credentials) for instructions.
</Note>

## Supported providers

<CardGroup cols={2}>
  <Card title="OpenAI" icon="robot">
    Supports DALL-E 3 and gpt-image-1. The gpt-image-1 model adds transparent background support (real RGBA PNG output) and maskless instruction-based editing. **Default provider for image editing** because it is the only provider that combines maskless editing with real alpha transparency in a single call.
  </Card>

  <Card title="Replicate" icon="rotate">
    Supports Flux models, including `flux-fill-pro` for precision inpainting. Mask is required for Replicate editing calls.
  </Card>

  <Card title="BFL (Black Forest Labs)" icon="bolt">
    Direct API access to Flux Pro, Flux Kontext Pro, and Flux Fill Pro. Kontext Pro supports maskless editing; Flux Fill Pro requires a mask for inpainting.
  </Card>

  <Card title="Local" icon="server">
    Self-hosted models via a configurable endpoint. Set `local_endpoint` in `maxi/update-ai-settings`.
  </Card>
</CardGroup>

<Warning>
  OpenRouter does **not** support image generation or editing. Calls to image abilities with `"provider": "openrouter"` return `not_supported`.
</Warning>

## Generate an image

Call `maxi/generate-image-ai` to create a single image synchronously. The plugin generates the image, uploads it to your media library, and returns the attachment ID immediately.

<Tabs>
  <Tab title="Basic generation">
    ```json theme={null}
    {
      "prompt": "A clean product photo of a wooden desk with minimal decoration",
      "provider": "openai",
      "size": "1024x1024"
    }
    ```
  </Tab>

  <Tab title="Transparent background">
    Transparent backgrounds are supported by OpenAI's gpt-image-1 model only. The result is a real RGBA PNG — not a white-filled background.

    ```json theme={null}
    {
      "prompt": "A logo for a tech company, white background",
      "provider": "openai",
      "background": "transparent"
    }
    ```

    Valid `background` values: `transparent`, `opaque`, `auto`.
  </Tab>

  <Tab title="Reproducible seed">
    Pass a `seed` to make generation reproducible. Use the same seed and prompt to regenerate the same image.

    ```json theme={null}
    {
      "prompt": "Abstract geometric pattern in blue tones",
      "seed": 42
    }
    ```
  </Tab>
</Tabs>

The response includes the new attachment ID, which you can pass directly to `maxi/set-featured-image`, `maxi/update-product`, or any other ability that accepts an attachment ID.

## Edit an existing image

Call `maxi/edit-image-ai` to modify an image that already exists in your media library. Pass the attachment ID and describe the change you want in the prompt.

```json theme={null}
{
  "attachment_id": 456,
  "prompt": "Change the background to a sunset",
  "provider": "openai"
}
```

The edited image is sideloaded as a new attachment — your original image is not overwritten.

### Mask requirements by provider

Different providers have different requirements for inpainting masks:

| Provider / Model        | Mask required | Notes                                                                                       |
| ----------------------- | ------------- | ------------------------------------------------------------------------------------------- |
| OpenAI gpt-image-1      | No            | Describe the change in the prompt — the model applies it globally or infers the target area |
| BFL Flux Kontext Pro    | No            | Maskless instruction-based editing                                                          |
| BFL Flux Fill Pro       | Yes           | Precision inpainting — mask defines the area to fill                                        |
| Replicate flux-fill-pro | Yes           | Precision inpainting — mask defines the area to fill                                        |

### Remove a background

To remove an image background and produce a PNG with a transparent alpha channel, use the OpenAI provider with `"background": "transparent"`:

```json theme={null}
{
  "attachment_id": 456,
  "prompt": "Remove the background",
  "provider": "openai",
  "background": "transparent"
}
```

<Tip>
  OpenAI is the default provider for `maxi/edit-image-ai` because it is the only provider that supports both maskless instruction-based editing and real alpha transparency in a single call. You can change the default via `maxi/update-ai-settings` using the `provider_edit_image` field.
</Tip>

## Batch image generation

To generate multiple images in the background, use `maxi/generate-image-ai-batch`. This returns a job ID immediately and processes images via WP Cron. See [Batch AI processing](/abilities/ai-batch) for the full workflow.

## Related abilities

<CardGroup cols={2}>
  <Card title="Batch image generation" icon="layer-group" href="/abilities/ai-batch">
    Generate many images in the background without waiting for each one. Results are sideloaded into the media library as each job item completes.
  </Card>

  <Card title="Text generation" icon="pen-to-square" href="/abilities/ai-text">
    Generate product descriptions, page content, and other text synchronously via OpenAI, Anthropic, OpenRouter, and local providers.
  </Card>

  <Card title="Media abilities" icon="images" href="/abilities/media">
    Upload, attach, detach, and manage media attachments — including regenerating image thumbnails after replacement.
  </Card>

  <Card title="Managing credentials" icon="key" href="/security/credentials">
    Set API keys for OpenAI, Replicate, and BFL. Keys are encrypted at rest and validated before replacing existing ones.
  </Card>
</CardGroup>
