> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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: userInput | type: string | description: Text prompt describing the image to generate. | required: true | validation: maxLength 3000
   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
 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-managed)
Self-managed 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);
};
```

---