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

@reaatech/media-pipeline-mcp-stability

v0.3.0

Published

Stability AI provider — SD3/SDXL/SD1.5 image generation via Stable Image API

Downloads

527

Readme

@reaatech/media-pipeline-mcp-stability

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Stability AI provider for the media pipeline framework. Supports image generation using SD3, SDXL, and SD1.5 models via the Stable Image v2beta REST API. Fully self-contained with no SDK dependency — all requests use the native Fetch API with FormData for multipart image uploads.

Installation

npm install @reaatech/media-pipeline-mcp-stability
# or
pnpm add @reaatech/media-pipeline-mcp-stability

Feature Overview

  • Image generation with SD3, SD3 Turbo, SDXL, and SD1.5 models
  • Full parameter control: prompt, negative prompt, dimensions, seed, steps, CFG scale
  • PNG output format with optional seed for reproducible generation
  • Per-step cost estimation with model-specific base + per-step rates
  • Deterministic caching when seed is provided
  • Base URL override for custom endpoints and proxies
  • Balance-based health check

Quick Start

import { StabilityProvider } from "@reaatech/media-pipeline-mcp-stability";

const provider = new StabilityProvider({ apiKey: process.env.STABILITY_API_KEY! });

const result = await provider.execute({
  operation: "image.generate",
  params: {
    prompt: "A serene mountain lake at dawn, professional photography",
    negative_prompt: "blurry, low quality, distorted",
    width: 1024,
    height: 1024,
    seed: 42,
    steps: 30,
    cfg_scale: 7.0,
  },
  config: {},
});

console.log(result.metadata.model); // "sd3"
console.log(result.metadata.seed);  // 42
console.log(result.costUsd);        // 0.007

Supported Operations

| Operation | Supported Models | Description | Output Format | |-----------|-----------------|-------------|---------------| | image.generate | sd3, sdxl, stable-diffusion-v1-5 | Text-to-image generation with full parameter control | PNG image buffer |

Configuration Parameters

image.generate

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | prompt | string | required | Text description of the desired image | | negative_prompt | string | — | Text describing what to avoid in the output | | width | number | — | Image width in pixels (model-dependent constraints) | | height | number | — | Image height in pixels (model-dependent constraints) | | seed | number | — | Random seed for reproducible generation (omit for random) | | steps | number | — | Number of diffusion inference steps | | cfg_scale | number | — | Classifier-free guidance scale (higher = more prompt adherence) | | model | string | "sd3" | Model identifier: sd3, sdxl, stable-diffusion-v1-5 |

Model Constraints

Different Stability AI models have different dimension requirements. Refer to the Stability AI documentation for each model's supported resolutions. Common defaults:

| Model | Default Dimensions | Notes | |-------|-------------------|-------| | sd3 | 1024 × 1024 | Supports various aspect ratios | | sdxl | 1024 × 1024 | Optimized for 1024px | | stable-diffusion-v1-5 | 512 × 512 | Legacy resolution |

API Reference

StabilityProvider

class StabilityProvider extends MediaProvider {
  constructor(config: StabilityConfig)

  healthCheck(): Promise<ProviderHealth>
  estimateCost(input: ProviderInput): Promise<CostEstimate>
  execute(input: ProviderInput): Promise<ProviderOutput>
}

StabilityConfig

interface StabilityConfig {
  apiKey: string;                                               // Stability AI API key (required)
  model?: "sd3" | "sdxl" | "stable-diffusion-v1-5";           // Default: "sd3"
  baseUrl?: string;                                             // Default: "https://api.stability.ai/v2beta"
}

Factory Function

import { createStabilityProvider } from "@reaatech/media-pipeline-mcp-stability";

const provider = createStabilityProvider({ apiKey: process.env.STABILITY_API_KEY!, model: "sd3" });

Key Methods

| Method | Returns | Description | |--------|---------|-------------| | healthCheck() | ProviderHealth | Validates API key by querying the balance endpoint | | estimateCost(input) | CostEstimate | Estimates cost based on model base rate + per-step multiplier | | execute(input) | ProviderOutput | Generates image via multipart form POST and returns the PNG buffer |

Non-Retryable Errors

Non-retryable errors are determined by Stability AI HTTP status codes. The provider relies on the base class retry logic for transient failures.

Cost Estimation

Per-Image Pricing

| Model | Base Cost | Per Step | Est. Cost (30 steps) | |-------|-----------|----------|---------------------| | sd3 | $0.007 | $0.00 | $0.007 | | sdxl | $0.009 | $0.00 | $0.009 | | stable-diffusion-v1-5 | $0.004 | $0.00 | $0.004 |

Cost is computed as baseCost + (perStep × steps). Both values are sourced from pricing.json per model. The perStep field defaults to 0 for current models, meaning cost is fixed per generation regardless of step count.

Cache Configuration

The provider exposes static cacheConfig with all parameters treated as deterministic.

Deterministic parameters: prompt, model, steps, cfg_scale, width, height, seed, sampler

Non-deterministic parameters: (none)

The normalize() function trims and collapses whitespace in prompt, and drops sampler when it's set to "auto" (the default). When a seed is provided, identical prompt + model + seed + dimensions + steps + cfg_scale combinations are fully cacheable.

Important: If seed is omitted, outputs will differ on each call and cache hits will not occur. For reproducible generations and effective caching, always provide an explicit seed.

Health Check

The health check sends a GET request to {baseUrl}/user/balance using the API key as a Bearer token. Returns { healthy: true, latency: <ms> } on 2xx response, or { healthy: false, error: "HTTP <status>: <message>" } on failure. The balance endpoint provides a lightweight way to validate both connectivity and API key validity.

Related Packages

License

MIT