Back to Guides

How to Use Apiframe in n8n (Step-by-Step Guide)

Learn how to use Apiframe on N8N and automate content creation. From Getting your Apiframe API key to creating workflows.

In this guide, you will learn how to connect Apiframe to n8n so you can generate AI images (or videos, music, etc.) from any workflow.

We will cover:

  1. What we're building
  2. Prerequisites
  3. Creating Apiframe credentials in n8n
  4. Workflow 1 - Simple image generation using /imagine
  5. Workflow 2 - Polling results with /fetch
  6. Workflow 3 - Recommended: Using webhooks for real-time results
  7. Extending the pattern to other Apiframe endpoints

All examples will use the Midjourney /imagine endpoint, but the same pattern works for most of the other endpoints and models.

I. What we're going to build

We’ll build two small n8n integrations:

  1. Generate an image on demand
    • Trigger: Manual, Webhook, Google Sheet, anything
    • HTTP Request: POST https://api.apiframe.pro/imagine
    • Get back a task_id You can store or log
  2. Get the final images automatically
    • By polling Apiframe with /fetch until the task is complete
    • Or (recommended) let Apiframe call n8n Webhook when the task is complete

Once the image URLs land in n8n, you can do anything: send them to Slack, store them in Airtable, Google Drive, etc.

II. Prerequisites

You will need:

  • An Apiframe account and an API key. You can grab this from your Apiframe dashboard (or Click here). This API key will be used to authenticate our requests via the Authorization header.
Apiframe API key
Apiframe API key
  • An n8n instance (self-hosted or cloud)
  • Basic familiarity with n8n nodes (HTTP Request, Webhook, Set, IF, etc.). The HTTP Request node is the generic way to call any REST API in n8n.

III. Create Apiframe credentials in n8n

We’ll configure credentials once, then reuse them in all HTTP Request nodes.

  • Step 1: In n8n, go to Credentials → Create credential.
Create credential
Create credential
  • Step 2: Choose Header Auth (or "HTTP Header Auth", "API Key in Header" depending on your version)
Header Auth
Header Auth
  • Step 3: Configure:
    • Header name: Authorization
    • Value: your Apiframe API key (exactly as shown in your dashboard)
Apiframe header auth
Apiframe header auth
  • Step 4: Give it a name like Apiframe Auth and save

Apiframe expects:

text
Authorization: YOUR_API_KEY
Content-Type: application/json

IV. Workflow 1 - Basic image generation with /imagine

We’ll build a simple workflow:

💡
Manual Trigger → Set prompt → HTTP Request → Log task_id

1. Create the workflow

    1. In n8n, create a New workflow.
    2. Add a Manual Trigger node.
manual trigger
manual trigger

2. Add a "Set" node for the prompt

    1. Add a Set node after the Manual Trigger.
    2. In Values → Add Field → String:
      • Name: prompt
      • Value: something like a cinematic photo of a cyberpunk city at night, ultra detailed, 4k
    3. (Optional) Add another string field:
      • Name: aspect_ratio
      • Value: 3:2
Set Node
Set Node

Now the Set node’s output JSON looks roughly like:

json
{
  "prompt": "a cinematic photo of a cyberpunk city at night, ultra detailed, 4k",
  "aspect_ratio": "3:2"
}

3. Add the HTTP Request node for /imagine

    1. Add an HTTP Request node after the Set node.
    2. Configure:
      • Method: POST
      • URL: https://api.apiframe.pro/imagine
      • For authentication, choose the "Generic Credential type", then "Header Auth", then the “Apiframe Auth” credentials you created earlier.
      • For the body, turn on "Send body", and let's add our fields: prompt, aspect_ratio, and optionally webhook_url for later.
HTTP Request Node
HTTP Request Node
Request body
Request body

When you execute this node, Apiframe returns something like:

json
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}

This means the task is queued/processing. Images are generated asynchronously; you don’t get the final URLs from /imagine itself.

You can now:

  • Log the task_id
  • Store it in a DB / Google Sheet
  • Pass it forward to a “Fetch” workflow

V. Workflow 2 - Polling Apiframe with /fetch

Now let’s get the actual image URLs using the /fetch endpoint.

Apiframe exposes a POST https://api.apiframe.pro/fetch endpoint that takes task_id and returns either the final result or a status: "processing" response.

We’ll do a minimal “Wait then Fetch” flow.

1. Add a Wait node

After the /imagine HTTP Request node:

    1. Add a Wait node.
    2. Set it to wait, for example, 2–3 seconds.

This gives Apiframe time to finish the generation. Generation time depends on the task's complexity and the system load.

Wait node
Wait node

2. Add the /fetch HTTP Request node

