You can use the Retool AI resource to write queries that leverage AI models to generate images. The AI model returns a base64-encoded string of the image.
To get started with Image actions for apps, add a new AI Action query. For workflows, add a new AI Action block.
- Web and mobile apps
Generate an image
Use the Generate image action to generate an image based on the instructions you provide.
- Select the Generate image action.
- Enter some instructions in the Input field.
- Select the AI model to use, (e.g., dall-e-2).
- Click Save and then Run to perform the action.
The query output then displays a preview of the base64-encoded image that the AI model returns.
AI models typically generate
image/png images with a maximum resolution (e.g., 1024x1024px for dall-e-2). You can specify custom dimensions but they cannot exceed the maximum limit.