Actions7
Overview
This node allows you to generate images using the Azure OpenAI API, specifically via the "Image" resource and the "Generate" operation. It is designed for scenarios where you need to create AI-generated images based on a textual prompt. Common use cases include generating illustrations, concept art, or visual assets for marketing, prototyping, or creative projects directly within an n8n workflow.
Practical examples:
- Automatically creating product mockups from descriptions.
- Generating unique artwork for blog posts or social media.
- Producing visual content for presentations or reports based on user input.
Properties
Name | Meaning |
---|---|
API Version | The version of the Azure OpenAI API to use. Only option: 2023-06-01-preview . |
Prompt | A text description of the desired image(s). Maximum length is 1000 characters. |
No. of Images | The number of images to generate (between 1 and 5). |
Image Size | The size of the generated images. Options: 256x256 , 512x512 , 1024x1024 . |
Output
The output will be a JSON object containing the results of the image generation request. While the exact structure depends on the Azure OpenAI API response, it typically includes:
- operationId: An identifier for the image generation operation.
- status: The status of the request (e.g., succeeded, running).
- created: Timestamp of when the operation was created.
- result/data: URLs or data for the generated images (if the operation has completed).
Example output:
{
"operationId": "abc123",
"status": "succeeded",
"created": "2024-06-10T12:34:56Z",
"result": {
"images": [
{"url": "https://.../image1.png"},
{"url": "https://.../image2.png"}
]
}
}
If the operation is still running, the result may not contain image URLs yet.
Dependencies
- External Service: Requires access to the Azure OpenAI API with appropriate permissions for image generation.
- API Key/Credentials: You must configure the
yoovAzureOpenAIApi
credential in n8n, including the correct hostname and authentication details. - Environment Variables: None specified, but ensure your Azure credentials are set up in n8n.
Troubleshooting
Common issues:
- Invalid API Key or Hostname: If credentials are incorrect, you may receive authentication errors. Double-check your Azure OpenAI API key and endpoint.
- Prompt Too Long: If the prompt exceeds 1000 characters, the API will reject the request.
- Too Many Images Requested: Requesting more than 5 images will result in an error.
- Unsupported Image Size: Only the specified sizes (
256x256
,512x512
,1024x1024
) are allowed. - Operation Status Not Succeeded: If the output status is not "succeeded", the images may not be available yet. Poll the operation until completion.
Error messages:
"error": "Request failed with status code 401"
– Check your API credentials."error": "Prompt exceeds maximum length"
– Shorten your prompt."error": "Invalid image size"
– Use one of the supported sizes.