To run the code shown on this page, open the MLX file in MATLAB®: mlx-scripts/UsingDALLEToGenerateImages.mlx
This example shows how to generate images using the openAIImages
object.
To run this example, you need a valid OpenAI™ API key. Creating images using DALL-E may incur a fee.
loadenv(".env")
addpath('../..')
Create an openAIImages
object with ModelName
dall-e-3
.
mdl = openAIImages(ModelName="dall-e-3");
Generate and visualize an image. This model only supports the generation of one image per request.
images = generate(mdl,"A crispy fresh API key");
figure
imshow(images{1})
You can also define the style and quality of the image
images = generate(mdl,"A cat playing with yarn", Quality="hd", Style="natural");
figure
imshow(images{1})
Copyright 2024 The MathWorks, Inc.