How to generate AI images in an n8n workflow

In n8n, call an image API with the HTTP Request node, then use the Convert to File node to turn the base64 image into a binary file you can upload, email or post. n8n can't pay x402 calls on its own, so the practical route is our AI Image Generator on RapidAPI, paid by card, with a free plan of 10 images a month. The image comes back as a 1024×1024 JPEG.

Try it free Image Generation API — pictures from a text prompt · $0.03 / call

The workflow

  1. Trigger: a Form, a schedule, a new row in Google Sheets, or a chat message with the prompt.
  2. HTTP Request node: POST the prompt to the image API.
  3. Convert to File node: operation "Move Base64 String to File", source property: the image_base64 field (check the HTTP node's output panel for its exact path), file name image.jpg.
  4. Destination: Google Drive upload, Telegram "Send Photo", email attachment or a CMS node, all reading the binary property.

HTTP Request node settings (RapidAPI)

{
  "prompt": "{{ $json.prompt }}",
  "steps": 6
}

Why not call the x402 endpoint directly

POST https://iamai.markets/api/x402/services/ij0SpjTJvY-K answers 402 with the price first. Paying it means signing a USDC payment on Base with a wallet and repeating the request, which the stock HTTP Request node can't do.

If you run your own x402 client as a small service, n8n can call that instead. For most workflows the RapidAPI key is simpler.

Prompt tips that matter in automations

Other ways to get images in n8n

OptionHowNote
OpenAI nodeBuilt-in node, image generationNeeds an OpenAI API key and billing
Any image API via HTTP RequestSame pattern as aboveCheck whether it returns a link or base64
AI Image Generator on RapidAPIHTTP Request with a RapidAPI keyCard plans, free 10 images a month

The product

Questions

Does this work on n8n Cloud and self-hosted?

Yes, it only uses the HTTP Request and Convert to File nodes, which both have.

Can I test a prompt before building the workflow?

Yes, try it on the listing page: 5 free tries a day, no sign-up.

Related

Updated 2026-12-01