> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GenerateImage

# Package: socialMedia

# Namespace: GeneratedContentService

# Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/generated-content-v1/generate-image.md

## Permission Scopes:
Manage Social Posts: SCOPE.PROMOTE.MANAGE-SOCIAL-POSTS

## Introduction

Generates an image from a text prompt and a source image.

Image generation runs asynchronously. This method starts the process and returns an `executionId`. Poll Get Generated Image with that `executionId` until the status is `READY` (the `imageUrl` and `fileId` are then populated) or `FAILED`. The generated image is also added to the "Social Marketing AI Media" folder in the site's Media Manager.

---

## REST API

### Schema

```
 Method: generateImage
 Description: Generates an image from a text prompt and a source image.  Image generation runs asynchronously. This method starts the process and returns an `executionId`. Poll Get Generated Image with that `executionId` until the status is `READY` (the `imageUrl` and `fileId` are then populated) or `FAILED`. The generated image is also added to the "Social Marketing AI Media" folder in the site's Media Manager.
 URL: https://www.wixapis.com/social-publisher/v1/generate-image
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  userInput, imageUrl
 Method parameters: 
   param name: imageUrl | type: imageUrl | description: URL of the source image to generate from. | required: true | validation: format WEB_URL
   param name: userInput | type: userInput | description: Text prompt describing the image to generate. | required: true | validation: maxLength 3000
 Return type: GenerateImageResponse
  - name: status | type: GenerateMediaStatus | description: Status of the generation request.  
     - enum: UNKNOWN_STATUS, OK
  - name: executionId | type: string | description: Identifies the asynchronous image-generation process.  | validation: maxLength 1000


```

### Examples

### Generate an image from a prompt and a source image
Start generating an image from a text prompt and a source image. Generation is asynchronous; poll Get Generated Image with the returned executionId for the result.

```curl
curl -X POST \
'https://www.wixapis.com/social-publisher/v1/generate-image' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "userInput": "Add a bright summer-sale banner to the product photo",
  "imageUrl": "https://static.wixstatic.com/media/cf2434_source-product-photo.jpg"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.promoteGrowthToolsPublisher.generatedContent.generateImage(userInput, options)
 Description: Generates an image from a text prompt and a source image.  Image generation runs asynchronously. This method starts the process and returns an `executionId`. Poll Get Generated Image with that `executionId` until the status is `READY` (the `imageUrl` and `fileId` are then populated) or `FAILED`. The generated image is also added to the "Social Marketing AI Media" folder in the site's Media Manager.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  userInput, options.imageUrl, options
 Method parameters: 
   param name: options | type: GenerateImageOptions  none | required: true 
        - name: imageUrl | type: string | description: URL of the source image to generate from. | required: true | validation: format WEB_URL
   param name: userInput | type: string | description: Text prompt describing the image to generate. | required: true | validation: maxLength 3000
 Return type: PROMISE<GenerateImageResponse>
  - name: status | type: GenerateMediaStatus | description: Status of the generation request.  
     - enum: UNKNOWN_STATUS, OK
  - name: executionId | type: string | description: Identifies the asynchronous image-generation process.  | validation: maxLength 1000


```

### Examples

### Generate an image from a prompt and a source image
```javascript
import { generatedContent } from "@wix/promote-growth-tools-publisher";

const userInput = "Add a bright summer-sale banner to the product photo";

const options = {
  imageUrl: "https://static.wixstatic.com/media/cf2434_source-product-photo.jpg",
};

async function generateImage() {
  const response = await generatedContent.generateImage(userInput, options);
}

/* Promise resolves to:
 * {
 *   "status": "OK",
 *   "executionId": "b7c2f0a1-4e6d-4a8b-9c3f-2d5e1a7b0c94"
 * }
 */

```

### generateImage (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { generatedContent } from '@wix/promote-growth-tools-publisher';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { generatedContent },
  // Include the auth strategy and host as relevant
});


async function generateImage(userInput,options) {
  const response = await myWixClient.generatedContent.generateImage(userInput,options);
};
```

---