> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/ai-in-umbraco/19.latest/management-api/image-generation/generate-image.md).

# Generate Images

Generate one or more images from a text prompt, with optional maskless edit.

{% hint style="warning" %}
Returns **404** when the `Umbraco:AI:Experimental:ImageGeneration` feature flag is disabled.
{% endhint %}

```http
POST /umbraco/ai/management/api/v1/image-generation/generate
```

## Request Body

{% code title="application/json" %}

```json
{
  "prompt": "A serene mountain landscape at dawn",
  "profileIdOrAlias": "marketing-images",
  "count": 1,
  "size": "1024x1024",
  "responseFormat": "data",
  "originalImages": [
    { "data": "<base64>", "mediaType": "image/png" }
  ]
}
```

{% endcode %}

| Property           | Type   | Required | Description                                                                                                                                                     |
| ------------------ | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `prompt`           | string | Yes      | The text prompt describing the desired image(s).                                                                                                                |
| `profileIdOrAlias` | string | No       | Profile ID or alias. Uses the default image-generation profile if omitted.                                                                                      |
| `count`            | int    | No       | Number of images to generate.                                                                                                                                   |
| `size`             | string | No       | Image size as `"{width}x{height}"` (for example, `"1024x1024"`).                                                                                                |
| `responseFormat`   | string | No       | How images are returned: `"url"` (a URI to the image), `"data"` (inline base64 data), or `"hosted"` (a hosted resource identifier to retrieve the image later). |
| `originalImages`   | array  | No       | Base64 images to edit (maskless edit). Each: `{ "data", "mediaType" }`. Masked outpainting is not exposed over REST.                                            |

## Response

{% code title="200 OK" %}

```json
{
  "images": [
    { "data": "<base64>", "url": null, "mediaType": "image/png" }
  ],
  "usage": {
    "inputTokens": 0,
    "outputTokens": 0,
    "totalTokens": 0
  }
}
```

{% endcode %}

| Property | Type   | Description                                                                         |
| -------- | ------ | ----------------------------------------------------------------------------------- |
| `images` | array  | Generated images. Each has `data` (base64) and/or `url`, plus `mediaType`.          |
| `usage`  | object | Optional token usage (`inputTokens`, `outputTokens`, `totalTokens`), when reported. |

## Status Codes

| Code | Meaning                                                          |
| ---- | ---------------------------------------------------------------- |
| 200  | Images generated.                                                |
| 400  | Invalid prompt, invalid base64 image data, or generation failed. |
| 404  | Feature flag disabled, or the profile was not found.             |

## Example

{% code title="cURL" %}

```bash
curl -X POST "https://your-site.com/umbraco/ai/management/api/v1/image-generation/generate" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "prompt": "A serene mountain landscape at dawn", "size": "1024x1024" }'
```

{% endcode %}

## Related

* [Image Generation API overview](/ai-in-umbraco/19.latest/management-api/image-generation.md)
* [Using the Image Generation API](/ai-in-umbraco/19.latest/using-the-api/image-generation.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/ai-in-umbraco/19.latest/management-api/image-generation/generate-image.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
