Build a Free AI Article Generator with n8n: Gemini + Pexels in Action

Chain Gemini and Pexels with n8n to generate complete blog posts with compliant images at zero cost.
This article presents a content automation solution built around the open-source workflow platform n8n, connecting Google Gemini's free text generation with Pexels' free image API into a complete pipeline. The four-step workflow covers topic retrieval, Gemini-powered structured article generation, JSON parsing, and keyword-based image search from Pexels. The output panel delivers the title, body, image URL, and photographer credit in one shot — balancing production efficiency with copyright compliance. Near-zero cost makes it ideal for bloggers and small teams, though API quota limits, JSON format drift, and the need for human review before publishing are all worth keeping in mind.
Why Choose n8n for Automated Content Production
The bottleneck in content creation isn't usually the writing itself — it's connecting a scattered set of tools into a reliable workflow. n8n, as an open-source workflow automation platform, offers a low-barrier solution: visually chain together AI text generation, JSON parsing, image retrieval, and more into a complete pipeline, then run the entire process with a single click on "Execute Workflow."
The biggest appeal of this setup is that it's free. It combines Google Gemini's free tier with Pexels' free image API, producing article content and automatically pairing it with copyright-compliant images — perfect for individual bloggers and small teams experimenting with bulk content production.

Breaking Down the Core Logic of the Workflow
The entire automation can be broken into four key stages, each corresponding to one or more nodes in n8n:
1. Fetch a Topic
The workflow starts by having n8n retrieve a topic to write about. The topic source can be a manual input, a spreadsheet, or a parameter passed in from an upstream node. This step determines the direction of all content generated downstream.
2. Generate the Article with Gemini
Once a topic is available, n8n calls the Gemini model to generate the article. The key here is prompt design — you need the model to output in a structured format containing fields like title and body text, laying the groundwork for clean parsing later.

Google Gemini is a multimodal large language model series developed by Google DeepMind, available in versions including Gemini 1.5 Flash and Gemini 1.5 Pro. Free access is provided through Google AI Studio — as of late 2024, Gemini 1.5 Flash supports roughly 15 requests per minute and 1,500 per day, which is generally sufficient for individual bloggers' daily content needs. In n8n, Gemini is typically called via an HTTP Request node sending a REST API request, or through a community-built Gemini node. After configuring an API Key, you pass in a prompt and receive the generated text. It's worth noting that Gemini handles Chinese prompts well, but to get consistent JSON output, it's best to explicitly state the format requirements in the prompt — for example, "Please return the result strictly following the JSON Schema below, without any additional explanatory text" — and reinforce this in the System Prompt.
3. Parse the JSON
If Gemini returns content in a JSON structure, n8n can cleanly split it into individual fields. This step is critical to keeping the entire pipeline stable — structured output means the title and body can each flow into different downstream nodes, rather than arriving as a blob of hard-to-process plain text.
Parsing JSON in n8n typically involves the built-in Code node (running JavaScript) or a Set node to extract fields. When Gemini returns a standard JSON string, you can use JSON.parse() to convert it into an object and then access values by field name. However, large language models inherently carry a "format drift" risk — the model might append explanatory text before or after the JSON, use single quotes instead of double quotes, or omit brackets in nested structures, causing the parse to fail. A common hardening approach is to add a regular expression in the Code node to first extract the first {...} segment from the returned text before attempting to parse it. Another option is to use Gemini's response_mime_type parameter, setting it to application/json to force the model to return valid JSON at the API level, fundamentally reducing drift probability.
4. Match an Image from Pexels
Finally, the workflow calls the Pexels API using the article's topic or keywords to retrieve a matching free-for-commercial-use image, along with the image URL and photographer attribution information.
Pexels is a platform offering free high-quality stock photography. Images are licensed under the Pexels License, which permits commercial use with no attribution required — though the platform encourages (and the API terms of service effectively require) crediting the photographer's name and source link to support creators. The Pexels API free tier supports approximately 200 requests per month (actual limits may vary by account status). You can search images by keyword via the GET /v1/search?query=keyword endpoint. The returned JSON includes image URLs in multiple sizes (src.original, src.large, etc.) as well as the photographer's name (photographer) and profile link (photographer_url). In n8n, a single HTTP Request node with the Authorization Header configured (filled with your Pexels API Key) handles the entire retrieval step; a Set node then maps the required fields to the downstream output.
Output Results at a Glance
After the workflow completes, n8n's output panel on the right clearly displays everything generated in that run. You can immediately review:
- The newly generated blog post title
- The complete body content
- A direct link to the matched image
- Photographer attribution (as required by Pexels)

This "one execution, full output" design makes debugging and reuse straightforward. The inclusion of the photographer attribution field is especially noteworthy — it directly addresses the most commonly overlooked copyright issue when using free image libraries, ensuring the produced content can be published safely.

Who Is This For, and What Should You Watch Out For?
For creators who want to quickly validate content automation ideas, this n8n + Gemini + Pexels combination is an exceptionally cost-effective entry point. It assembles three free resources into a reusable production pipeline, eliminating the hassle of manually calling multiple tools.
That said, it's important to be clear-eyed about its limitations. AI-generated articles typically require human review before they're ready to publish. Both Gemini's free tier and Pexels' API call frequency have caps that need watching during large-scale batch production. In addition, the JSON parsing stage places high demands on prompt consistency — if the model's output format drifts, the entire pipeline can break down, making this the most critical point to harden in real-world deployments.
Overall, this is an excellent showcase of n8n's orchestration capabilities: using minimal resources to close the loop between AI writing and image retrieval, and laying the groundwork for more sophisticated content automation down the road.
Related articles

AI Agent Decision Auditing: Building an Evidence Chain in Regulated Workflows
Starting from a Reddit discussion, this article analyzes three core issues in AI agent decision auditing within regulated workflows: what fields audit records should contain, how to handle feedback latency for erroneous decisions, and how to continuously calibrate LLM judge consistency with human judgment.

Apple Opens Multiseat Subscription Purchasing: App Subscriptions Can Now Be Sold in Bulk to Businesses and Schools
Apple opens multiseat purchasing for auto-renewable subscriptions: businesses and schools can bulk-buy via Apple Business and Apple School Manager, adding or removing seats anytime. Enabled by default in App Store Connect—developers should verify settings; group purchasing sandbox testing opens October 2026.

FCC Takes First Action: Devices Containing "Foreign Surveillance Chips" Banned
The FCC exercises its new power for the first time, banning two devices for containing "foreign surveillance chips." This article analyzes the impact on hardware supply chain compliance, chip procurement decisions, and market access.