genmagic-pi
v0.1.0
Published
Image, video and speech generation for the pi coding agent: 60+ image and 30+ video models (Veo, Kling, Seedance, FLUX, Nano Banana, GPT Image) on one GenMagic key, as agent tools plus six skills.
Downloads
355
Maintainers
Readme
genmagic-pi
Image, video and speech generation for the pi coding agent, on one GenMagic key.
Ask pi for a hero image, a product shot, a short clip or a voiceover and it makes the file with the model that fits, saves it in your project, and tells you what it cost. One key and one pay-as-you-go balance cover 60+ image models (Nano Banana, GPT Image, FLUX, Seedream, Qwen Image, Recraft, Grok Imagine) and 30+ video models (Veo, Kling, Seedance, Wan, Hailuo, Grok Imagine, HeyGen), so you pick by price and quality instead of wiring one provider per model.
Install
pi install npm:genmagic-piTo try it for one run without installing: pi -e npm:genmagic-pi.
Set up
Get a free key with starter credit (it takes a minute): https://genmagic.co/get-api-key?utm_source=pi&utm_medium=package
Put it in the environment pi runs in, for example in your shell profile:
export GENMAGIC_API_KEY="your key"Start pi and ask for something: "Make a 1792x1024 hero image of a fox in fresh snow for the landing page", or "Which video models are cheapest for a 5 second clip?"
Keep the key in the environment, not in a project file. The package never writes it anywhere. Without a key, list_models still works and the other tools answer with the sign-up link instead of failing.
Tools
| Tool | What it does |
|---|---|
| generate_image(prompt, model?, size?, image?) | Makes or edits a picture and saves it. size is 1024x1024, 1792x1024 or 1024x1792. image is a picture to build on: an https URL, a data:image URL, or a PNG, JPEG, WebP or GIF file inside the working directory (3 MB at most). |
| generate_video(prompt, model?, aspect_ratio?, duration?, image?) | Starts a video job, waits for it (under a minute to several minutes; interrupting pi stops the wait), saves the clip as a file and returns its hosted URL. aspect_ratio is 16:9, 9:16 or 1:1. image starts the clip from a picture. |
| generate_speech(text, voice?, model?) | Turns text into spoken audio and saves it, with a hosted URL for the audio. |
| list_models(category) | Lists the image, video or audio models with an estimated price each. Free, no key needed. |
Every generation is saved as a new file in pi's working directory, named like genmagic-image-a-red-fox-in-fresh-snow-20261101-181500.png. An existing file is never overwritten. Each result reports the saved path, the model and the cost. Leave model out to get GenMagic's recommended default.
What it costs
You pay per generation from a prepaid GenMagic balance. There is no subscription. list_models shows an estimated price for every model, each result reports what the call actually cost and what is left, and a video is charged once, when the clip completes.
The tools tell the agent that every call is charged to your GenMagic balance, and ask it to name the model and its price before a video or a run of images, so you can object. When your balance runs out, GenMagic's own message (it says how to top up) is shown as it is. If you want a confirmation before every paid call, add a pi extension that gates tool calls: these tools declare that they are not read-only.
Skills
Seven GenMagic skills ship in the package, so pi can load the playbook when the task calls for it:
| Skill | For |
|---|---|
| genmagic-image-generation | Hero images, product shots, illustrations, logos, edits |
| genmagic-video-generation | Text-to-video and image-to-video clips, and the asynchronous job |
| genmagic-text-to-speech | Voiceovers and narration |
| genmagic-music-generation | Background music, jingles and soundtracks |
| genmagic-faceless-shorts | A complete faceless short for YouTube Shorts, TikTok or Reels |
| genmagic-ugc-video-ads | A UGC-style video ad from a product photo |
| genmagic-n8n-workflows | GenMagic steps in n8n workflows, with the verified node |
They are the same skills genmagic.co publishes at /.well-known/skills/. They call the GenMagic REST API with curl; inside pi the tools above do the same job, and pi is told to use the tools first. Music has no tool here, so the music skill still uses the REST API.
Safety and privacy
- The key is read from
GENMAGIC_API_KEYwhen a tool runs. It is sent togenmagic.coas a bearer token and nowhere else: not to the model providers, not to the media host a result is downloaded from. - Your prompt, text and any reference picture are sent to GenMagic, which passes them to the model's provider.
- A local reference picture is read only if it is a real PNG, JPEG, WebP or GIF file inside the working directory (symlinks out of it are refused).
- Results are downloaded over https only, and written as new files in the working directory.
- Like any pi extension, it runs with your permissions. It has no runtime dependencies and no install scripts; the source is the TypeScript in
extensions/andsrc/. - A generation is never retried automatically, because a retry could be charged twice. Only the free status lookups that poll a video job are retried.
Limits
generate_videowaits up to 20 minutes. If it stops waiting (you interrupt pi, the network fails, or the limit is reached), the job can still finish at GenMagic and is then charged; the result names the job so you do not start a second one.- For options the tools do not expose (an end frame, reference images, resolution, music, several images at once) use the GenMagic API directly: it is documented as OpenAPI at https://genmagic.co/openapi.json.
License
MIT. Questions: [email protected]
