We are going to build a command-line content generator that turns a one-line topic into a publish-ready blog draft. The pipeline uses an LLM to build an outline, write the body, and run a light editing pass. If you are a developer, founder, or technical writer who wants to automate first drafts, this tool will save you time.
What you'll need
- Python 3.10 or newer
- The OpenAI SDK:
pip install openai - An Oxlo.ai API key from https://portal.oxlo.ai
I am running this on Oxlo.ai because its request-based pricing keeps costs predictable even when I feed long outlines or previous drafts back into the context. You can compare plans at https://oxlo.ai/pricing.
Step 1: Set up the Oxlo.ai client
First, I create a small helper that talks to Oxlo.ai through the OpenAI-compatible endpoint. I will use llama-3.3-70b as the general-purpose workhorse.
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key=os.environ.get("OXLO_API_KEY")
)
def chat(system: str, user: str, model: str = "llama-3.3-70b") -> str:
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": system},
{"role": "user", "content": user},
],
)
return response.choices[0].message.content
Step 2: Define the system prompt
This system prompt sets the persona and rules for every stage of the pipeline. Keeping it in one constant makes the behavior easy to tweak.
SYSTEM_PROMPT = """You are a senior technical writer and content strategist.
Your goal is to turn a rough topic into a polished, publish-ready blog post.
You write in short paragraphs, use concrete examples, and avoid filler.
Follow the user's exact instruction for each step. Do not add meta commentary."""
Step 3: Generate an outline
Before writing prose, I ask the model to structure the post. A tight user instruction keeps the output predictable.
def generate_outline(topic: str, audience: str) -> str:
user_message = (
f"Create a four-section outline for a blog post about '{topic}' "
f"targeted at {audience}. Each section needs a title and one sentence "
f"describing what it covers. Return only the outline."
)
return chat(SYSTEM_PROMPT, user_message)
Step 4: Write the first draft
Next, I feed the outline back into the model as context and ask for a full draft in a friendly, technical tone.
def generate_draft(outline: str, topic: str) -> str:
user_message = (
f"Write the complete body of a blog post about '{topic}' using the "
f"following outline. Write in a friendly, technical tone. Use markdown "
f"headers for each section. Return only the article body.\n\n{outline}"
)
return chat(SYSTEM_PROMPT, user_message)
Step 5: Refine and polish
I run one more pass to tighten wording and catch repetition. Because Oxlo.ai charges per request, not per token, sending the entire draft back for editing does not inflate the cost.
def refine_draft(draft: str) -> str:
user_message = (
"Edit the draft below for clarity, flow, and grammar. Remove filler "
"words and fix awkward phrasing. Preserve all technical details. "
"Return only the revised article.\n\n" + draft
)
return chat(SYSTEM_PROMPT, user_message)
Step 6: Wire the pipeline together
Now I connect the three stages so a single function call goes from topic to polished draft.
def write_post(topic: str, audience: str) -> str:
print("Step 1: Outlining...")
outline = generate_outline(topic, audience)
print(outline)
print("\nStep 2: Drafting...")
draft = generate_draft(outline, topic)
print(draft)
print("\nStep 3: Refining...")
final = refine_draft(draft)
return final
if __name__ == "__main__":
if not os.environ.get("OXLO_API_KEY"):
raise SystemExit("Set the OXLO_API_KEY environment variable first.")
article = write_post(
topic="The Role of LLM in Content Generation",
audience="software engineers new to AI"
)
print("\n=== FINAL ARTICLE ===\n")
print(article)
Run it
Save the script as content_gen.py, export your key, and run it.
export OXLO_API_KEY="YOUR_OXLO_API_KEY"
python content_gen.py
Example output after the refinement stage:
Step 1: Outlining...
1. Introduction - Define what LLMs are and why content teams use them.
2. Core Mechanics - A plain-language look at next-token prediction.
3. Real-World Use Cases - Documentation, code comments, and marketing copy.
4. Best Practices - Fact checking, tone control, and human review.
Step 2: Drafting...
## Introduction
Large language models have become the default starting point for many technical writing teams...
Step 3: Refining...
## Introduction
Large language models are now the default starting point for many technical writing teams...
=== FINAL ARTICLE ===
## Introduction
Large language models are now the default starting point for many technical writing teams...
Wrap-up
This three-step pattern, outline then draft then edit, keeps the model on task and gives you review checkpoints. Two concrete next steps: feed the final output into a Markdown-to-HTML converter to publish it straight to your blog, or swap llama-3.3-70b for kimi-k2.6 on Oxlo.ai when you need deeper reasoning for long-form technical reports.
Top comments (0)