OpenAI (DALL-E) inside Grasshopper with Python

Luciano Ambrosini
3 min readNov 9, 2022

--

Recently many Architects and Designers have been exploring different AI platforms — This is exciting!

Thanks to Open AI API documentation for DALL-E is it possible to integrate into Grasshopper our “prompts to image” process throughout my component “LA_OpenAI-GH” (I am going to update it in my Ambrosinus-Toolkit soon!) — WIP.

Useful premises

Then…

Generate a personal API key from your beta.openai.com account and save it in your window environment variables with this name: “OPENAI_API_KEY”

Required actions before running the components in Grasshopper

Each creation will take a small amount of your trial-granted credit (at the time I took the last screenshot I have generated more or less 100 images).

prompt-to-image usage

Don’t share your API key.

Below is the new component in action:

OpenAI (DALL-E) inside Grasshopper with Python
  • Now you can save your Open AI API key in the environment variables of Windows O.S. or give it as input as shown above (my demo key has been deleted this is just a demonstration ;) ) — After you have saved your API key into the environment variables of Windows, restart your Rhino for letting the component reads the key. If you don’t connect anything in the “APIkey” input, the components will read the key stored in your Windows O.S.;
Windows O.S. environment variables
  • When the toggle is in the “False state” the component read only the PNG files inside “Path” directory;
  • The component generates for each prompt a text file (.txt) where you can read the prompt that has generated a specific image See image below);
text file with used prompt
example with Grasshopper image sampler

A video demo here below

For extra info about downloading have a look at the bottom of this page

--

--

Luciano Ambrosini
Luciano Ambrosini

Written by Luciano Ambrosini

PhD | Architect | Computational + Environmental Designer

No responses yet