genmagic
v0.1.1
Published
Official GenMagic client and CLI: one API key and one pay-as-you-go balance for 460+ AI models. Generate images, video with sound, speech, music and text with Veo, Kling, Seedance, Wan, Nano Banana, GPT Image, FLUX and more.
Maintainers
Readme
GenMagic for JavaScript and the command line
One API key and one pay-as-you-go balance for 460+ AI models: images, video with sound, speech, music and text. Veo, Kling, Seedance, Wan, Hailuo, Runway, Nano Banana, GPT Image, FLUX, Seedream and more, each with its price shown before you run it.
npm install genmagic
export GENMAGIC_API_KEY=... # free key, one minute: https://genmagic.co/get-api-key?utm_source=npm&utm_medium=readmeNo dependencies. Node 18 or newer.
Images
import GenMagic from "genmagic";
const gm = new GenMagic();
const { url, costCents } = await gm.image("A red fox in snow, 35mm photo", {
model: "google/gemini-nano-banana-2.1", // leave out for GenMagic's default
size: "1792x1024",
});Video
video starts the job and waits for the clip. Use startVideo and getVideo to poll yourself.
const clip = await gm.video("Waves at sunset, slow drone shot", {
model: "alibaba/wan-3.0",
aspectRatio: "9:16",
duration: 5,
sound: true,
image: "https://example.com/opening-frame.png", // optional
});
console.log(clip.url);Moving off OpenAI's Sora 2 API
OpenAI shut down the Sora 2 Videos API on September 24, 2026. GenMagic answers the same calls, so code built on the
OpenAI SDK keeps working with a new base URL and key, and even model: "sora-2" runs (on Veo 3.1 Fast):
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://genmagic.co/api/v1", apiKey: process.env.GENMAGIC_API_KEY });
const video = await client.videos.createAndPoll({ model: "sora-2", prompt: "A paper boat at dusk", seconds: "8", size: "1280x720" });Details and prices: https://genmagic.co/sora-2-api-alternative?utm_source=npm&utm_medium=readme
Speech, music, text
import { writeFile } from "node:fs/promises";
const voice = await gm.speech("Welcome to the show");
await writeFile("welcome.mp3", voice.bytes);
const track = await gm.music("Calm lo-fi beat, 80 bpm");
const answer = await gm.chat("Write a hook for a video about foxes", { model: "anthropic/claude-haiku-5.5" });Models and prices
const videoModels = await gm.models("video"); // needs no key
const balance = await gm.usage();A refusal throws a GenMagicError with status, code and GenMagic's own message (for example how to top up when the balance is too low).
Command line
npx genmagic image "A red fox in snow" --out fox.png
npx genmagic video "Waves at sunset" --aspect 9:16 --duration 5 --out waves.mp4
npx genmagic speech "Welcome to the show" --out welcome.mp3
npx genmagic models video
npx genmagic balanceAlso from GenMagic
The same key works in n8n, Zapier, Make, ComfyUI and through MCP in Claude, ChatGPT and Cursor. The REST API is OpenAI-compatible: reference.
