npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sanity-plugin-genmagic

v1.0.0

Published

Generate images with 60+ AI models (FLUX, Nano Banana, GPT Image, Seedream and more) from the Select menu of an image field in Sanity Studio. One GenMagic key, pay as you go, every model shows its price. Optional video clips for file fields.

Readme

sanity-plugin-genmagic

Generate images with more than 60 AI models from inside Sanity Studio, at the moment an editor needs one.

The plugin adds Generate with GenMagic to the Select menu of every image field. It opens a dialog where the editor picks a model, writes a prompt, chooses a size, and sees the picture and what it cost before using it. Use this image puts it in your dataset as a normal image asset.

  • Choose the model. FLUX, Nano Banana, GPT Image, Seedream, Recraft, Qwen and more, all through one GenMagic key. The list is read live from GenMagic, so new models appear without a plugin update.
  • See the price first. Every model shows its estimated price per image next to its name. After a generation the dialog shows the exact cost and the balance left.
  • Pay as you go. One prepaid balance for every model. No subscription, no per-model account.
  • Optional video. Add a clip generator to file fields (see Video clips).

Install

npm install sanity-plugin-genmagic

Add it to sanity.config.ts:

import {defineConfig} from 'sanity'
import {genmagicAssetSource} from 'sanity-plugin-genmagic'

export default defineConfig({
  // ...
  plugins: [genmagicAssetSource()],
})

Open any document with an image field, open the field's Select menu, and choose Generate with GenMagic.

Requires Sanity Studio v5 or v6 (React 19.2 or newer).

The API key

Generating needs a GenMagic API key. A free key is at genmagic.co/get-api-key. Browsing the model list needs no key.

There are two ways to provide it.

Each editor pastes their own (the default). The dialog shows a key field. Once a generation works, the key is kept in that browser's localStorage and is never sent anywhere except genmagic.co. Forget key removes it.

You set one key for the whole Studio:

plugins: [genmagicAssetSource({apiKey: process.env.SANITY_STUDIO_GENMAGIC_KEY})]

When a key is set this way the dialog shows no key field.

A key in your Studio configuration is part of the JavaScript your Studio serves, so anyone who can load the Studio can read it. GenMagic bills a prepaid balance, which caps what a key can spend. Use a key from an account that holds only what you are happy to spend, and combine it with allowedModels to keep to prices you accept. If that does not suit you, leave apiKey unset and let each editor use their own.

Options

All optional.

| Option | Type | What it does | | --------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | apiKey | string | One GenMagic key for every editor, so nobody pastes one. See the note above. | | defaultModel | string | Model id preselected the first time an editor opens the dialog. After that their last choice is remembered. Without it, the first model in GenMagic's list (newest first) is used. | | allowedModels | string[] | Limit the picker to these model ids. Handy with a shared apiKey. | | video | boolean | Also add Generate video with GenMagic to every file field. Default false. |

Model ids are listed at https://genmagic.co/api/v1/models?category=image.

genmagicAssetSource({
  apiKey: process.env.SANITY_STUDIO_GENMAGIC_KEY,
  allowedModels: ['black-forest-labs/flux-3-image-klein', 'bytedance-seed/seedream-5-0-flash'],
})

One field only

To offer the generator on a single field instead of all of them, leave the plugin out and use the source directly:

import {defineField} from 'sanity'
import {createGenmagicImageSource} from 'sanity-plugin-genmagic'

defineField({
  name: 'cover',
  title: 'Cover image',
  type: 'image',
  options: {sources: [createGenmagicImageSource({defaultModel: 'openai/gpt-image-2'})]},
})

options.sources sets the complete list of sources for that field, so Sanity's own Browse option is not shown unless you list it too. See Sanity's documentation on asset sources.

What the editor sees

  1. Model. Each option reads like Black Forest Labs: FLUX 3 Image ($0.072), the estimated price of one image. If the list cannot be loaded, the dialog offers a retry and still generates with GenMagic's own default model.
  2. Size. Square 1024x1024, landscape 1792x1024 or portrait 1024x1792.
  3. Prompt. Press Ctrl+Enter (Cmd+Enter on Mac) to generate.
  4. Generate. The button shows the estimated price. When it finishes, the picture appears with the cost of that generation and the balance left.
  5. Use this image. The file is downloaded and uploaded to your dataset like any other upload, so it does not depend on genmagic.co afterwards. Generate again as often as you like before choosing.

Errors are shown exactly as GenMagic words them. A low balance, for example, explains how to top up.

What is stored on the asset

Each image asset records where it came from, so it can be found and labelled later:

  • description: the prompt
  • creditLine: Generated with GenMagic (<model name>)
  • source: {name: 'genmagic', id: <file address>, url: <file address>}

Video clips

A file field can offer Generate video with GenMagic, which makes a short clip from a prompt and stores it as a file. It is off by default, because file fields are often for PDFs.

For one field:

import {createGenmagicVideoSource} from 'sanity-plugin-genmagic'

defineField({
  name: 'heroClip',
  type: 'file',
  options: {accept: 'video/*', sources: [createGenmagicVideoSource()]},
})

For every file field, use genmagicAssetSource({video: true}).

Only text-to-video models are listed, with the aspect ratios 16:9, 9:16 and 1:1. A clip takes a few minutes to render. Nothing is charged until it finishes. Closing the dialog while it renders stops the waiting, but the clip may still finish and be billed.

In Sanity's types, the form.file.assetSources setting that this relies on is marked beta.

Troubleshooting

  • "Add your GenMagic API key": paste a key into the dialog, or set apiKey.
  • "Invalid API key": the key is wrong or revoked. Use Forget key and paste a new one.
  • A low balance message: GenMagic's message says how to top up.
  • "Could not download the image from GenMagic": the browser could not read the generated file. If your Studio sets a Content Security Policy, allow https://genmagic.co in connect-src and img-src (and media-src for clips).
  • "This field accepts ...": the field's accept option does not allow the file type the model produced. Pick another model or relax accept.

Notes

  • Each call identifies this package to GenMagic with an X-GenMagic-Client: sanity-plugin/<version> header.
  • Prompts go to GenMagic and the model providers it routes to. Do not put confidential text in a prompt that you would not send to an AI service.
  • Images are produced by AI. The creditLine on each asset makes that visible in your own content tools.

License

MIT © GenMagic. genmagic.co/developers