DALL-E Integration with Mendix

This blog is a guide for anyone who wants to integrate DALL-E 2 in Mendix.

Rasagnya Dilip
Mendix Community
Published in
4 min readJun 15, 2023

--

DALL-E Integration with Mendix Banner Image

What is DALL-E 2?

DALL-E is a neural network-based image generator developed by OpenAI that can generate high-quality images from textual descriptions. It is an extension of the GPT-3 language model and uses a combination of computer vision and natural language processing techniques to understand textual input and generate corresponding images.

The name “DALL-E” is a combination of the famous artist Salvador Dali and the fictional character WALL-E, who is known for his creative and inventive nature. The name reflects the idea that DALL-E is a creative tool that can generate unique and imaginative images based on textual input.

DALL-E Architecture

Where is DALL-E 2 widely used?

DALL-E has significant potential in various fields, including design, advertising, and entertainment. It can help designers visualize their ideas and create mock-ups quickly and easily. It can also be used in advertising to generate custom images based on input from customers or campaign managers. In the entertainment industry, it can be used to create unique and imaginative creatures, objects, and scenes for movies, TV shows, and video games.

Steps to Set up Your Own OpenAI Account

Step 1. Go to the OpenAI website and sign up for an account: https://openai.com/

Step 2. After the account creation, login to your OpenAI account.

Step 3. In the top right corner of the screen, click on your account name and then select “View API Keys” from the drop-down menu.

Step 4. The API key will be displayed on the screen. Make sure to copy the key and store it in a secure location, as it will not be shown again.

Generate Secret Key by clicking on create new secret key

How to find API Endpoints?

Refer ‘https://platform.openai.com/docs/api-reference/images’ this guide covers the basics of using API endpoints with useful code samples

Mendix Implementation

Step 1.

  • Add an input field and “Generate” button as below to your page
  • Text or prompt (String) is the text describing the image to be generated in plain English
  • N is the number of images to be generated, e.g. n = 1 generates just one image
  • Size (String) can either be 256x256, 512x512, or 1024x1024
  • Generate button
Required Input Fields

Step 2.

In the generate button, call a microflow, then drag a Call REST activity, and configure it as shown below.

Call REST Service

Step 3.

Add required HTTP Headers.

Required Headers

Step 4.

Create a new JSON structure and import mapping.

Here is the OpenAI Documentation for this Request:

  • JSON Structure for Image Generation
{
"created":1589478378,
"data":[
{
"url":"https://..."
}
]
}
JSON Structure
  • Import Mapping for Image Generator
Import Mapping

Step 5.

Request Body

{
"prompt":"A pink 3d elephant in a dense forest with various animals and flowers",
"n":1,
"size":"512x512",
"response_format":"url"
}

Step 6.

Now use the import mapping in the Call REST activity.

Response Handling

Step 7.

Configure the list view as below to see the response

Overview page configuration

Step 8.

Provide Input as per your requirement and click on generate. Below is a sample

Input Page

Finally, the outcome will look like this 😱

AI Response

I hope this blog has ignited your curiosity, and inspired you to learn more about DALL-E 2 and OpenAI.

Feel free to leave any questions or feedback in the comments. Thank you!

Read more

From the Publisher -

Inspired by this article to bring your ideas to life with Mendix? Sign up for a free account! You’ll get instant access to the Mendix Academy, where you can start building your skills.

For more articles like this one, visit our Medium page. And you can find a wealth of instructional videos on our community YouTube page.

Speaking of our community, join us in our Slack community channel. We’d love to hear your ideas and insights!

--

--