Overview
This node transforms images using the PiAPI GPT-4o Image Generation API. It takes an input image (either from a URL or binary data) and applies a text prompt to generate a transformed version of that image. The node supports different models, multiple input images, various aspect ratios, and artistic styles to customize the output.
Common scenarios include:
- Enhancing or modifying existing images based on descriptive prompts.
- Creating stylized versions of photos for social media or marketing.
- Generating variations of an image with different artistic influences.
- Automating image transformation workflows in creative projects.
For example, you could input a photo URL and a prompt like "turn this into a cyberpunk cityscape" and receive a transformed image styled accordingly.
Properties
| Name | Meaning |
|---|---|
| Model | The model used for image transformation. Options: "GPT-4o Image", "GPT-4o Image Preview (Legacy)" |
| Image Source | Source of the input image. Options: "URL", "Binary Data" |
| Multiple Images Input | Whether to use multiple images as input (only supported by "GPT-4o Image" model when source is URL). Boolean true/false |
| Additional Image URLs | Additional image URLs to include in the request (only shown if multiple images input is enabled and source is URL) |
| Image URL | URL of the image to transform (required if source is URL) |
| Binary Property | Name of the binary property containing the image data (required if source is binary data) |
| Prompt | Text prompt describing how to transform the image (required) |
| Aspect Ratio | Aspect ratio for the output image. Options include presets for square, landscape, portrait, or custom dimensions. Examples: "1024:1024" (square), "1280:720" (landscape 16:9), or "custom" to specify width and height manually |
| Custom Width | Custom width of the output image (shown only if aspect ratio is set to custom) |
| Custom Height | Custom height of the output image (shown only if aspect ratio is set to custom) |
| Image Style | Artistic style to apply to the generated image. Options include "None", "Anime", "Art", "Disney", "Furry", "MidJourney v6", "Realism", "Scenery", and many more specialized styles |
Output
The node outputs JSON objects with the following structure:
prompt: The original text prompt used for transformation.status: Status of the generation, either"completed"or"failed".- If successful:
source_image: The URL of the original source image.image_url: The URL of the transformed/generated image (may be null if unavailable).processed_content: Processed content extracted from the API response (likely includes metadata or additional info).original_response: The full raw response from the API.
- If failed:
error: An object containing:reason: Reason for failure.suggestion: Suggested fix or workaround.full_message: Full error message or response content.
original_response: The full raw response from the API.
If the node receives binary input, it converts it to a base64 data URL format before sending it to the API.
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/completionswith authentication. - Uses helper functions for streaming response processing and error extraction.
- Requires n8n environment configured with the appropriate API key credential.
Troubleshooting
Error: "The provided binary data is not an image"
Occurs if the binary input does not have an image MIME type. Ensure the binary data contains valid image data.Error: "No usable image data found in the provided binary property"
Happens if the specified binary property lacks usable data or URL. Verify the binary property name and that the data exists.API errors or failures
The node captures failure reasons and suggestions from the API response. Check theerrorfield in the output for details and adjust prompts or inputs accordingly.Multiple images input only supported by GPT-4o Image model
Using multiple images with other models will not work; ensure the correct model is selected.Custom aspect ratio requires valid width and height
When selecting custom aspect ratio, provide sensible numeric values for width and height.
Links and References
- PiAPI GPT-4o Image Generation API Documentation (hypothetical link)
- n8n documentation on Creating Custom Nodes
- General info on Image-to-Image AI Models