- Load and preview a source image
- Call the DALL·E variations endpoint
- Render the generated images
Prerequisites
- Python 3.6+
- Install the OpenAI Python library:
- Set your API key as an environment variable:
1. Import Modules and Configure the API Key
Begin by importing the necessary modules and loading your API key:2. Load and Display the Source Image
Use IPython’s display utilities to preview the original asset:3. Generate Three Variations
Call the DALL·E variation endpoint, specifying the image file, output size, and number of results:You can modify the
size or the n parameter to control the resolution and the number of variations returned.