
Member-only story
ChatGPT Completions API and Image Generation
ChatGPT’s API, powered by OpenAI, offers developers access to advanced natural language processing and generation capabilities. It enables the integration of ChatGPT’s conversational AI into various applications, websites, and digital products.
In this article, we will integrate ChatGPT in several use cases. From how to set up and configure the connection, to implementing the completions API with chat history, and finally, image generation using the Dall-e-3 model. Let's get started by learning how to configure the connection.
Configuration:
Go to https://platform.openai.com/api-keys to create an API key for integration. This is the API-keys overview in OpenAI’s platform (https://chat.openai.com/), we are going to build an overview in Mendix to store this information to be used in our requests.

In some APIs we need to use organization ID, you can find it at https://platform.openai.com/account/organization

In Mendix, create one entity for storing the token. To make the article easy to understand, I will not validate the token by checking if it exists, and we won't encrypt and decrypt it every time we use it (but you should do this if possible).
Right-click on the Configuration Entity and select “Generate overview pages”. It will quickly generate an overview and new_edit forms.

Put this overview form onto the navigation.
Then you will have a page that looks like this.