This AI API Makes Your App A “Fast Style” Artistic Genius

The AI API “Fast Style” is a form of graphical style transfer which uses a neural network to combine the artistic styles of one image with another to render a new unique image. You can think if it like taking a photograph and combining it with a Manet painting to produce a unique photo after the style of Manet.

To make art, we will use the help of a platform that you can use to make a lot of artificial intelligence projects. One of them is “fast style transfer”. We will connect with their API using Delphi.

REST and Delphi makes the API easy to use

Delphi has a tool called REST Debugger that makes it easy to connect with a REST API. After using it and successfully make the connection, you can copy the components into your Delphi application. Let’s dive into the DeepAi API and see how to build a desktop application to make art.

How to connect with DeepAi API?

DeepAi has good documentation around their API, which you can check here. First of all, you will need to make an account on and take your API key. You are gonna need it later.

DeepAi Fast Style API 1

From the Fast Style documentation, you can see that you will need to send three parameters to the API endpoint. Two links or files with images (where one is the image to render and the other, the style you want to apply), and your API key.

DeepAi Fast Style API Curl examples

How do I use Delphi to Connect with DeepAi API REST endpoints ?

First of all, let’s use the REST Debugger found in RAD Studio Delphi. The REST Debugger is a visual tool to connect with any API, make a call, and get a response. In your Delphi IDE,. To use it, in the IDE menu, go to Tools > REST Debugger.

DeepAi Fast Style API  in the Delphi REST debugger

Change the Method to POST and insert the API Endpoint ( ) in the URL field. Then, go to the Parameters Tab. To add the image links, click on the Add button. If you want to send a link directly from a web link, on Kind, select BODY. If you want to send a file of your hard drive, select FILE instead. In the name, write ‘content’ and put the link of the image in the value. For your style image, just change the name to ‘style’. Lastly, click on add again e now, select HEADER on Kind and, on name, write api-key and on value, put your API key value.

Sending a REST request to the DeepAI API

Sending a REST request to the DeepAi Fast Style API  with Delphi

Now, click on Send Request and after some time, you should receive a 200 response and, on Tabular Data Tab, you will see the output_url, with the link of the image that the artificial intelligence created:

DeepAi Fast Style API  REST response

Congrats, now you can send and get data from an Artificial Intelligence API and use it as you want.

How do I build a Windows desktop application to send and get images from the DeepAi API?

The application we are gonna build here will get the images from your computer, show and send them to the deepAi API. Also, it will show the image that the API returns and save it into the application folder. So, with a form already created, paste the components copied from the REST Debugger.

DeepAi Fast Style API  - required Delphi REST components

Right-click on the RESTRequest1 component and execute it. After right-clicking on the FDMemTable1 component, go to Fields Editor > Add All Fields. I added more components to make the app. Your form should look similar to this:

DeepAi Fast Style API  example Delphi form

Connecting a REST request with the API

Now, let’s go to the code. To connect with the API you can use:

To process the result and download the image, we created the GetImg procedure. There you can do something like this:

Here’s an example of the final DeepAI Fast Style API results from our Delphi app

DeepAi Fast Style API  Result

You can check all the code here: