Experiments with GPT

The past few weeks I’ve been drawn to experiment with GPT, asking it to help write or revise poems, songs, and code, talk about physics, etc. Yesterday, I decided to make a little app to make images using GPT. Below is one image, created by asking “make an abstract painting mixing the styles of Braque and Klee; use blues, reds, a little orange and warm grays.”

Below is another, generated by asking GPT to “make an abstract painting blending the styles of Braque and Signac. Use mostly pastel colors but some with strong values.”

GPT prompt: .

Writing the app turned out to be surprisingly easy. OpenAI, the company behind ChatGPT, has very good documentation. Browsing it, I found an explanation of how to generate images. Here is the key piece of code, a shell script:

url https://api.openai.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "prompt": "A cute baby sea otter",
    "n": 2,
    "size": "1024x1024"

I signed up for an API key, tried out the shell script, then started building the app. Below is a screenshot of the first version, which you can find at gpt-lab.lamdera.app. It is written in Elm, a pure functional language, ursing choonkeat’s Elm library for working with OpenAI’s API.

Because the API keys need to be kept secret, the code is not, alas, open source. In any case, I am planning some significant upgrades in the next week or so, e.g. a way to save generated images that you like. After an initial test period, there will be a paid plan that you can sign up for if you find it is useful. Usage fees will be very, very modest.

PS. I’ve used the app mostly for generating abstract art. But of course you can prompt it to create any kind of image. Here is one such example:

Here is one more image, with a fairly long prompt:

Prompt for the above: An abstract composition with one large shape, two medium-sized shapes, and a few smaller ones. Make it two-dimensional. Add a network of lines. The background should be reminiscent of Australian aboriginal paintings. Keep the colors only partially saturated, with lots of grays and earth tones.

Remark. In its current incarnation, the app generates 10 images per prompt. My experience is that one has to look through at least that many images on average to find one that has satisfying esthetics. The other knob to turn, of course, is tuning the prompt itself, using it to guide GPT in the direction you want to go (and discovering or at least refining that direction as you proceed).