How to beginner · 3 min read

How to generate product descriptions with AI

Quick answer
Use a large language model like gpt-4o via the OpenAI SDK to generate product descriptions by providing product details as prompts. This approach automates content creation, improving ecommerce listings efficiently.

PREREQUISITES

  • Python 3.8+
  • OpenAI API key (free tier works)
  • pip install openai>=1.0

Setup

Install the openai Python package and set your API key as an environment variable for secure access.

bash
pip install openai>=1.0
output
Collecting openai
  Downloading openai-1.x.x-py3-none-any.whl
Installing collected packages: openai
Successfully installed openai-1.x.x

Step by step

Use the OpenAI SDK to call the gpt-4o model with a prompt describing the product features. The model returns a creative product description.

python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

product_info = "Smartwatch with heart rate monitor, GPS, and 7-day battery life"

prompt = f"Write a compelling product description for: {product_info}."

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": prompt}]
)

print("Generated product description:\n", response.choices[0].message.content)
output
Generated product description:
Experience the ultimate in wearable technology with our Smartwatch featuring a heart rate monitor, built-in GPS, and an impressive 7-day battery life. Stay connected and track your fitness effortlessly with style and precision.

Common variations

You can generate descriptions asynchronously, use streaming for real-time output, or switch to other models like gpt-4o-mini for faster, cost-effective results.

python
import asyncio
import os
from openai import OpenAI

async def generate_description():
    client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
    product_info = "Wireless earbuds with noise cancellation and 24-hour battery"
    prompt = f"Create a catchy product description for: {product_info}."

    stream = await client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": prompt}],
        stream=True
    )

    description = ""
    async for chunk in stream:
        description += chunk.choices[0].delta.content or ""
        print(chunk.choices[0].delta.content or "", end="", flush=True)

asyncio.run(generate_description())
output
Create a catchy product description for: Wireless earbuds with noise cancellation and 24-hour battery.

Wireless earbuds deliver crystal-clear sound with active noise cancellation and an all-day 24-hour battery life, perfect for music lovers on the go.

Troubleshooting

  • If you get authentication errors, verify your OPENAI_API_KEY environment variable is set correctly.
  • If responses are too generic, provide more detailed product info in the prompt.
  • For rate limits, consider using smaller models like gpt-4o-mini or batching requests.

Key Takeaways

  • Use detailed product features in prompts to get richer descriptions.
  • The gpt-4o model balances quality and speed for ecommerce content.
  • Streaming responses enable real-time generation feedback.
  • Always secure your API key via environment variables.
  • Adjust model choice based on cost and latency needs.
Verified 2026-04 · gpt-4o, gpt-4o-mini
Verify ↗