We are going to build a multilingual marketing copy generator that turns a product name and a few keywords into polished descriptions and ad headlines. This tool is useful for e-commerce teams and content marketers who need to scale copy across languages without ballooning token costs. Because Oxlo.ai charges a flat rate per request instead of per token, you can stuff detailed instructions and examples into the system prompt and still pay the same price on every call.
What you'll need
Before starting, grab the following:
- Python 3.10 or newer
- An Oxlo.ai API key from https://portal.oxlo.ai
- The OpenAI SDK:
pip install openai
Step 1: Configure the Oxlo.ai client
I use the OpenAI SDK as a drop-in client. Point base_url to Oxlo.ai and pick Llama 3.3 70B for reliable creative writing in English and Spanish.
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key=os.environ.get("OXLO_API_KEY")
)
# Verify connectivity
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Say OK"}],
max_tokens=10
)
print(response.choices[0].message.content)
Step 2: Lock behavior with a system prompt
A strict system prompt forces JSON output and keeps headlines under 60 characters. Storing it as a module constant makes it easy to tweak later.
SYSTEM_PROMPT = """You are a senior copywriter. You write product descriptions and ad headlines.
Rules:
- Write exactly 2 headlines and 1 description.
- Headlines must be under 60 characters.
- Descriptions must be under 200 characters.
- Match the requested tone and audience.
- Respond in JSON format with keys: headlines (list), description (string).
If the user requests a language other than English, write in that language."""
Step 3: Build the core generation function
The function formats the user message, calls Oxlo.ai with JSON mode enabled, and returns a parsed dict. I set temperature to 0.8 so the copy stays creative but does not hallucinate extra fields.
import json
def generate_copy(product, keywords, tone, audience, language="English"):
user_msg = (
f"Product: {product}\n"
f"Keywords: {', '.join(keywords)}\n"
f"Tone: {tone}\n"
f"Audience: {audience}\n"
f"Language: {language}"
)
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_msg},
],
response_format={"type": "json_object"},
temperature=0.8,
)
return json.loads(response.choices[0].message.content)
# Quick smoke test
print(generate_copy(
product="TrailRunner X1",
keywords=["waterproof", "lightweight", "trail running"],
tone="Energetic",
audience="Trail runners aged 25-40",
language="English"
))
Step 4: Generate multilingual variants
Running the generator for several languages is just a loop. Because Oxlo.ai uses request-based pricing, the cost stays flat even when the system prompt and product context grow long. See https://oxlo.ai/pricing for current plan details.
def generate_multilingual_variants(product, keywords, tone, audience, languages):
variants = {}
for lang in languages:
variants[lang] = generate_copy(product, keywords, tone, audience, lang)
return variants
results = generate_multilingual_variants(
product="TrailRunner X1",
keywords=["waterproof", "lightweight", "trail running"],
tone="Energetic",
audience="Trail runners aged 25-40",
languages=["English", "Spanish"]
)
print(json.dumps(results, indent=2, ensure_ascii=False))
Step 5: Wrap it in a CLI
Finally, I add argparse so the team can run this from a terminal without editing code.
import argparse
def main():
parser = argparse.ArgumentParser(description="Generate marketing copy via Oxlo.ai")
parser.add_argument("--product", required=True)
parser.add_argument("--keywords", required=True)
parser.add_argument("--tone", default="Professional")
parser.add_argument("--audience", default="General consumers")
parser.add_argument("--languages", nargs="+", default=["English"])
args = parser.parse_args()
keywords = [k.strip() for k in args.keywords.split(",")]
output = generate_multilingual_variants(
args.product, keywords, args.tone, args.audience, args.languages
)
print(json.dumps(output, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()
Run it
Save everything to copy_generator.py, export your key, and pass in a product.
export OXLO_API_KEY="YOUR_OXLO_API_KEY"
python copy_generator.py \
--product "TrailRunner X1" \
--keywords "waterproof, lightweight, trail running" \
--tone "Energetic" \
--audience "Trail runners aged 25-40" \
--languages English Spanish
Expected output:
{
"English": {
"headlines": [
"Run Light. Stay Dry.",
"TrailRunner X1: Waterproof Freedom"
],
"description": "The TrailRunner X1 is a waterproof, lightweight shoe built for serious trail runners who refuse to let weather slow them down."
},
"Spanish": {
"headlines": [
"Corre ligero. Mantente seco.",
"TrailRunner X1: libertad impermeable"
],
"description": "El TrailRunner X1 es un zapato impermeable y ligero diseñado para corredores de montaña que no dejan que el clima les frene."
}
}
Wrap up
You now have a working copy generator that runs on Oxlo.ai. Two concrete next steps: wire the script into a CMS webhook so new product listings trigger copy generation automatically, or add an A/B test logger that records which headline variant drives the highest click-through rate.
Top comments (0)