AI

Building an AI Blog Outline Generator: Structured JSON and Prompt Chaining

DD
Ankur Ishwar
9 min read Updated Sep 7, 2026
Building an AI Blog Outline Generator using Structured Outputs

If you ask an off-the-shelf LLM to "generate a blog outline about building web APIs", it hands you the exact same boilerplate slop every single time:

  1. Introduction (What is an API?)
  2. Benefits of APIs
  3. How to Build an API (Step 1, Step 2, Step 3)
  4. Challenges of APIs
  5. Conclusion

No software engineer or thoughtful reader wants to read that article. It has zero narrative tension, zero technical depth, and zero opinionated perspective.

When we built internal content generation tools for Dropout Developer, we quickly realized that the outline is the single most critical step in the pipeline. If your outline is generic, the resulting article will be unreadable. But if your outline enforces technical specifics, code snippet requirements, and contrarian insights, the final content delivers genuine value. To see the larger picture of pipeline architecture, check our guide on architecting AI content generation systems.

Why Raw Prompting Fails for Outlines

Large Language Models are probabilistic next-token predictors. When prompted loosely with unstructured natural language, they gravitate toward the statistical average of internet text. For blog posts, that statistical average is lazy marketing listicles from 2018.

To produce technical outlines that resemble senior engineering articles, your application must solve three specific problems:

  • Schema Enforcement: The model must return valid, typed JSON matching an exact tree structure, not markdown paragraphs with broken asterisks.
  • Constraint Injection: The outline prompt must explicitly ban clichés, mandate code block requirements, and specify exact heading depths.
  • Two-Pass Critique: Pass 1 generates initial topics; Pass 2 audits the outline to prune redundant fluff and verify logical progression.

Defining the Outline Schema with TypeScript and Zod

In modern web applications, never parse raw string responses with regex. Define a strict schema using Zod and use OpenAI or Anthropic structured JSON outputs:

import { z } from 'zod';

// Define a single section within the article
export const OutlineSectionSchema = z.object({
  heading: z.string().describe('Descriptive H2 title avoiding buzzwords'),
  technicalHook: z.string().describe('The concrete real-world problem or error solved in this section'),
  estimatedWordCount: z.number().int().min(150).max(600),
  requiresCodeExample: z.boolean(),
  codeLanguage: z.enum(['typescript', 'python', 'sql', 'bash', 'none']),
  keyTakeaways: z.array(z.string()).min(2).max(4)
});

// Define the complete blog outline blueprint
export const BlogOutlineSchema = z.object({
  title: z.string().describe('Clear, click-worthy title without clickbait punctuation'),
  targetAudience: z.string().describe('Exact developer persona, e.g., Junior Backend Engineer'),
  primaryThesis: z.string().describe('The non-obvious argument the post makes'),
  targetTotalWords: z.number().int().min(1200).max(3000),
  sections: z.array(OutlineSectionSchema).min(4).max(8)
});

export type BlogOutline = z.infer<typeof BlogOutlineSchema>;

By enforcing this schema, your backend guarantees that every section has a clear technical hook, an estimated token budget, and an explicit flag declaring whether a code example is required.

Building the Node.js Outline Generation Service

Here is a complete, production-ready implementation using the official OpenAI SDK with strict JSON schema output:

import OpenAI from 'openai';
import { zodResponseFormat } from 'openai/helpers/zod';
import { BlogOutlineSchema, BlogOutline } from './schema';

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

export async function generateTechnicalOutline(topic: string, angle: string): Promise<BlogOutline> {
  const systemPrompt = `
You are a Principal Software Engineer designing an outline for a deep technical blog post.
Rules:
1. BANNED PATTERNS: Do not use AI filler vocabulary, flowery adjectives, or clichéd transitions.
2. NO FLUFF: Skip generic introductory sections like 'What is X?' unless explaining novel internal mechanics.
3. GROUND IN CODE: Ensure at least three sections require concrete code examples (TypeScript, SQL, or Python).
4. AUDIENCE: Target self-taught engineers and junior developers escaping tutorial hell.
`;

  const response = await client.beta.chat.completions.parse({
    model: 'gpt-4o',
    messages: [
      { role: 'system', content: systemPrompt },
      { role: 'user', content: `Create an outline for: "${topic}". Angle: "${angle}".` }
    ],
    response_format: zodResponseFormat(BlogOutlineSchema, 'blog_outline'),
    temperature: 0.3,
  });

  const outline = response.choices[0].message.parsed;
  if (!outline) {
    throw new Error('Failed to parse structured outline from model response.');
  }

  return outline;
}

Notice setting temperature: 0.3. While high temperature (0.8+) is good for creative brainstorming, outline generation demands architectural consistency and adherence to schema constraints.

The Multi-Pass Architecture: Outline Refinement

One generation pass is rarely enough for high-stakes technical writing. The secret to high quality is a second Auditing Pass:

┌───────────────────────────────────────────┐
│ Pass 1: Raw Topic & Audience              │
│ Generates candidate outline via JSON mode │
└─────────────────────┬─────────────────────┘
                      │
                      ▼
┌───────────────────────────────────────────┐
│ Pass 2: Critical Auditor Model            │
│ Checks: Is it generic? Are headings flat? │
│ Rewrites weak sections with concrete hooks│
└─────────────────────┬─────────────────────┘
                      │
                      ▼
┌───────────────────────────────────────────┐
│ Validated Outline Stored in DB            │
│ Ready for parallel section expansion      │
└───────────────────────────────────────────┘

In the auditor pass, you ask the model: "Which of these sections could have been written by someone with zero hands-on experience? Replace them with sections that discuss real production trade-offs, configuration gotchas, or latency numbers."

Cost and Performance Optimization

Running an outline generator in production should cost less than a few paise per request:

  • Cache Common Topics: Hash user input prompts with SHA-256 and store generated outlines in a Redis cache with a 48-hour TTL. If two users request an outline on "Docker multi-stage builds", serve the cached blueprint.
  • Self-Hosted Alternative: If you do not want to pay commercial API rates, you can run an open-weights model like Qwen 2.5 Coder or Llama 3.3 locally using vLLM or Ollama. Check out our step-by-step tutorial on self-hosting private LLMs on your own server.
  • Benchmark Quality: Compare how different models handle structured output without schema deviations: see our analysis of AI model benchmarks and developer workflows.

Stop accepting five-point generic summaries. Build your outline generator with strict schema validation, enforce real coding requirements, and build tools that produce genuinely insightful content.

Found this useful?
View all articles

Keep Reading

Related Articles

Learn with Dropout Developer

Build real software with AI

Step-by-step learning paths, vibe coding tutorials, and certified developer programs designed for the modern engineer.