JUHE API Marketplace

Nano Banana Pro API for Automation: Build Workflows with n8n

9 min read

Why Nano Banana Pro + n8n for AI automation

Automation engineers and indie builders want reliable, fast pipelines that are easy to deploy and maintain. Pairing Nano Banana Pro API with n8n gives you a lightweight, composable n8n AI workflow you can run anywhere. The model gemini-3-pro-image-preview delivers Gemini lightweight automation for text-to-image prompts, creative drafting, and structured responses without heavyweight setup.

What you’ll get

  • A ready-to-import n8n workflow JSON: prompt → model → output
  • A curl test you can paste to validate your API key
  • Practical guidance for retries, security, and cost control

API quickstart

Nano Banana Pro exposes a familiar chat-style endpoint for completions.

Curl smoke test (copy-paste)

Use this to validate your key and network. If you see a valid JSON response, you’re ready to wire n8n.

curl --location --request POST 'https://wisdom-gate.juheapi.com/v1/chat/completions' \
--header 'Authorization: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Host: wisdom-gate.juheapi.com' \
--header 'Connection: keep-alive' \
--data-raw '{
  "model":"gemini-3-pro-image-preview",
  "messages": [
    {
      "role": "user",
      "content": "Draw a stunning sea world."
    }
  ]
}'

Tip: Some gateways expect Bearer tokens. If your credential requires it, set Authorization to Bearer YOUR_API_KEY. The example above mirrors the provided header format.

Workflow architecture: prompt → model → output

Our Nano Banana automation flow is designed for simple, repeatable steps.

  1. Webhook (POST): accept a prompt and optional options from clients
  2. Set: shape the payload and default values
  3. HTTP Request: call Nano Banana Pro chat/completions with the Gemini model
  4. Set: extract the response text or image URL
  5. Respond to Webhook: return clean JSON to the caller

Request and response shape

  • Request body: { prompt: "..." }
  • Response body: { model: "gemini-3-pro-image-preview", output: "..." }

This keeps clients free from provider-specific details while enabling n8n to orchestrate retries, caching, and routing.

Step-by-step build in n8n

Follow these compact steps to assemble the pipeline. You can also skip to the ready-to-import JSON below.

1) Create a Webhook trigger

  • Node: Webhook
  • Method: POST
  • Path: /nano-banana
  • Response mode: Last node (we will respond with Respond to Webhook)

2) Shape the input

  • Node: Set (keep only set values)
  • Field prompt: {{$json.body.prompt || $json.prompt || 'Draw a stunning sea world.'}}
  • Optional extras you can pass: size, style

3) Call the model

  • Node: HTTP Request
  • Method: POST
  • URL: https://wisdom-gate.juheapi.com/v1/chat/completions
  • Headers:
    • Authorization: Use YOUR_API_KEY or Bearer YOUR_API_KEY as your gateway requires
    • Content-Type: application/json
    • Accept: /
    • Host: wisdom-gate.juheapi.com
    • Connection: keep-alive
  • JSON body:
    • model: gemini-3-pro-image-preview
    • messages: [{ role: 'user', content: prompt }]

4) Extract output

  • Node: Set (keep only set values)
  • Fields:
    • model: gemini-3-pro-image-preview
    • output: choices[0].message.content or a fallback when structure differs

5) Respond to caller

  • Node: Respond to Webhook
  • Body: { model, output }
  • Status: 200

Environment variable for secrets

Use N8N_ENV or your Docker environment to hold NANO_BANANA_API_KEY. In expressions, reference it with $env.NANO_BANANA_API_KEY. This keeps secrets out of node parameters.

Ready-to-import n8n JSON workflow

Import this in n8n (Settings → Import) and start the execution. It listens on POST /nano-banana and returns a simple JSON response.

