Contact Us 1-800-596-4880

Configuring Image Generation Operations

Configure the Image Read Operation

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

To configure the Image read operation:

  1. Select the operation on the Anypoint Code Builder or Studio canvas.

  2. In the General properties tab for the operation, enter these values:

    • Data

      Contains the prompt for the operation.

    • ContextUrl

      Contains the URL to the image file to read.

This is the XML configuration for this operation:

<ms-aichain:image-read
  doc:name="Image read"
  doc:id="16cac2ce-def9-41e2-aaff-0f9c33d622f1"
  config-ref="MuleSoft_AI_Chain_Config"
  contextURL="#[payload.imageUrl]">
  <ms-aichain:data><![CDATA[#[payload.prompt]]]></ms-aichain:data>
</ms-aichain:image-read>

Output Configuration

This operation responds with a JSON payload containing the main LLM response. Additionally, attributes such as token usage are included as part of the metadata (attributes), but not within the main payload.

This is an example response of the JSON payload:

{
  "response": "The image depicts a group of men in what appears to be a stadium or arena setting. They are standing in the stands, with some looking agitated or engaged in a discussion."
}

Along with the JSON payload, the operation also returns attributes, which include information about token usage, for example:

{
  "attributes": {
      "tokenUsage": {
          "outputCount": 87,
          "totalCount": 187,
          "inputCount": 100
      },
      "additionalAttributes": {}
  }
}

Configure the Image Generate Operation

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.

To configure the Image generate operation:

  1. Select the operation on the Studio canvas.

  2. In the General properties section, configure the Data field with the prompt for generating the image, for example, payload.prompt.

This is the XML configuration for this operation:

<ms-aichain:image-generate
  doc:name="Image generate"
  doc:id="a057ad09-533f-42e9-bfd6-00014db6cec8"
  config-ref="MuleSoft_AI_Chain_Config">
  <ms-aichain:data><![CDATA[#[payload.prompt]]]></ms-aichain:data>
</ms-aichain:image-generate>

Output Configuration

This operation responds with a JSON payload containing the URL of the generated image, for example:

{
  "response": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-dP8odnP25FlwTi1fOMr1X7vO/user-Jyi0vNlYu4mjEBZl9Mu1lXBW/img-bEO12CWIRI7CkGUjfz5ajAlS.png"
}
View on GitHub