DEV Community

shashank ms
shashank ms

Posted on

The Role of LLM in Content Generation

We are going to build a Multi-Format Content Agent that turns a raw topic into a structured blog outline, a social thread, and a newsletter blurb in a single call. This is for marketing teams and developer advocates who need consistent drafts without jumping between tools. By running it on Oxlo.ai, we get flat per-request pricing and zero cold starts on models like Llama 3.3 70B.

What you'll need

Step 1: Configure the Oxlo.ai client

I start every project by pinning the client to Oxlo.ai. Because the platform is fully OpenAI compatible, the import stays standard and only the base_url changes. I am using Llama 3.3 70B here because it follows long formatting instructions reliably.

from openai import OpenAI
import os

client = OpenAI(
    base_url="https://api.oxlo.ai/v1",
    api_key=os.environ.get("OXLO_API_KEY")
)

MODEL = "llama-3.3-70b"

Step 2: Lock in the system prompt

The system prompt is the agent's job description. It sets the voice, enforces structure, and demands JSON output so we do not have to regex-parse prose later.

SYSTEM_PROMPT = """You are a senior content strategist. When given a topic, produce three assets and return them as a single JSON object.

Keys:
- blog_outline: array of objects with "title" and "summary"
- social_thread: array of 2 to 4 short posts under 280 characters each
- newsletter_blurb: one paragraph under 100 words

Tone: direct, technical, developer-first. Output ONLY valid JSON."""

Step 3: Write the generation function

We wrap the API call in a small function. I set response_format to JSON mode so the model is constrained to valid output. This keeps the parsing logic trivial.

import json

def generate_content(topic: str) -> dict:
    response = client.chat.completions.create(
        model=MODEL,
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": f"Topic: {topic}"},
        ],
        response_format={"type": "json_object"},
    )
    raw = response.choices[0].message.content
    return json.loads(raw)

Step 4: Render the results

Parsing JSON is not enough. We want a clean terminal report so the team can scan the outputs before copying them into a CMS.

def print_assets(assets: dict):
    print("=== BLOG OUTLINE ===")
    for item in assets.get("blog_outline", []):
        print(f"- {item['title']}: {item['summary']}")

    print("\n=== SOCIAL THREAD ===")
    for i, post in enumerate(assets.get("social_thread", []), 1):
        print(f"{i}. {post}")

    print("\n=== NEWSLETTER BLURB ===")
    print(assets.get("newsletter_blurb", "N/A"))

Step 5: Wire up the CLI

I use a simple input loop so we can test topics quickly without rewriting code. In production you would swap this for a FastAPI route or a CI trigger.

if __name__ == "__main__":
    import sys

    topic = sys.argv[1] if len(sys.argv) > 1 else "LLM inference pricing models"
    print(f"Generating content for: {topic}\n")
    
    assets = generate_content(topic)
    print_assets(assets)

Run it

Save the complete script as content_agent.py, export your key, and run it.

$ export OXLO_API_KEY="sk-oxlo.ai-..."
$ python content_agent.py "agentic AI workflows"

Generating content for: agentic AI workflows

=== BLOG OUTLINE ===
- Introduction: Define agentic AI and contrast it with single-turn chatbots.
- Architecture Patterns: Compare ReAct, Reflexion, and multi-agent orchestration.
- Tool Use: How LLMs call external APIs to ground decisions in live data.
- Evaluation: Metrics that matter when agents run unsupervised.
- Conclusion: Where flat inference pricing changes the economics of long agent loops.

=== SOCIAL THREAD ===
1. Single-turn chatbots answer questions. Agentic AI systems finish tasks. Here is how they differ.
2. The best agents do not just reason. They loop, reflect, and call tools until the job is done.
3. If your inference bill scales with tokens, long agent loops get expensive fast. Flat per-request pricing fixes that.

=== NEWSLETTER BLURB ===
Agentic AI is moving from demo to production. This week we cover the architecture patterns that make autonomous loops reliable, and why pricing models matter when your agent runs ten tool calls per task.

Next steps

Two concrete ways to extend this agent.

  • Add a refinement loop. Feed the generated outline back to the model with a critique prompt, then merge the improvements. Because Oxlo.ai charges per request, not per token, running a second critique pass on a long outline costs the same as a short ping.
  • Swap models by task. Use Qwen 3 32B for multilingual campaigns, or Kimi K2.6 when you need to generate alt text from screenshot inputs. Both are available on the same Oxlo.ai endpoint with no code changes beyond the model string.

Top comments (0)