• Blog
  • Image generation capabilities with Delphi FMX Application via OpenAI API

Image generation capabilities with Delphi FMX Application via OpenAI API

DALL·E models

Publish date:
Discover more of what matters to you

Overview

Today there are a lot of different online services that allow users to generate images based on the provided text descriptions. These services rely on the capabilities of Artificial Intelligence (AI).

Specialized neural networks that are the foundation of such services enable the analysis of users’ textual information regarding the desired theme. And based on this info, they will generate the necessary image.

The range of possible themes is extremely wide. For example, a user’s input can contain just a couple of words “cat and mouse”.

As a result, a user will get an AI-generated image of a cat and a mouse. It’s important to mention that services can generate different images based on the same text description.

It is interesting that even by sending the same request to the server several times in a row, we can get different images. The location of objects in the image, their features, like size or color, etc. may differ.

In this article, we will talk about the capabilities of OpenAI DALL-E models in generating images based on the description provided by users in our Delphi FMX app by means of OpenAI API.

In our previously published blog post devoted to the text generation process, we demonstrated how to register and get a secret key (API key).

For request-based image generation, we will use OpenAI API (the Images tab).

OpenAI API

The OpenAI API offers extensive possibilities to developers for generating images. Here, we can configure the resolution of the generated image and specify the format in which we want to receive it.

We can receive images generated by request in the form of URL links or in the BASE64-encoded string format (b64_json).

Therefore, we will receive a JSON response from OpenAI containing either a URL link or a BASE64-encoded string with the image data. In this article, we will discuss how to obtain an image as a URL link and then proceed with downloading it.

We will also provide an example of receiving an image in the BASE64 format, decoding it, and displaying it in our Embarcadero Delphi FMX application.

We can specify the desired number of image variants generated by OpenAI (in our example, we will use one variant).

OpenAI Request Parameters

Get access to the article by completing your name and e-mail address.

This field is required
This field is required Invalid email address
By submitting data, I agree to the Privacy Policy
Tags

Subscribe to our newsletter and get amazing content right in your inbox.

You can unsubscribe from the newsletter at any time

This field is required
This field is required Invalid email address

You're almost there...

A confirmation was sent to your email

confirm your subscription, make sure to check
your promotions/spam folder