> For the complete documentation index, see [llms.txt](https://docs.xenioo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xenioo.com/actions-and-operations/ai/ai-image-generation.md).

# AI Image Generation

This action will send a text prompt to an image-generation AI model and store the URL of the resulting image in a conversation variable, ready to be displayed in the chat.

<figure><img src="https://2532694803-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvGYwUmVjfELEiJzfmWLC%2Fuploads%2Fw34ncqO2bwoSabCBGavr%2Fimage.png?alt=media&amp;token=8887529f-ba7b-43c1-886f-657da935dfb2" alt=""><figcaption></figcaption></figure>

#### Settings

The action uses the following settings:

| Setting                | Description                                                                                                            | Parsed               |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------- |
| Prompt                 | The description of the image the AI should generate                                                                    | :white\_check\_mark: |
| Use AI module settings | If enabled, the request uses the provider and API key configured in the AI module settings                             | :no\_entry:          |
| AI Provider            | The AI provider to use for this request. Only visible when Use AI module settings is disabled                          | :no\_entry:          |
| Model Version          | The image model of the selected provider to use for this request. Only visible when Use AI module settings is disabled | :no\_entry:          |
| API Key                | The API key used to authenticate with the selected provider. Only visible when Use AI module settings is disabled      | :no\_entry:          |

#### Remarks

The generated image is saved in your account storage and **ai\_image\_generated** contains its public URL. Use the variable in an Image Action to display the image to the user.

The prompt can include any variable collected during the conversation, so each user can receive a personalized image. For example: *A watercolor postcard of {{city}} at sunset, with the text "Greetings from {{city}}".*

Only OpenAI and Gemini currently support image generation.

When Use AI module settings is enabled, Xenioo uses the provider and API key configured for your bot. Since the model configured in the AI module is a chat model, the first image model available for that provider is used automatically. If your bot uses a provider that does not support image generation, disable Use AI module settings and select a supported provider and model.

{% hint style="info" %}
Image generation is slower than text generation. Depending on the model and the complexity of the prompt it might take several seconds before the image is available. Consider sending a short message to the user before this action.
{% endhint %}

{% hint style="warning" %}
If the generation fails, for example because the prompt was rejected by the provider content policy, the trigger is still executed and **ai\_image\_generated** will be empty. The failure is reported in the conversation flow log. Check the variable before displaying the image.
{% endhint %}

#### Trigger

On Image Generated. This action will trigger any child operation as soon as the image is available.

#### Variables

This action produces the following variables after being triggered:

| Variable             | Description                                                    |
| -------------------- | -------------------------------------------------------------- |
| ai\_image\_generated | The URL of the generated image. Empty if the generation failed |

#### Availability

Channel specific availability follows the table below:

| Channel  | Availability     |
| -------- | ---------------- |
| Facebook | Fully Available. |
| WhatsApp | Fully Available. |
| Telegram | Fully Available. |
| Web      | Fully Available. |
