Case study — AI Cost Optimization
Local content
pipeline.
A content pipeline that drafts blog posts for three niche sites on a local model, with a fact-checking gate and quality gates before anything is published. About one post a week across the three sites.
- Cadence
- About one post a week across three sites
- Cost
- No per-draft API cost
- Stack
- llama.cpp (local LLM) / Bash / Cloudflare Pages / Astro / Custom analysis patterns
01 — The problem
Paying per article.
I run three niche content sites. Each needs well-researched, search-friendly posts. The default playbook — pay a cloud API per article, or pay a content agency per post — has a per-article cost and two unpleasant side effects:
- Every prompt and every draft passes through a cloud provider with terms of service that change quarterly.
- Cloud-generated content tends to converge on the same patterns, hurting differentiation.
I wanted local control: my prompts, my fact-checks, my editorial voice — and no per-article API cost.
02 — The solution
Scripts and a local model.
The pipeline is a small set of scripts driving a self-hosted llama.cpp server. Each run does:
- 01
Topic selection
A topic queue script proposes candidates from search-trend data, recent news in the niche, and what the sites already rank for. The model picks the highest-leverage topic.
- 02
Outline + draft
A two-pass generation: first an outline with H2/H3 sections + key claims; second a full draft tracked against the outline.
- 03
Fact-checking gate
A "perishable facts audit" script flags claims that have an expiration date — tax credit percentages, year-specific deadlines, legislation references, pricing — so they can be verified before publishing. (This was added after a real incident where the model cited an out-of-date tax-credit rate.)
- 04
Quality gate
Reusable analysis patterns (extract-wisdom, analyze-claims, review-writing) score the draft. Below threshold → reject + retry.
- 05
Deploy
Astro builds the site and it is published to Cloudflare Pages.
03 — The patterns
The 14 reusable analysis patterns.
The pipeline shares a library of 14 reusable analysis patterns — small Markdown prompts that turn the local model into specialized roles: extract_wisdom, analyze_claims, review_code, improve_writing, threat_model, summarize_paper, etc. Each pattern is one file, one role, well-tested. A new content site doesn't require a new model — it requires one new prompt that wires the existing patterns into a fresh editorial voice.
04 — Results
What was built.
Cost
No per-article API cost: drafting runs on hardware that is already there.
Cadence
About one post a week across three sites.
Gates
A perishable-fact audit and scored analysis patterns sit between the draft and the publish step.
Privacy
Drafts, source notes and prompts stay on the local network.
Failures
Failures are logged, retried once, and sent to a human review queue if the retry also fails.
05 — What surprised me
Lessons from the build.
A local model can draft long-form content; verification is the hard part.
Where the gap to a frontier model matters most — accuracy on perishable claims — a better model does not fix it. A verification gate does.
Quality gates are doing more work than the model.
The win isn't "the model writes great posts." It's "the model drafts a post, and reusable patterns check it for clarity, factual risk, and SEO before it ships." The gate is the IP.
SEO discipline beats prompt engineering.
An OK post on a topic with real search demand outperforms a brilliant post on a topic nobody searches for. Half the pipeline's effectiveness is the topic-selection script, not the writing.
06 — What I'd build for you
The same pipeline, your voice.
If you're a marketing team, agency, or solo operator publishing more than ~4 long-form articles a week and paying cloud APIs (or freelancers) per article, a local pipeline is worth pricing out. I can build:
- Local LLM inference setup tuned to your hardware.
- Custom topic-selection scripts wired to your SEO tooling (GSC, Ahrefs, etc.).
- Fact-checking gates calibrated to your niche (legal, financial, health all need different perishable-fact patterns).
- Deploy automation to your existing publishing platform (WordPress, Ghost, Astro, custom CMS).
- A library of analysis patterns for your editorial voice.
Typical engagement: $5K-$15K for setup + a runbook your team can extend. Optionally retainer for ongoing prompt tuning and pattern additions as your editorial needs grow.