◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
Articles/API / SDK
◈ API / SDK/2026-04-02Beginner

Automate AI Workflows with Gemini API and n8n

Learn how to connect Gemini API with n8n to automate AI-powered workflows. From basic HTTP Request nodes to advanced AI Agent setups — with practical code examples throughout.

gemini-api286n8nworkflow automationno-codeAI automationPython51

Automating AI Workflows with n8n and Gemini API

Adding AI to an existing process usually means writing glue code, then maintaining it forever. n8n sidesteps that: an open-source workflow automation platform, self-hostable, with connectors for more than 400 services. Paired with Google's Gemini API, it becomes a place to run practical AI workflows without a codebase to babysit.

What we'll set up:

  • How to set up n8n locally with Docker
  • Calling the Gemini API using HTTP Request nodes
  • Using AI Agent nodes for more advanced automation
  • Real-world use cases: email summarization, scheduled reports
  • Common errors and how to fix them

This guide is ideal for developers who want to add AI capabilities to their workflows without heavy coding, or anyone coming from Zapier/Make looking for a more flexible, self-hostable alternative.


What is n8n? — Why It's Worth Your Attention

n8n (short for "nodemation") is an open-source automation platform originally from Germany. While it sits in the same category as Zapier or Make, it stands out in several key ways:

  • Self-hostable: Your data stays on your own server or laptop
  • Code-friendly: JavaScript/Python Code nodes for complex logic
  • Built-in AI nodes: Native support for LLMs like Gemini, OpenAI, Claude
  • Free to start: Self-hosted version is completely free

As of 2026, n8n ships with a full suite of AI-oriented nodes — AI Agent, Memory, Vector Store, and more — making it possible to build RAG pipelines entirely through a visual interface, no coding required.


Setting Up Your Environment

Running n8n Locally with Docker

# Requires Docker to be installed first
docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n

Open http://localhost:5678 in your browser to reach the setup screen. You'll be prompted to create an admin account on first run.

Getting a Gemini API Key

  1. Go to Google AI Studio and sign in
  2. Click Get API key in the left sidebar
  3. Hit Create API key to generate a new key
  4. Copy it somewhere safe — we'll refer to it as YOUR_GEMINI_API_KEY

API keys are free with any Google account. The free tier allows up to 15 requests per minute and 1,500 requests per day with Gemini 2.5 Flash.

For a more in-depth setup walkthrough, check out the Gemini API Quickstart Guide.


The Basics: Calling Gemini API with an HTTP Request Node

The simplest way to integrate Gemini into n8n is via the HTTP Request node. Since Gemini's API is a standard REST API, any HTTP client — including n8n's built-in node — can call it directly.

Step-by-Step Workflow Setup

Step 1: Create a new workflow

In the n8n dashboard, click New Workflow and give it a name (e.g., Gemini Test).

Step 2: Add a Manual Trigger node

Click +, search for Manual Trigger, and add it. This lets you start the workflow by clicking a button.

Step 3: Add and configure an HTTP Request node

Click + to the right of the trigger node and add an HTTP Request node. Configure it as follows:

Method: POST
URL: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=YOUR_GEMINI_API_KEY
Body Content Type: JSON
Body:
{
  "contents": [
    {
      "parts": [
        {
          "text": "Explain the future of AI in 100 words."
        }
      ]
    }
  ]
}

Step 4: Run a test

Click Test workflow. You should receive a response from Gemini that looks like this:

// Example response
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "The future of AI is deeply collaborative. As models become more capable, they'll take on complex tasks in healthcare, climate science, and education — while humans retain creative direction and emotional judgment. The most transformative shift will be AI systems that reason, adapt, and explain themselves transparently."
          }
        ],
        "role": "model"
      }
    }
  ]
}

Step 5: Extract the text from the response

To use the generated text in downstream nodes, use this expression in n8n's expression editor:

// n8n expression syntax
{{ $json.candidates[0].content.parts[0].text }}

Going Further: Using the AI Agent Node with Gemini

With n8n 1.0+, the AI Agent node lets you treat LLMs as high-level reasoning components. You can attach tools (like web search, code execution, or API calls) and let the agent decide when and how to use them.

Setting Up the Gemini Chat Model Node

  1. Click + and browse to the AI category
  2. Search for and add Google Gemini Chat Model
  3. Under Credentials, create a new Google Gemini(PaLM) Api credential
  4. Paste your API key and save

