EvonSys Mendix Community - Stay up to date for updates

Integrating DALL-E 2 into Mendix: Your Comprehensive Guide

Written by Rasagnya Dilip | May 11, 2023 12:49:07 PM

This blog is meant to guide anyone who is looking to integrate DALL-E 2 in Mendix

Are you a Mendix developer who have dreams of integrating DALL-E 2, just like WALL-E had his eyes set on EVE? Well, we're here to help you turn that dream into a reality! In this blog, we'll provide you with step-by-step instructions on how to seamlessly integrate DALL-E 2 with Mendix and start generating images in no time. So, let's get your development journey rolling, just like WALL-E's adventure with EVE!

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.

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 OpenAI Account

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

Step 2. After the account creation, log in 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.

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.

Implementation In Mendix:

Alright, let's now delve into the step-by-step process of implementing it in Mendix.

Step 1.

  • Add an input fields and Generate button as below to your page
  • Text or prompt (String) is the text describing the image to be generated in plain English
  • Number of images is the amount of images to be generated, e.g. Number of images = 1 generates just one image
  • Size (String) can either be 256x256, 512x512 or 1024x1024
  • Generate Button

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

Step 3. Add HTTP Headers required.

Step 4. Create a new JSON structure and import mapping

  • JSON structure for Image Generation

  • Import Mapping for Image Generator

Step 5. Request Body

Step 6. Now use the import mapping in the Call REST activity

Step 7. Configure list view as below to see response

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

Finally, the outcome will look like this 😱

DALL-E 2, OpenAI's picture generating AI model, is establishing a name for itself by producing breathtaking, high-quality images from text prompts. Mendix applications may now provide a more engaging user experience by generating bespoke images on the fly, avoiding the need for costly and time-consuming manual design effort.

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

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