MegaBrain in n8n: images, video and text models

Generate images with Nano Banana Pro, FLUX 2 and Seedream, videos with Kling 3 and Seedance, and call Claude, GPT, Gemini and 100+ other text models from your n8n workflows with one API key. Every request is paid from your balance; a job the provider fails is refunded. The templates below use only built-in n8n nodes, so they work on n8n Cloud and on a self-hosted n8n alike.

Credentials

Copy your key on the API key page and add funds on the Balance page. Then create the credential that fits the node you use:

  • HTTP Request node (the templates): a Header Auth credential named MegaBrain API key, header name Authorization, value Bearer YOUR_KEY.
  • AI Agent / OpenAI Chat Model node: an OpenAI credential with your MegaBrain key and Base URL https://getmegabrain.com/api/gateway/v1. The model list then shows every MegaBrain text model, including the free mb-auto/free.

Workflow templates

Download a file and import it in n8n (Workflows → Import from File), or open it and paste the JSON onto the canvas. Each template has a note with the setup steps and the price of a run.

Telegram AI image botNano Banana Pro

Send the bot a description, get a 2K image back. Replies with the reason when a generation fails.

telegram-image-bot-nano-banana-pro.json
Idea → Kling 3 videoKling 3, mb-auto/free

A form takes a one-line idea, a free model writes the prompt, Kling 3 renders the clip and the form shows the link.

text-to-video-kling-3.json
Instagram carouselFLUX 2, mb-auto/free

A free model plans the slides and the caption, FLUX 2 draws each slide at 1080×1350.

instagram-carousel-flux-2.json
Product photo → video adNano Banana Pro Edit, Kling 3

Puts the product from one photo into a lifestyle shot that keeps the label, then animates it into a vertical clip.

product-photo-to-video-ad.json
AI agent on any modelClaude, GPT, Gemini, Kimi, GLM…

n8n’s AI Agent with the OpenAI Chat Model node pointed at MegaBrain. Starts on the free model.

ai-agent-any-model.json

Image and video jobs with the HTTP Request node

An image fits in one request: POST /images/generations waits up to about 110 seconds and returns the URL in data[0].url. Any model field (aspect_ratio, resolution, image_urls…) goes in the same body. If the image is not ready in time, the answer is 202 with response_url: wait 10 seconds and GET response_url until it returns images[0].url, as the templates do.

POST https://getmegabrain.com/api/gateway/v1/images/generations
Authorization: Bearer YOUR_KEY

{"model": "nano-banana-pro", "prompt": "{{ $json.text }}", "aspect_ratio": "1:1", "resolution": "2K"}

A video runs in the queue. Submit it, then loop Wait (15 s) → GET status_url → Switch on status until it is COMPLETED and read video.url from GET response_url. FAILED means the price went back to your balance.

POST https://getmegabrain.com/api/gateway/v1/queue/kling-video/v3/standard/text-to-video
Authorization: Bearer YOUR_KEY

{"prompt": "a drone flies over a snowy mountain lake at sunrise", "duration": "5", "generate_audio": false}

Model ids, prices and every model’s fields are in the image and video API docs; text models are in the text models API docs.