We are going to build a marketing content generator that turns a single product description into a blog intro, a tweet, and an email subject line. This is useful for solo founders and small teams who need campaign copy without hiring a writer. You will end up with a small Python script you can run from the terminal.
What you'll need
- Python 3.10 or newer
- An Oxlo.ai API key from https://portal.oxlo.ai
- The OpenAI SDK:
pip install openai
Step 1: Set up the client
First, I import the OpenAI SDK and point it at Oxlo.ai. I use llama-3.3-70b here because it handles general-purpose writing tasks reliably.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Say hello."},
],
)
print(response.choices[0].message.content)
Step 2: Define the system prompt
I want the model to return three specific pieces of content in a predictable format. The system prompt enforces that structure so I can parse the result with simple string splitting.
SYSTEM_PROMPT = """You are a marketing copywriter.
Given a product description, write exactly three items:
1. A blog post introduction (2 to 3 sentences)
2. A Twitter post under 280 characters
3. An email subject line under 60 characters
Format your response exactly like this:
BLOG:
<blog text>
TWEET:
<tweet text>
SUBJECT:
<subject line>
"""
Step 3: Build the generator function
Next, I wrap the API call in a function called generate_campaign. It takes a product description, sends it to Oxlo.ai, and returns the raw text.
def generate_campaign(product_description: str) -> str:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": product_description},
],
temperature=0.7,
max_tokens=500,
)
return response.choices[0].message.content
Step 4: Parse and display the output
The model returns a block of text, so I split it on the section headers to isolate each piece of copy. I print them with clear labels.
def parse_campaign(text: str) -> dict:
lines = text.strip().splitlines()
sections = {"BLOG": [], "TWEET": [], "SUBJECT": []}
current = None
for line in lines:
if line.startswith("BLOG:"):
current = "BLOG"
continue
elif line.startswith("TWEET:"):
current = "TWEET"
continue
elif line.startswith("SUBJECT:"):
current = "SUBJECT"
continue
if current and line.strip():
sections[current].append(line.strip())
return {
"blog": " ".join(sections["BLOG"]),
"tweet": " ".join(sections["TWEET"]),
"subject": " ".join(sections["SUBJECT"]),
}
def print_campaign(parts: dict):
print("Blog Intro:")
print(parts["blog"])
print()
print("Tweet:")
print(parts["tweet"])
print()
print("Email Subject:")
print(parts["subject"])
Step 5: Run the pipeline
Now I put it together. I define a product description and call the functions in sequence. Because Oxlo.ai charges per request, not per token, running this long prompt costs the same flat rate regardless of how verbose the product description is. See https://oxlo.ai/pricing for current plan details.
if __name__ == "__main__":
product = (
"Oxlo.ai is a developer-first AI inference platform with flat per-request pricing. "
"Unlike token-based providers, cost does not scale with prompt length, "
"so it is significantly cheaper for long-context and agentic workloads. "
"It offers 45+ models, full OpenAI SDK compatibility, and no cold starts."
)
raw = generate_campaign(product)
campaign = parse_campaign(raw)
print_campaign(campaign)
Run it
Save the full script as campaign_generator.py, export your key, and run it.
export OXLO_API_KEY="sk-oxlo.ai-..."
python campaign_generator.py
When I ran this against llama-3.3-70b on Oxlo.ai, I got output similar to this:
Blog Intro:
Oxlo.ai flips the script on AI infrastructure pricing. Instead of watching tokens burn through your budget, you pay one flat rate per request, no matter how complex the prompt. For teams running long-context RAG or multi-step agents, that predictability is a game changer.
Tweet:
Stop counting tokens. Start shipping. Oxlo.ai offers flat per-request pricing for 45+ open-source LLMs, full OpenAI SDK compatibility, and zero cold starts.
Email Subject:
Flat pricing for LLM inference is here
If you prefer multilingual output, swap the model to qwen-3-32b or kimi-k2.6 in the generate_campaign function. Both handle non-English generation well.
Next steps
Replace the string parser with Oxlo.ai JSON mode so the model returns valid JSON instead of custom markers. You could also wrap this script in a FastAPI endpoint and connect it to your CMS so content generation happens inside your existing publishing flow.
Top comments (0)