[Image] Generate

The Image generate operation generates an image based on a prompt sent to the LLM. Currently, MuleSoft AI Chain connector supports only OpenAI Image Models.

Image Generate

Input Fields

Module Configuration

This refers to the MuleSoft AI Chain LLM Configuration set up in the Getting Started section.

General Operation Fields

  • Data: Contains the prompt for the operation.

XML Configuration

Below is the XML configuration for this operation:

<ms-aichain:image-generate 
  doc:name="Image generate" 
  doc:id="a5ae05e2-3cbb-4b89-b3e1-07030a3649b8" 
  config-ref="MAC_AI_Llm_configuration" 
  data="#[payload.prompt]"
/>

Output Field for v0.2.0

This operation responds with a string payload which needs to be converted into a json, this can be achieved with a Transform Message component with the following dataweave expression:

%dw 2.0
output application/json
---
read(payload,"application/json").

Output Field

This operation responds with a json payload.

Once converted into JSON, you can use the following dataweave expression to extract the generated images URL.

Image Generate

The image URL can be extracted with the following DataWeave expression:

%dw 2.0
output application/json
---
{ imageURL: payload.response as String }

Example Use Cases

This operation is particularly useful in scenarios where you need to generate an image based on a plain text prompt, such as:

  • Marketing and Advertising: Creating visuals for campaigns based on specific descriptions.
  • Content Creation: Generating images for blog posts, articles, or social media based on given prompts.
  • Prototyping and Design: Quickly generating concept images from textual descriptions.

[Image] Read

The Image read operation read an image based on a prompt. Currently, MuleSoft AI Chain connector supports only OpenAI Image Models.

Image Generate

Input Fields

Module Configuration

This refers to the MuleSoft AI Chain LLM Configuration set up in the Getting Started section.

General Operation Fields

  • Data: Contains the prompt for the operation.
  • ContextUrl: Contains the url to the image file.

XML Configuration

Below is the XML configuration for this operation:

<ms-aichain:image-read 
doc:name="Image read" 
doc:id="a6a11fd7-6f48-4063-820c-1d9d488dd033" 
config-ref="OPENAI-GPT4-TURBO" data="#[payload.prompt]" 
contextURL="#[payload.imageUrl]" />

Output Field for v0.2.0

This operation responds with a string payload which needs to be converted into a json, this can be achieved with a Transform Message component with the following dataweave expression:

%dw 2.0
output application/json
---
read(payload,"application/json").

Output Field

This operation responds with a json payload.

Image Generate
{
    "response": "I see a group of eight people who appear to be posing for a photo together. They are all smiling and seem to be happy. The group includes both men and women, and they are arranged closely together, suggesting a sense of camaraderie or friendship. The background is not very clear, but the focus is on the people in the foreground.",
    "tokenUsage": {
        "outputCount": 69,
        "totalCount": 166,
        "inputCount": 97
    }
}