Overview
This node generates images from text prompts using the PiAPI GPT-4o Image Generation API. It is designed to transform descriptive text into visual content, supporting various image styles and aspect ratios. This node is useful for creative projects, marketing materials, concept art, or any scenario where quick generation of images based on textual descriptions is needed.
For example, a user can input a prompt like "A futuristic cityscape at sunset" and receive an AI-generated image matching that description. The node supports different models and styles, allowing customization of the output's artistic appearance.
Properties
| Name | Meaning |
|---|---|
| Model | The model used for image generation. Options: "GPT-4o Image", "GPT-4o Image Preview (Legacy)". |
| Prompt | Text prompt describing the desired image content. This is required. |
| Aspect Ratio | Aspect ratio of the generated image. Options include square (1:1), landscape (16:9, 3:2, 4:3, 21:9), portrait (9:16, 2:3, 3:4, 4:5), or custom dimensions. Headers like "-- Square --" are non-selectable group labels. |
| Custom Width | Width in pixels for the image when "Custom" aspect ratio is selected. Default is 1024. |
| Custom Height | Height in pixels for the image when "Custom" aspect ratio is selected. Default is 1024. |
| Image Style | Artistic style applied to the generated image via LoRA models. Options include None, Anime, Art, Disney, Furry, MidJourney v6, Realism, Scenery, Collage Art Style, Creepycute, Cyberpunk Anime, Deco Pulse, Deep Sea Particle, Faetastic Details, Fractal Geometry, Galactixy Illustrations, Geometric Woman, Graphic Portrait, Mat Miller Art, Moebius Style, OB3D Isometric Room, Paper Quilling. |
Output
The node outputs an array of JSON objects, each representing one generated image result with the following structure:
prompt: The original text prompt used for generation.status: Either"completed"if generation succeeded or"failed"if it did not.- If failed:
error: An object containing:reason: Reason for failure.suggestion: Suggested action or fix.full_message: Full error message returned by the API.
original_response: Raw response from the API.
- If successful:
image_url: URL string pointing to the generated image.processed_content: Processed content extracted from the streamed API response.original_response: Raw response from the API.
No binary data is output directly; instead, the image is accessible via the returned URL.
Dependencies
- Requires an API key credential for the PiAPI GPT-4o Image Generation API.
- The node makes HTTP POST requests to
https://api.piapi.ai/v1/chat/completions. - Uses streaming response processing utilities imported from shared helper functions.
- Requires proper configuration of the API key credential within n8n.
Troubleshooting
- Common issues:
- Invalid or missing API key will cause authentication failures.
- Incorrect prompt formatting or unsupported model selection may lead to generation failure.
- Selecting custom aspect ratio without specifying valid width and height could cause unexpected results.
- Error messages:
- The node returns detailed error information including reason and suggestions when generation fails.
- Network or API errors will be surfaced as exceptions unless "Continue On Fail" is enabled.
- Resolutions:
- Verify the API key is correctly set and has necessary permissions.
- Ensure prompt text is meaningful and not empty.
- Use supported aspect ratios or provide valid custom dimensions.
- Enable "Continue On Fail" to handle errors gracefully in workflows.
Links and References
- PiAPI Official Website
- PiAPI GPT-4o Image Generation API Documentation
- n8n Documentation on Creating Custom Nodes