🔗 G-Labs Webhook × n8n Integration

Automate AI image & video generation by connecting G-Labs Automation with n8n — the open-source workflow automation platform.

⚠️MAX plan required for Webhook API.

1. 🌟 Overview

G-Labs Webhook API provides a local REST API server running on your computer. You can send image/video generation requests from any tool — including n8n.

Why use n8n?

  • Full automation: Schedule image/video creation by time or events
  • Multi-platform integration: Pull prompts from Google Sheets, Telegram, email → generate → send results
  • Drag-and-drop interface: No coding required
  • Free & self-hosted: Runs on your own machine
text
n8n Workflow → [HTTP Request] → G-Labs Webhook API (127.0.0.1:8765)
                                        ↓
                              Added to G-Labs queue
                                        ↓
                              G-Labs generates image/video
                                        ↓
n8n Workflow ← [Polling / Check status] ← Returns result (file URLs)

2. 🛠️ Prerequisites

ComponentDetails
G-Labs AutomationInstalled, MAX plan active
n8nInstalled
Google AccountAt least 1 valid account in G-Labs

Install n8n

Option 1 — n8n Desktop: Download from n8n.io/get-started

Option 2 — npm:

bash
npm install n8n -g
n8n start

Option 3 — Docker:

bash
docker run -it --rm --name n8n -p 5678:5678 n8nio/n8n
💡n8n and G-Labs must run on the same computer (the Webhook API only listens on 127.0.0.1).

3. 🚀 Enable Webhook Server

  1. Open G-Labs Automation
  2. In the left sidebar, click Webhook (🔗)
  3. Copy your API Key
  4. Configure port (default: 8765)
  5. Click Start Server → status changes to 🟢 Server Online

4. 🖼️ Workflow 1: Generate AI Images

text
[Manual Trigger] → [HTTP: Generate] → [Wait 30s] → [HTTP: Check Status] → [IF completed?]
                                                                               ↓ Yes
                                                                        [HTTP: Download]
                                                                               ↓ No
                                                                        [Back to Wait]

Step 4.3 — HTTP Request (Generate)

PropertyValue
MethodPOST
URLhttp://127.0.0.1:8765/api/image/generate
HeaderX-API-Key: YOUR_API_KEY
json
{
  "prompt": "a beautiful sunset over the ocean, cinematic, 8k",
  "model": "nano_banana_2",
  "aspect_ratio": "16:9",
  "upscale": ["2K"],
  "reference_images": []
}

5. 🎬 Workflow 2: Generate AI Videos

Similar to image workflow — change the endpoint and parameters:

json
{
  "prompt": "a golden retriever running on the beach, slow motion",
  "model": "veo_31_fast",
  "mode": "text_to_video",
  "aspect_ratio": "16:9",
  "resolution": ["720p", "1080p"]
}
💡Videos take 1–5 minutes. Set Wait = 60 seconds between status checks.

6. 📦 Workflow 3: Batch Generation

Read a list of prompts from Google Sheets / CSV → generate images in bulk.

json
{
  "prompt": "={{ $json.prompt }}",
  "model": "={{ $json.model || 'nano_banana_2' }}",
  "aspect_ratio": "={{ $json.aspect_ratio || '16:9' }}"
}

7. ⚠️ Error Handling & Tips

TipDetails
Health check firstAdd GET /api/health node at the start
Timeout protectionCounter for poll attempts. If > 20 → stop and report
Save credentialsSettings → Credentials → create Header Auth to reuse API Key
Parallel requestsSend multiple requests (G-Labs manages its own queue)
RetryUse Error Trigger + Retry on Fail

8. 📖 API Quick Reference

EndpointMethodAuthDescription
/api/healthGETCheck server status
/api/image/generatePOSTSubmit image generation
/api/video/generatePOSTSubmit video generation
/api/grok/generatePOSTSubmit Grok image/video
/api/status/{task_id}GETCheck task status
/api/result/{task_id}GETGet task result
/api/files/{filename}GETDownload file
/api/tasksGETList all tasks