Skip to content
Technology Jul 7, 2026 2 sources

Laravel AI Blog Generator: Build a Self-Hosted Blog That Writes Itself

AI-generated blog automation concept — glowing neural network over a keyboard
A self-hosted blog that writes itself — powered by real news and free LLMs.

Imagine a blog that wakes up every night, reads today's top tech news, writes a full article about it, and publishes it — all while you sleep. That is exactly what Laravel AI Blog Generator does, and it is completely free and open source.

What Is AI Blog Generator?

AI Blog Generator is a production-ready, Dockerized REST API built with Python and FastAPI. It accepts a single POST request and returns a fully SEO-optimised HTML blog article generated from today's real breaking news.

Under the hood it:

  • Fetches top headlines from NewsAPI filtered by category and country
  • Deduplicates stories using a 3-layer system — URL hash → title hash → Jaccard similarity — backed by SQLite
  • Calls any OpenAI-compatible LLM through OpenRouter (free models supported) to write the article
  • Returns full HTML with Open Graph tags, Twitter Card metadata, and Schema.org NewsArticle JSON-LD

You can run it standalone with a single Docker command:

docker run -d \
  --name ai-blog-generator \
  --env-file .env \
  -p 8000:8000 \
  -v ai_blog_data:/data \
  ghcr.io/roshanb08/ai-blog-generator:1.0.0

Then generate your first post:

curl -X POST http://localhost:8000/generate-blog \
  -H "Content-Type: application/json" \
  -d '{"category":"technology","country":"us","limit":5}'

One API call. One complete, publication-ready blog article. No writing required.

Code editor showing PHP and Laravel code on a dark screen
Laravel 13 powers the blog platform — PHP 8.3, MySQL, Redis, all orchestrated with Docker Compose.

The Laravel AI Blog Generator — A Full Blog Platform

Laravel AI Blog Generator takes the API one step further. Instead of just generating articles on demand, it wraps the generator inside a complete Laravel 13 blog platform that runs on autopilot — fetching, writing, and publishing one article every night at 02:00 UTC without any human intervention.

The stack:

  • Laravel 13 — the blog application (PHP 8.3)
  • MySQL 8 — stores articles, categories, and metadata
  • Redis 7 — job queues and caching
  • ai-blog-generator 1.1.0 — the FastAPI service that fetches news and calls the LLM
  • Docker Compose — orchestrates all four containers with a single command

How It Works

The architecture is straightforward. Every night the Laravel Scheduler triggers an Artisan command:

php artisan blog:generate

That command sends a POST request to the internal ai-blog-generator service with the configured category and country. The service fetches headlines, deduplicates them, writes the article, and returns an HTML block. Laravel saves it to MySQL and publishes it immediately — it appears at the top of the blog index within seconds.

A fallback chain is built in: if the primary category or country returns too few unique articles, the generator automatically retries with alternative parameters before giving up.

Quick Start — Up and Running in 3 Commands

Prerequisites

  • Docker and Docker Compose v2
  • A free NewsAPI key (100 requests/day on the free tier)
  • A free OpenRouter key (free models like google/gemma-4-31b-it:free are supported)

1. Clone and configure

git clone https://github.com/roshanb08/laravel-ai-blog-generator.git
cd laravel-ai-blog-generator
cp .env.example .env

Open .env and fill in your API keys:

NEWS_API_KEY=your_newsapi_key
OPENROUTER_API_KEY=sk-or-...
OPENROUTER_MODEL=google/gemma-4-31b-it:free

2. Start

docker compose up -d

That single command starts all four containers. Migrations and the APP_KEY are generated automatically on first boot.

3. Generate your first article on demand

docker compose exec laravel-ai-blog-web php artisan blog:generate

Open http://localhost and your first AI-generated article will be there.

Docker containers and server infrastructure for self-hosted applications
One docker compose up -d starts everything — no manual setup required.

Key Features

  • Completely free to run — OpenRouter free models mean zero LLM cost; NewsAPI free tier gives 100 requests/day
  • Fully autonomous — set it up once and the blog writes itself every night forever
  • 3-layer deduplication — URL hash, title hash, and Jaccard similarity prevent repeat stories across runs
  • SEO-optimised output — every article includes a unique title, meta description, Open Graph tags, and Schema.org JSON-LD
  • Medium-like design — clean serif typography, featured post hero, paginated card grid
  • Production-ready Docker — restart: unless-stopped on all services, health checks, named volumes
  • On-demand generation — trigger an article at any time with one Artisan command, no need to wait for the nightly schedule

Use Cases

The AI Blog Generator is a good fit for:

  • Developer portfolios — keep a live tech blog running without writing a single word
  • Company tech blogs — publish daily technology news under your brand automatically
  • SEO experiments — test how AI-generated, news-driven content ranks in search engines
  • Learning projects — study how Laravel Scheduler, Docker Compose, and external APIs work together in a real production codebase
  • Side projects — add a self-updating blog section to any website using the Docker API directly

Using the API Standalone in Your PHP or Laravel Project

If you already have a PHP or Laravel application and just want AI-generated articles on demand, you can run ai-blog-generator as a sidecar service and call it from your existing code:

// Laravel — using Http facade
$response = Http::post('http://ai-blog-generator:8000/generate-blog', [
    'category' => 'technology',
    'country'  => 'us',
    'limit'    => 5,
]);

$article = $response->json();
// Returns: title, html, meta_description, og_image ...

The API returns everything you need to save the article directly to your database — title, full HTML content, meta description, Open Graph title, description, and image URL.

Developer working on an open-source project late at night
Open source, MIT licensed — clone it, fork it, build on top of it.

Open Source & MIT Licensed

Both projects are open source under the MIT licence. Contributions, issues, and stars are welcome:

If you build something with it, we would love to hear about it.

Sources
More Articles