Add another HTTP Request node after the Wait node:

    • Method: POST
    • URL: https://api.apiframe.pro/fetch
    • For authentication, choose the "Generic Credential type", then "Header Auth", then the “Apiframe Auth”, like before.
    • For the body, turn on "Send body", and let's add our task_id field
Fetch Request Node
Fetch Request Node
Fetch request body
Fetch request body

Processing (job still running):

json
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "task_type": "imagine",
  "status": "processing",
  "percentage": "40"
}

Completed (job done, image URLs ready):

json
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "task_type": "imagine",
  "original_image_url": "https://.../grid.png",
  "image_urls": [
    "https://.../image1.png",
    "https://.../image2.png",
    "https://.../image3.png",
    "https://.../image4.png"
  ]
}

3. Handling “still processing”

For a quick dev setup, you can:

  • Just wait longer and fetch once.
  • Or add a simple IF node after the Fetch:
    • Condition: status equals "processing"
    • If “true”: branch to another Wait + Fetch
    • If “false”: continue with your final logic (Slack, Airtable, etc.)

In production, Apiframe recommends using webhooks instead of polling to avoid unnecessary requests and get instant updates.

Let’s do that next.

This is the clean, “real-time” architecture:

  • Workflow A: Send generation request (with webhook_url and webhook_secret)
  • Workflow B: Receive webhook from Apiframe when generation is done

1. Create Workflow B - The webhook receiver

    1. Create a New workflow in n8n and name it Apiframe – Image Completed.
    2. Add a Webhook node. Configure the Webhook node:
      • HTTP Method: POST
      • Path: something like apiframe/midjourney-completed
      • Response mode:
        • For example, When Last Node Finishes (so you can return data back if you want).

Copy the Production URL – this is what we’ll set as webhook_url in Apiframe.

Webhook node
Webhook node

2. Secure the webhook with "webhook_secret"

Apiframe lets you pass a webhook_secret in the /imagine request; it will send it back as x-webhook-secret header on webhook calls.

    1. Add an IF node after the Webhook node.
    2. In the IF node, check:
      • Left side: Expression like ={{ $json["headers"]["x-webhook-secret"] }}
      • Condition: equals
      • Right side: your secret, e.g. my-super-secret
    3. If the secret doesn’t match, go to a branch that just ends (or logs the attempt).
Secure webhooks
Secure webhooks

This ensures only Apiframe’s webhooks are processed.

3. Accessing the image URLs in the webhook payload

The webhook body will look like the same “completed” payload shown earlier:

json
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "task_type": "imagine",
  "original_image_url": "https://.../grid.png",
  "image_urls": [
    "https://.../image1.png",
    "https://.../image2.png",
    "https://.../image3.png",
    "https://.../image4.png"
  ]
}

You can access the image URLs, then pass them into:

  • Slack node (send a message with the URL)
  • Airtable / Notion (store the URL)
  • HTTP Request (push to your app’s backend)

4. Update Workflow A to use the webhook

Return to Workflow A (the one calling /imagine) and edit the HTTP Request node body to include:

  • webhook_url
  • webhook_secret
Added webhook fields
Added webhook fields

Example JSON body in the HTTP Request node:

json
{
  "prompt": "a cinematic photo of a cyberpunk city at night, ultra detailed, 4k",
  "aspect_ratio": "3:2",
  "webhook_url": "https://your-n8n-domain.com/webhook/apiframe/midjourney-completed",
  "webhook_secret": "my-super-secret"
}

Now the flow is:

  1. Workflow A → /imagine with webhook_url + webhook_secret
  2. Apiframe generates the image in the background
  3. When done, Apiframe calls your Webhook (Workflow B) with the final URLs
  4. Workflow B processes them and pushes them wherever you want

No polling, no extra HTTP requests – just event-driven.

VII. Extending this pattern to other Apiframe endpoints

The nice part: once you’ve wired n8n → Apiframe once, you can reuse the same pattern for everything.

Some ideas:

  • Variations: switch the URL to https://api.apiframe.pro/variations and send the original task_id + new prompt.
  • Upscales: same auth, different endpoint/body.
  • Faceswap: send two image URLs (source & target) to the faceswap endpoint.
  • Describe: build an n8n workflow where you drop an image URL and Apiframe returns a prompt for it.
  • Other media: Flux, Ideogram, Luma, Suno, etc. all follow the same REST pattern: POST with JSON, include webhook_url + webhook_secret if you want webhooks.

Each of these becomes just another HTTP Request node (or two, if you also use /fetch) using the same “Apiframe Auth” credentials.

VIII. Wrap-up

You now have:

  • A basic /imagine workflow to trigger Midjourney via Apiframe in n8n
  • A polling setup using /fetch for quick experiments
  • A webhook-based architecture for real-time, production-grade pipelines

Ready to start building?

Get your API key and start generating AI content in minutes.