Product description
Плагин Medusa v2 для генерации описаний товаров с помощью AI через OpenRouter.
medusa-plugin-product-description
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.
Features
- Product detail widget: "Generar Descripcion con IA" button directly on the product edit page
- Category detail widget: "Generar Descripcion de Categoria con IA" button directly on the category edit page
- Admin page "IA Descripciones": individual generation for products and categories, batch generation of ALL products/categories, and cache revalidation
- AI generation via OpenRouter (OpenAI-compatible API, supports any model: Google Gemini, GPT, Claude, etc.)
- Configurable prompts via environment variables
- Automatic date stamp: "Descripcion actualizada el DD/MM/AAAA"
- Server-side cache revalidation via
- Batch operations with progress bar and cost warning
- Zero hardcoded URLs — works on any Medusa installation
Prerequisites
- MedusaJS v2.22.2 or later
- Node.js v22.22.0 or later
- An OpenRouter API key (free tier available)
Installation
Configuration
1. Environment Variables
Add the following to your Medusa project's file:
| 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:
2. Medusa Configuration
In your , register the plugin:
Usage
Widgets (recommended)
The plugin injects widgets directly into the Medusa admin:
- Product detail page (): A "Generar Descripcion con IA" section appears below the product details. Generate, edit, save, and revalidate — all without leaving the page.
- Category detail page (): Same widget for categories, with sibling category context for better AI results.
Admin Page: IA Descripciones
Navigate to IA Descripciones in the sidebar for advanced operations:
Individual generation:
- Enter a product or category ID, load it, generate a description, edit and save.
Batch generation:
- Generate descriptions for ALL products or ALL categories in one go.
- A progress bar shows real-time status.
- ⚠️ Warning: This calls the OpenRouter API for every entity. Use with caution — it may consume significant API credits.
Cache management:
- Revalidate products cache, categories cache, or both at once.
- Requires environment variable pointing to your storefront.
Next.js Revalidation Endpoint
If you're using a Next.js storefront, this plugin calls to revalidate the ISR cache. Add this endpoint:
API Endpoints
Generate a product description.
Request:
Response:
Generate a category description. Optionally include sibling category names for context.
Request:
Response:
Trigger cache revalidation on the storefront. Requires environment variable.
Request:
Response:
Development
Local Testing with a Medusa Project
Publishing to NPM
To publish an update:
License
MIT

