Medusa v2 plugin to generate AI-powered product descriptions via OpenRouter.
AI-powered product & category description generator plugin for MedusaJS v2.
This plugin uses AI (via OpenRouter) to generate SEO-optimized descriptions for products and categories in Spanish. It adds widgets on the product and category detail pages, plus a dedicated admin page for batch operations and cache management.
npm install medusa-plugin-product-description
Add the following to your Medusa project's file:
OPENROUTER_API_KEY=sk-or-v1-your-key-hereOPENROUTER_MODEL=google/gemma-3-12b-it:freeOPENROUTER_SITE_URL=https://your-store.comOPENROUTER_APP_NAME=Your Store AdminSTOREFRONT_URL=https://your-storefront.comAI_DESCRIPTION_PROMPT=Genera una descripcion atractiva, natural y optimizada para SEO sobre el producto "{productTitle}". ...AI_CATEGORY_PROMPT=Escribe una descripcion breve, natural y optimizada para SEO en Markdown sobre la categoria **{categoryName}**. ...
| Variable | Required | Default | Description |
|---|---|---|---|
| Yes | — | OpenRouter API key (sign up at openrouter.ai) | |
| No | Model to use. Browse models | ||
| No | — | Your site URL (sent as header) | |
| No | Your app name (sent as header) | ||
| No | — | Your storefront base URL for cache revalidation (e.g. ) | |
| No | Default prompt (see below) | Prompt template for products. Use as placeholder | |
| No | Default prompt (see below) | Prompt template for categories. Use as placeholder |
Default product prompt:
Default category prompt:
In your , register the plugin:
import { defineConfig } from "@medusajs/framework/config"export default defineConfig({plugins: [{resolve: "medusa-plugin-product-description",options: {},},],})
The plugin injects widgets directly into the Medusa admin:
Navigate to IA Descripciones in the sidebar for advanced operations:
Individual generation:
Batch generation:
Cache management:
If you're using a Next.js storefront, this plugin calls to revalidate the ISR cache. Add this endpoint:
// frontend/src/app/api/revalidate/route.tsimport { revalidateTag } from "next/cache"import { NextRequest, NextResponse } from "next/server"export async function GET(request: NextRequest) {const tag = request.nextUrl.searchParams.get("tags") || "products"revalidateTag(tag)return NextResponse.json({ revalidated: true, tag })}
Generate a product description.
Request:
{ "productId": "prod_01JABC...", "productTitle": "Paracetamol 650mg" }
Response:
{ "description": "## Paracetamol 650mg\n\nAlivia el dolor y la fiebre con..." }
Generate a category description. Optionally include sibling category names for context.
Request:
{"categoryId": "pcat_01JABC...","categoryName": "Analgesicos","relatedCategories": ["Antiinflamatorios", "Antigripales"]}
Response:
{ "description": "## Analgesicos\n\nEncuentra los mejores analgesicos..." }
Trigger cache revalidation on the storefront. Requires environment variable.
Request:
{ "tags": "products" }
Response:
{ "revalidated": true, "tags": "products" }
# Install dependenciesnpm install# Build the pluginnpm run build# Watch mode (for local plugin development)npm run dev
# From your plugin directorynpm run dev# In your Medusa project directory:npx medusa plugin:add ../path-to/medusa-plugin-product-description
npx medusa plugin:buildnpm publish
To publish an update:
npm version patch # or minor / majornpx medusa plugin:buildnpm publish
MIT