DEV Community

Cover image for How we automated keyword research and mapping using structured LLM outputs
Mactrix XR
Mactrix XR

Posted on

How we automated keyword research and mapping using structured LLM outputs

How we automated keyword research and mapping using structured LLM outputs

You build a product. You launch it on Product Hunt. You tweet about it once. You check the box. But how are you driving sustainable traffic the other six days of the week?

In a world filled with shifting algorithms, infinite digital noise, and fierce market competition, it is easy to live as a box-checking, nominal founder. You go through the motions of search engine optimization when you find a spare hour on Sunday, but you live exactly like your non-marketing competitors the rest of the month. We convince ourselves that we have time, that we can rank later, and that users will magically find our landing page.

But the truth is much more urgent. Your runway is not guaranteed. Your startup's life is leased, not owned.

If you want to survive as a solo founder or a small team, you cannot afford to sit on the fence. You need an automated content calendar that keeps your site active while you write code and fix bugs.

For solo founders, managing content ops for indie hackers is a grueling cycle. You open a spreadsheet, type in some seed ideas, and try to guess what your users search for. Then you spend hours mapping those keywords to topics. By the time you need to write, your energy is gone.

I refused to accept this manual grind. I needed an automated seo content pipeline that could handle the research, organization, and execution without requiring my constant attention. But when I first tried using basic LLM prompts to build an automated content calendar, the system broke.

Here is how we solved the technical hurdles of automated keyword mapping using structured LLM outputs, and how you can build the same system.

The technical bottleneck of unstructured AI planning

If you ask a standard chat model to generate thirty SEO keywords and map them to a monthly schedule, you get a beautiful wall of text. It looks great to the human eye, but it is impossible for an automated system to parse.

If you try to parse this output using regular expressions or loose JSON parsers, your pipeline will fail. The model might change the key names, return markdown code blocks inside the string, or omit critical parameters.

This is where structured outputs become essential. By passing a strict JSON schema to our LLM, we force the model to return data in an exact, predictable shape.

During the development of our gemini ai content generation pipeline, I ran into a massive technical constraint: output token limits.

When I first requested a full thirty-day map in a single API call, the model regularly ran out of output tokens midway through the twenty-fifth item. This resulted in truncated, invalid JSON that crashed our database parser. If I lowered the request to ten items to avoid the token limit, the model lost context between calls and started repeating keywords it had already generated in previous batches.

To solve this, we decoupled the architecture. Instead of generating thirty detailed posts at once, we built a three-stage generator:

  1. The Core Cluster Map: We ask the model to generate five core topical clusters based on a single seed niche.
  2. The Keyword Expansion: For each cluster, we run parallel, schema-constrained API calls to generate six highly specific target keywords. This keeps the token usage low per call.
  3. The Calendar Compilation: We merge the validated JSON payloads back into a single structured calendar payload.

This architecture ensures we never hit token exhaustion, and our JSON payloads remain perfectly valid every single time.

Designing the pipeline for an automated content calendar

To build a reliable system, you must define your data structures using a validation library like Pydantic. This acts as the source of truth for your API.

Here is the exact Pydantic schema we use to enforce structured outputs for our keywords and scheduling pipeline:

from pydantic import BaseModel, Field
from typing import List

class KeywordMetadata(BaseModel):
    keyword: str = Field(description="The exact target search query.")
    search_intent: str = Field(description="Informational, transactional, or navigational.")
    estimated_difficulty: str = Field(description="Low, Medium, or High difficulty based on niche competition.")

class ContentPost(BaseModel):
    day: int = Field(description="The scheduled day for this content, from 1 to 30.")
    title: str = Field(description="An SEO-optimized, highly engaging blog post title.")
    primary_keyword: KeywordMetadata
    secondary_keywords: List[str] = Field(description="A list of 3 to 5 related secondary keywords to include.")
    outline: List[str] = Field(description="The logical H2 and H3 structure for the post.")

class AutomatedCalendar(BaseModel):
    niche: str = Field(description="The core market vertical of the SaaS or website.")
    posts: List[ContentPost]
Enter fullscreen mode Exit fullscreen mode

When you pass this schema to an API that supports structured outputs, you guarantee that your database receives clean, structured JSON. The days of writing complex regular expressions to clean up LLM outputs are over.

Once the structured data is validated, your system can store the entire plan in your database. You now have a blueprint for an entire month of highly targeted marketing.

Turning raw keywords into structured articles

With your validated calendar in hand, you can transition from planning to execution. This is where an ai blog writer for saas becomes incredibly powerful.

Because your calendar schema already contains the primary keyword, secondary keywords, and a logical outline, the generation step is straightforward. You do not pass a vague prompt to the writing model. Instead, you feed it the specific parameters generated during your planning phase.

We run a daily cron job that checks our database for the scheduled post of the day. The system extracts the specific outline, feeds it to our writing pipeline, and generates a comprehensive, deep-dive article.

But generating the text is only half the battle. If your articles sit in a database or a raw markdown file, your traffic remains at zero.

I did not want to log in to my admin dashboard every single morning to copy, paste, format, upload images, and hit publish. I wanted a wordpress ai autopilot experience, but for every content platform I used.

I ended up automating this with a small Cloud Functions pipeline I built called SleepPublish. It is an AI content engine that researches keywords, plans a 30-day content calendar, generates SEO-optimized articles with Gemini, and auto-publishes them to WordPress, Ghost, Webflow, Notion, Wix, Shopify, Dev.to, and other CMS destinations.

Whether you write your own webhooks or use an external integration, the objective is the same: eliminate the human friction between content generation and publication.

Why your startup needs an automated content calendar today

You cannot build a sustainable business by writing articles only when inspiration strikes. Consistency is the primary metric search engine crawlers respect. If you publish three articles this week and then go silent for three months, your domain authority will flatline.

Your competitors are not waiting. They are building, shipping, and publishing every single day. While you are debating whether you have the time to write a technical blog post, their automated systems are capturing your search traffic.

Using ai content automation is not about spamming the web with low-quality, generic filler. It is about taking the deep domain knowledge in your head, structuring it efficiently, and distributing it to the people who are actively searching for your product. It is about using an ai seo tool for startups to handle the mechanical distribution so you can focus on building a better product.

Stop sitting on the fence. Stop convincing yourself that you will have more time to handle your content marketing next quarter.

By setting up an automated content calendar, you transition from a box-checking founder to a systematic engine. The search terms are waiting, the traffic is there for the taking, and the system is ready to build.

The choice is yours: keep ignoring your marketing and hope for a miracle, or build a system that works for you while you sleep.

Try SleepPublish free for 7 days, it plans, writes, and publishes SEO content straight to your CMS: https://sleeppublish.mactrixxr.space

Top comments (0)