DEV Community

shashank ms
shashank ms

Posted on

LLM-Powered Language Generation Apps: A Beginner's Guide

We are going to build a command-line marketing copy generator that turns rough product notes into a tweet, an email subject line, and a short product description. It is a practical first project if you are learning how to integrate LLMs into real applications, and we will run it entirely on Oxlo.ai.

What you'll need

Before we start, make sure you have the following:

  • Python 3.10 or newer installed on your machine
  • An Oxlo.ai API key from https://portal.oxlo.ai
  • The OpenAI SDK installed: pip install openai

Step 1: Create the system prompt

The system prompt is the only logic in a language generation app. It tells the model what formats to return and what voice to use. I keep mine in a separate variable so I can tweak it without touching the request code.

SYSTEM_PROMPT = """You are a marketing copywriter. The user will paste rough product notes. Generate exactly three outputs:

1. A tweet under 280 characters.
2. An email subject line under 60 characters.
3. A one-paragraph product description under 100 words.

Use a professional but friendly tone. Separate each output with a single blank line. Do not add markdown headers or bullet points."""

Step 2: Initialize the Oxlo.ai client

Oxlo.ai exposes an OpenAI-compatible API, so I can use the official SDK and only change the base URL and model name. I use Llama 3.3 70B because it follows instruction formatting reliably. Because Oxlo.ai uses flat per-request pricing, the cost of running this generator does not climb when I paste in long product specs. See https://oxlo.ai/pricing for plan details.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.oxlo.ai/v1",
    api_key="YOUR_OXLO_API_KEY"
)

Step 3: Build the generator function

I wrap the API call in a small function so the rest of my script does not need to know about LLM internals. The function takes raw notes, injects them as a user message, and returns the generated text.

def generate_copy(product_notes: str) -> str:
    response = client.chat.completions.create(
        model="llama-3.3-70b",
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": product_notes},
        ],
        temperature=0.7,
        max_tokens=500,
    )
    return response.choices[0].message.content

Step 4: Add a CLI wrapper

To make this feel like an app, I add a small argparse CLI so I can run it from the terminal and optionally save the output to a file.

import argparse

def main():
    parser = argparse.ArgumentParser(
        description="Generate marketing copy from product notes."
    )
    parser.add_argument("notes", help="Raw product notes or description")
    parser.add_argument("--out", "-o", help="Optional file to write output to")
    args = parser.parse_args()

    print("Generating copy via Oxlo.ai...")
    copy = generate_copy(args.notes)

    print("\n--- Generated Copy ---\n")
    print(copy)

    if args.out:
        with open(args.out, "w", encoding="utf-8") as f:
            f.write(copy)
        print(f"\nSaved to {args.out}")

if __name__ == "__main__":
    main()

Run it

Save the full script as copygen.py, then run it with sample product notes.

python copygen.py "Wireless mechanical keyboard. 75% layout. Hot-swappable switches. RGB backlight. 4000mAh battery lasts 200 hours. Bluetooth 5.1 and USB-C."

Example output:

Generating copy via Oxlo.ai...

--- Generated Copy ---

Type freely for 200 hours. Our wireless mechanical keyboard packs hot-swappable switches, RGB backlighting, and dual connectivity into a compact 75% layout.

200-Hour Wireless Mechanical Keyboard

Cut the cord without cutting corners. This 75% wireless board delivers 200 hours of battery life, hot-swap switch support, and Bluetooth 5.1 plus USB-C connectivity.

Next steps

From here, you can treat the generated copy as a draft and add a rewrite command. Pass the output back to the model with a follow-up instruction like "make the tweet more casual" or "shorten the product description."

Another concrete upgrade is to read product notes from a CSV file and write the generated copy into a new column. This turns the script into a bulk content pipeline that can process an entire product catalog in one run.

Top comments (0)