{
  "name": "Nano Banana Pro: Prompt → Model → Output",
  "nodes": [
    {
      "parameters": {
        "path": "nano-banana",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "Webhook",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        300,
        300
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "prompt",
              "value": "={{$json.body && $json.body.prompt ? $json.body.prompt : ($json.prompt || 'Draw a stunning sea world.')}}"
            },
            {
              "name": "apiKey",
              "value": "={{$env.NANO_BANANA_API_KEY || 'YOUR_API_KEY'}}"
            }
          ]
        }
      },
      "id": "Set Prompt",
      "name": "Set Prompt",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        540,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://wisdom-gate.juheapi.com/v1/chat/completions",
        "options": {
          "timeout": 30000
        },
        "queryParametersUi": {
          "parameter": []
        },
        "headerParametersJson": "={\"Authorization\":\"{{$json.apiKey}}\",\"Content-Type\":\"application/json\",\"Accept\":\"*/*\",\"Host\":\"wisdom-gate.juheapi.com\",\"Connection\":\"keep-alive\"}",
        "jsonParameters": true,
        "bodyParametersJson": "={\"model\":\"gemini-3-pro-image-preview\",\"messages\":[{\"role\":\"user\",\"content\":\"{{$json.prompt}}\"}]}"
      },
      "id": "HTTP Request",
      "name": "Nano Banana Pro API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        800,
        300
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "model",
              "value": "={{'gemini-3-pro-image-preview'}}"
            },
            {
              "name": "output",
              "value": "={{$json.choices && $json.choices[0] && $json.choices[0].message && $json.choices[0].message.content ? $json.choices[0].message.content : ($json.data || $json.text || $json.output || 'No content')}}"
            }
          ]
        }
      },
      "id": "Set Result",
      "name": "Set Result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1060,
        300
      ]
    },
    {
      "parameters": {
        "responseCode": 200,
        "responseBody": "={\"model\":\"{{$json.model}}\",\"output\":\"{{$json.output}}\"}"
      },
      "id": "Respond",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1320,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Set Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Prompt": {
      "main": [
        [
          {
            "node": "Nano Banana Pro API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Nano Banana Pro API": {
      "main": [
        [
          {
            "node": "Set Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Result": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Run and verify

With n8n running, send a request to your webhook.

Local test via curl

curl -X POST http://localhost:5678/webhook/nano-banana \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"Draw a stunning sea world."}'

Expected response

{
  "model": "gemini-3-pro-image-preview",
  "output": "..."
}

If the model returns an image preview URL or base64, output will carry it. For text completions, output contains the generated text.

Production hardening

Make the pipeline resilient without making it complex.

Reliability

  • Retries: configure HTTP Request retries and exponential backoff
  • Timeouts: set a sensible timeout (30–60s depending on workload)
  • Circuit breakers: add an IF node to short-circuit when upstream is rate-limited

Security

  • Secrets: store NANO_BANANA_API_KEY in environment or n8n credentials, not in node params
  • Input validation: reject empty or oversized prompts in the Webhook node using an IF node
  • Output sanitization: strip disallowed characters or enforce JSON-only payloads for downstream services

Cost control

  • Cache: memoize frequent prompts with a simple datastore node
  • Debounce: coalesce duplicate requests arriving within a short window
  • Budget guardrails: set max length and complexity; refuse prompts that exceed policy

Common variations and use cases

Nano Banana automation should be flexible. Here are quick variants you can adopt.

A) Manual Trigger for internal testing

Swap the Webhook for Manual Trigger and feed a Set node with a fixed prompt. This is useful for development or demo flows.

B) Prompt presets

Add a Switch node to pick styles (realistic, watercolor, neon). Use Set to combine a preset with the incoming prompt: style + subject → richer output.

C) Structured output for downstream

Ask the model to return JSON adhering to a schema. Pattern: "Return a JSON object with fields: title, description, image_hint." Then parse and validate before passing to your system.

D) Batch mode

Use Split In Batches to send multiple prompts through the same pipeline, then aggregate outputs. Keep concurrency modest to avoid rate limits.

E) Routing by capability

If you later include multiple models, route to gemini-3-pro-image-preview for image-centric or creative tasks and to a text-only model for data extraction.

Prompt engineering tips

To get consistent results with a lightweight Gemini model, keep prompts specific and bounded.

Strong baselines

  • Describe subject, composition, mood, and constraints
  • Provide resolution hints like size: medium; avoid overspecifying technical details when not supported
  • Use examples: "Output exactly one paragraph that describes the image to generate"

Guardrails

  • Cap prompt length
  • Avoid ambiguous verbs and compound goals
  • Ask for deterministic structure when needed: "Respond with a JSON object containing keys caption and style"

End-to-end automation scenarios

Bring the same workflow into bigger systems.

Content generation pipeline

  • Input: CMS posts that need visuals
  • Flow: CMS → n8n Webhook → Nano Banana Pro → store URL in CMS → publish
  • Wins: speed, uniformity, minimal developer overhead

Marketing experiments

  • Input: A/B prompts for landing pages
  • Flow: Spreadsheet → n8n → model → report
  • Wins: fast iteration, measurable results, no bespoke infra

Indie builder toolkit

  • Input: form in a static site
  • Flow: Form submit → n8n → model → email or webhook
  • Wins: launch faster, maintain less, scale gradually

Troubleshooting

Most issues boil down to credentials or payloads. Work through these quickly.

401 or 403

  • Verify Authorization header value matches your gateway requirements (plain key vs Bearer key)
  • Ensure NANO_BANANA_API_KEY is available to n8n

400 Bad Request

  • Confirm Content-Type is application/json
  • Validate bodyParametersJson formatting and that messages is an array of { role, content }

Timeout

  • Increase HTTP Request timeout
  • Try smaller prompts or reduce downstream processing

Unexpected response shape

  • Inspect the raw response in Nano Banana Pro API node
  • Adapt Set Result extraction: choices[0].message.content vs data or text fields

Performance notes

For Gemini lightweight automation patterns, keep throughput efficient.

Practical settings

  • Concurrency: keep it 3–5 per worker unless your rate limits allow more
  • Response size: use compact outputs to reduce bandwidth and serialization overhead
  • Observability: log prompt and response length, not full content, for privacy and performance

Why this approach stays simple

  • Minimal nodes: 5 components from input to output
  • Clear contracts: generic request and response shape
  • Easy to extend: plug in caching, retries, or routing without changing the API call

Next steps

  • Import the JSON workflow and run a local test
  • Add guardrails (rate limits, length caps)
  • Evolve prompts for your domain and wire the output into your product

By starting with a lean n8n AI workflow and the Nano Banana Pro chat endpoint, you get fast iteration with minimal ops—perfect for automation engineers and indie builders who want working software today.

Nano Banana Pro API for Automation: Build Workflows with n8n | JuheAPI Blog