Midjourney produces great results, we admit that. However, when it comes to automation, wrestling with a Discord bot or dealing with unofficial APIs can quickly turn into a nightmare. If you want to build a scalable system that runs on your own server and generates images by simply sending a prompt, you are in the right place.
In this guide, we will explain how to set up your own image production pipeline by combining the n8n automation tool with Fal.ai, a service that utilizes Google's imaging technologies.
- Requirements: n8n (Cloud or Self-hosted), Fal.ai account
- Cost: $0.15 per image (Fees double for 4K outputs)
- Difficulty: Medium (Involves HTTP Requests and JSON logic)
- Estimated Time: 15 Minutes
Why Fal.ai and n8n Instead of Midjourney?
As a developer or automation enthusiast, you do not want to click buttons manually. Midjourney's closed ecosystem makes scaling projects impossible. Fal.ai, on the other hand, allows you to use AI models as an API. This means you can talk to the server using code or "low-code" tools like n8n.
The system we will build here will not work on a "Fire and Forget" basis, but rather on a Polling logic. Since generating a high-quality image takes time, we will teach n8n to "go, wait until the process is finished, and bring back the result."
Preparation: API Key and Balance Settings
Our first stop is the Fal.ai platform. Once you create your account, you will see that the system operates on a "Pay-as-you-go" model.
In current pricing, a standard image generation request costs you approximately 0.15 dollars. This means when you load 1 dollar into your account, you can run this model about 7 times. Keep in mind that if your project requires high details like 4K resolution, this unit cost will double. If your balance drops to negative, the API will stop responding, so it is beneficial to proceed with control during the testing phase.
Go to the Key section from your profile in the top right corner and create a new API key. Note this key down somewhere safe; we will use it shortly to identify ourselves to the server within n8n.
Step-by-Step Automation Setup
Open a blank n8n canvas. Our scenario is this: We will design a Cyberpunk game character and automate the entire process.
1. Trigger and Prompt Data
Add a Manual Trigger node to the canvas to start the flow. This allows us to test the system manually for now. Connect an Edit Fields node right next to it to organize the data.
Create a field named Prompt here and write your imagined scene in the value section. For example: A futuristic chimpanzee wearing neon sunglasses in a Cyberpunk laboratory.
This node will be our order ticket. Later on, you can automatically pull this prompt from a Google Form or a Slack message.

2. Sending the Order (POST Request)
This is the most critical part. Add an HTTP Request node to the canvas. Our goal is to send the data we have to the Fal.ai server and start the process.
- Method: Select POST (We are creating a new resource).
- URL: Enter the
submitaddress provided by Fal.ai for the model you are using (e.g., Nano Banana Pro or Flux). - Authentication: Open the Header section. Add a parameter named
Authorization. In the value section, typeKeyfollowed by a single space, and then paste your API key. If you forget that space, the server will not let you in.
In the Body section, we will use the JSON format expected by Fal.ai. Open the Expression mode and dynamically link the Prompt data you wrote in the previous step here. Also, specify the image size as 16:9 (YouTube cover standard) or 1:1 if you want a square.

3. Polling Mechanism: Is the Process Finished?
When you send the request, the server does not give you the image immediately. It gives you a request_id (tracking number) and says "Queued, wait." This is where n8n's Wait node comes into play.
Add a Wait node to the flow and tell it to wait for 5 seconds. This is to give the server some breathing room.
Then add a second HTTP Request node. The goal is to ask for the status:
- Method: GET
- URL: Add
/requests/{request_id}to the end of the URL you used in the first request. (The ID here will be the output from the first node). - Header: Add your Authorization key again.
This query can return two responses: IN_PROGRESS (Still working) or COMPLETED (Finished).

4. Setting up the Loop (If Node)
Add an If node for the system to make a smart decision. The rule is very simple:
- If the incoming response status is
COMPLETED-> Continue on the True path and get the image. - If the status is still
IN_PROGRESS-> Exit from the False path and go back to the Wait step.
Thus, the system will check the status every 5 seconds until the image is ready and will not end the flow without completion.
5. Result: Retrieving the Image
When the loop is completed and the COMPLETED response is received, you reach your final image with a final HTTP Request (or by directly using the url data in the JSON output).

In our tests, we achieved a result on the 4th attempt (approximately 20 seconds) with the "Neon glasses Cyberpunk chimpanzee" prompt in 16:9 format. We integrated Google's powerful models into our own workflow without writing any code, just by combining logical blocks.
You can use this structure to automate cover images for your blog posts or for social media content creation.
Comments (0)
Sign in to comment
Report