Integrating OpenAI with Mendix via OpenAI’s REST API enables us to create apps that quickly evaluate user questions and produce output that is similar to it.

OpenAI REST API for Mendix

OpenAI REST API for Mendix

For instance, if you have any doubts while coding in any programming languages like C, C++, Java, or JavaScript, the exact output with syntax can be provided by OpenAI based on a query entered by the user. The OpenAI platform has other uses besides code completion though.

In my use case, I have to send a Project Delay Letter to the client, but I don’t have the time to type the content. In this case, OpenAI’s completion API is beneficial. All you have to do is enter the subject: “Project Delay letter to client” as a query. It will return text that you can edit and use as a template for the letter as an Output. You could then send it to the client by using the email module with templates or the Email Connector module.

OpenAI Playground

What is OpenAI?

OpenAI is an organization founded in 2015 that creates and conducts research on friendly artificial intelligence (AI) that generally benefits all of humanity.

Since its creation, OpenAI has created several AI powered tools such as ChatGPT (Complex Language Processing), Codex(Natural Speech to Code), and DALL·E (Image Generation).

Mendix OpenAI Integration

Integrating OpenAI’s completion API in Mendix

Implementing OpenAI’s API with Mendix takes around five minutes.

You will need an account on OpenAI in order to access the API. Create the OpenAI account here and generate the API key for authorization.

After creating an account click on settings, then click the view API keys to find your key
API key Generation

Next, we need to create the domain model. As the completion API only expects a single query and returns the response, we only need two fields on our entity and then we can generate the overview pages for the requests.

After creating the domain model and generating the overview pages, we need to make the JSON structure for the data mapping.

Click anywhere in or on the module and select Add other →JSON structure

JSON Snippet Code

Paste it in the JSON snippet and click format →Expand all → Refresh and click OK to complete.

JSON Structure Import Mapping

After creating the JSON structure right-click on the module and Select Add other →Import mapping

Then we need to create a new microflow to call the API from our app.

Below you can see an example of my implementation:

API Microflow Integration

Add this microflow to the SUBMIT button to get the response.

Call Rest Service Activity Configuration


Content-Type: “application/json”

Authorization: “Bearer sk-YfkyhiTMudra40*********yhjsnm,”




You can input a query on the OpenAI overview page, and when you click the submit button, the REST API analyses the query, and returns an answer with a string that you can use as a template for emails.

OpenAI Output in Mendix

I’ll include a few screenshots that show coding and a letter.

I hope this article helped you to understand how to use OpenAI in Mendix using OpenAI’s REST API.

Additionally, you can configure the Email Template Module to send emails.

This blog has been published in Mendix Medium. Click the below link to view it:

Thank you for reading this!

This blog has been published in Mendix Medium. Click the below link to view it:

OpenAI REST API in Mendix. Integrating OpenAI with Mendix via… | by Raffel | Mendix Community | Feb, 2023 | Medium