=== GenMagic AI Image & Video Generator ===
Contributors:      genmagic
Tags:              product photography, ai image generator, woocommerce ai, product images, ai video
Requires at least: 6.4
Tested up to:      7.1
Requires PHP:      7.4
Stable tag:        1.0.0
License:           GPLv2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Generate AI images, videos and WooCommerce product photos in the Media Library and save them to your site. See the price first, then keep the result.

== Description ==

Need a picture or a short video for a post, a product page or a banner? This plugin adds a **Generate** tab to the Media Library window and a **Media > Generate with GenMagic** page. Describe what you want, pick a model, see the price, generate, preview, and save the result straight into your Media Library.

It works with [GenMagic](https://genmagic.co), a service that runs many image and video models behind one API key and one prepaid balance. The model list comes from GenMagic and grows as models are added. Today it includes image models such as Google Nano Banana, OpenAI GPT Image, Black Forest Labs FLUX, Recraft and ByteDance Seedream, and video models such as Google Veo, Kling, Wan and Seedance.

**What you can do**

* **Generate images** in square, landscape or portrait. The model picker shows each model's name and its estimated price per image.
* **Generate videos** from a prompt. Choose the model, shape, length and quality, and the estimated price for exactly those choices is shown before you start. Videos render in the background; you can leave the page and the finished video is waiting for you.
* **See what it cost.** Every result shows what it cost and the balance left.
* **Save to the Media Library** with a title and alt text filled in from your prompt (you can edit both first). The model and prompt are kept as hidden attachment data.
* **Use it anywhere WordPress asks for media.** The Generate tab appears in the Media Library window of the classic editor, the Image block, featured images and more. After you save, the new file is selected and ready to insert.
* **Make product photos for WooCommerce.** On a product's edit screen, the Product photos box makes a new photo of the product from its product image: white studio, lifestyle scene, with a model, flat lay or seasonal. Every style tells the model to keep the product, its label and logo as they are. Check the photo, then add it to the product gallery with one click.
* **Control who can spend.** By default everyone who can upload files can generate. A setting limits it to administrators.

Nothing happens until a site administrator adds a GenMagic API key. A free key with starter credit takes a minute at [genmagic.co/get-api-key](https://genmagic.co/get-api-key?utm_source=wordpress&utm_medium=media-plugin).

**Good to know**

* The plugin itself is free and has no locked features. Generating costs money because GenMagic charges for the models it runs: a prepaid, pay-as-you-go balance with no subscription. When the balance is used up, GenMagic says so and explains how to top up; the plugin shows that message as it is.
* No ads, credits, links or tracking are added to your public site.
* All code is included as plain source files. There is no build step.

== Installation ==

1. Install and activate the plugin.
2. Go to **Settings > GenMagic Generator** and paste your GenMagic API key. Get a free key with starter credit at [genmagic.co/get-api-key](https://genmagic.co/get-api-key?utm_source=wordpress&utm_medium=media-plugin).
3. Open **Media > Generate with GenMagic**, or click **Generate with GenMagic** in any Media Library window.

You can also define the key in `wp-config.php` instead of saving it in the database:

`define( 'GENMAGIC_API_KEY', 'your-key' );`

== External services ==

This plugin connects to the GenMagic API (https://genmagic.co/api/v1), operated by GenMagic, to list models, generate images and videos, and download the results. GenMagic runs each request on the chosen model's provider (for example Google, OpenAI, Black Forest Labs or ByteDance) and charges the cost to your GenMagic balance.

**Nothing is sent until a site administrator saves a GenMagic API key** (or defines `GENMAGIC_API_KEY` in `wp-config.php`). Adding the key is the consent to the connection described here. Removing the key stops it.

What is sent, and when:

* **When you open a Generate screen:** a request for the model list, `GET https://genmagic.co/api/v1/models`. It carries no prompt and no key. The list is cached on your site for six hours.
* **When you save a key:** a request for the key owner's usage, `GET https://genmagic.co/api/v1/usage`, with the key, to check that GenMagic accepts it. It spends no credit.
* **When you click Generate for an image:** the prompt you typed, the model and the size, sent to `https://genmagic.co/api/v1/images/generations` together with the key.
* **When you click Make photo in the WooCommerce Product photos box:** the product's image (its large size, read from your site's files and sent inside the request), the style's prompt with any words you added, the model and the size, sent to `https://genmagic.co/api/v1/images/generations` together with the key.
* **When you click Generate for a video:** the prompt, the model, the shape, length, quality and sound choice, sent to `https://genmagic.co/api/v1/videos` together with the key. While the video renders, the plugin asks `https://genmagic.co/api/v1/videos/{id}` how it is doing.
* **When you preview a result or click Save:** your browser shows the result from, and your server downloads the file from, a GenMagic address (genmagic.co or its storage host tlwdqzfibvgektzgdfqa.supabase.co). Files are only downloaded from those two addresses, and the key is not sent to them.
* Every request also carries the plugin name and version (`X-GenMagic-Client: wordpress-media/1.0.0`) and your server's IP address, as any web request does.

No post content, user accounts, email addresses or other site data are sent. The prompts you write and the results are processed by GenMagic as described in its policies.

GenMagic's [terms of service](https://genmagic.co/legal/terms) and [privacy policy](https://genmagic.co/legal/privacy) apply.

== Frequently Asked Questions ==

= Is it free? =

The plugin is free. GenMagic charges for generating: a prepaid, pay-as-you-go balance, with no subscription. New accounts get free starter credit. The estimated price of every model is shown before you generate, and each result shows what it cost.

= What happens when my balance runs out? =

GenMagic declines the request and says how to top up. The plugin shows that message exactly as GenMagic sent it. Nothing in the plugin is locked.

= Which models can I use? =

Every image model and every text-to-video model in the GenMagic catalog. The pickers load the list from GenMagic, so new models appear without a plugin update.

= Can it make videos? =

Yes. Choose Video, pick a model, shape, length and quality, and the estimated price is shown before you start. A video can take a few minutes. You are charged when it is ready, not when you start it. If you leave the page, the video is waiting for you the next time you open a Generate screen.

= Does it work with WooCommerce? =

Yes. With WooCommerce active, every product's edit screen gets a Product photos box. Set a product image, pick a style (white studio, lifestyle scene, with a model, flat lay or seasonal), add a few words if you like, and click Make photo. Only models that can work from a photo are offered. Check the result and click Add to product gallery. Marketplaces such as Amazon want a real photo as the main image, so these photos are best used as additional images.

= Does it work in the block editor? =

Yes. In the Image block (or any block that picks media), open the Media Library and choose the **Generate with GenMagic** tab. When you save a result it is selected and ready to insert.

= Who can use it? =

Everyone who can upload files, unless you choose "Administrators only" under Settings > GenMagic Generator. Every result is charged to the balance behind the key, so choose with that in mind.

= Where is my API key stored? =

In your site's options table, or in `wp-config.php` if you define `GENMAGIC_API_KEY`. The key is only used on your server: the browser never receives it, and the settings page shows only its last four characters. Removing the key under Settings deletes it. Deleting the plugin removes its settings; files you saved stay in your Media Library.

= Image generation stops with a timeout. =

Some hosts end requests after 30 or 60 seconds, and a slow image model can take longer. Try a faster model. Videos are not affected: they render in the background.

== Screenshots ==

1. Media > Generate with GenMagic: model picker with estimated prices, prompt, size and Generate.
2. The same screen for video: length, quality and sound, with the estimated price shown before you start.
3. The Generate with GenMagic tab inside the Media Library window the Image block opens.
4. Settings > GenMagic Generator: the API key, who can generate, and what the plugin sends to GenMagic.
5. The Product photos box on a WooCommerce product: a lifestyle photo made from the product image, with its cost, ready to add to the product gallery.

== Changelog ==

= 1.0.0 =
* First release: image and video generation from the Media Library, price shown first, cost shown with each result, save with title and alt text from the prompt, and a WooCommerce Product photos box that makes product photos from the product image and adds them to the gallery.

== Upgrade Notice ==

= 1.0.0 =
First release.