We recommend gemini-2.5-flash for cost-effective workflows. Switch to gemini-2.5-pro when you need higher reasoning quality.

Real-World Example: Auto-Summarize Emails to Slack

Here's a practical workflow that watches for new emails, summarizes them with Gemini, and posts to Slack:

Gmail Trigger (new email arrives)
  ↓
AI Agent (Gemini 2.5 Flash)
  "Summarize this email in 3 bullet points: {{ $json.snippet }}"
  ↓
Slack (post summary to #notifications)

Set the AI Agent's System Message to:

You are a business email assistant.
Summarize the email body in no more than 3 bullet points.
If there are action items, add a final line starting with "Action needed:".
Reply in the same language as the email.

This simple workflow can save hours of inbox time each week.


Practical Example: Scheduled AI Reports

Using a Cron trigger, you can have Gemini analyze data from Google Sheets every morning and email you a summary.

Cron (every day at 8:00 AM)
  ↓
Google Sheets (fetch yesterday's data)
  ↓
Code node (format data as readable text)
  ↓
HTTP Request (Gemini API — analyze and summarize)
  ↓
Gmail (send report to your inbox)

In the HTTP Request body, pass the data like this:

{
  "contents": [
    {
      "parts": [
        {
          "text": "Analyze the following dataset and identify 3 key trends with recommended actions:\n\n{{ $json.sheetData }}"
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.3,
    "maxOutputTokens": 1024
  }
}

A lower temperature value (like 0.3) produces more consistent, fact-based outputs — ideal for analytical reports.

For more advanced automation patterns including CI/CD integration, see Automating Business Workflows with Gemini API — CI/CD Integration and Prompt Tuning Techniques.


Common Errors and Fixes

401 Unauthorized

Your API key is missing, invalid, or expired. Regenerate it in Google AI Studio and update the credential in n8n. For better security, store the key in n8n's credential manager rather than hard-coding it in the URL.

429 Too Many Requests

You've exceeded the free tier rate limit (15 req/min). Add a Wait node between API calls:

HTTP Request → Wait (5 seconds) → Next node

Alternatively, upgrade to a paid Gemini API plan for higher limits.

Empty or Undefined Response

Usually caused by a typo in the model name. Valid model identifiers include gemini-2.5-flash and gemini-2.5-pro. Some models require a -preview suffix — always verify the latest model IDs in Google AI Studio.

Expression Returns Nothing

Make sure the JSON path matches the actual response structure. Use n8n's built-in JSON output view after running a test to inspect the exact structure before writing your expression.


Looking back

The workflow you now have connects n8n to the Gemini API:

  • Using HTTP Request nodes to call Gemini directly via REST
  • Configuring the AI Agent node for higher-level reasoning tasks
  • Practical workflows: email summarization, scheduled reports
  • Fixing common errors (401, 429, empty responses)

n8n's strength lies in its ability to keep code minimal while letting you compose complex AI logic visually. Combined with Gemini API's breadth of features — multimodal input, Function Calling, long-context windows — you can automate a wide range of business tasks with relatively little effort.

Start by running n8n locally with Docker, grab a free Gemini API key, and try building a simple test workflow. For more day-to-day automation ideas, the Gemini API Daily Task Automation Guide is full of practical examples to get you started.

Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

◈ API / SDK2026-10-16
The Day /models Returns 200 but generateContent Returns 403 — Decide Your Triage Order Before It Happens
A triage order for the case where listing models succeeds with 200 but generation fails with 403 permission_denied. Includes a small diagnostic script that checks key, project, and billing in turn, why you should not retry a 403, and how to assemble what support needs.
◈ API / SDK2026-10-14
When Your config Raises "Extra inputs are not permitted", Check the Spelling of Every Key
If a google-genai call fails with a pydantic ValidationError (extra_forbidden) the moment you pass a config, it is almost always a one-letter typo. Here is the output I reproduced, a small function that checks keys before the call, and how to tell why response.text came back as None.
◈ API / SDK2026-10-08
When a Deprecation Has No Shutdown Date: Re-Picking an Image Model on Three Conditions
gemini-nano-banana-2.1 went GA on October 6, and gemini-3.1-flash-image was deprecated with no shutdown date. Here is a table and a short script for choosing a replacement by resolution, reference images, and search grounding.