Function variateImage

  • Generates visual variations of a source image using a provider-agnostic interface.

    Resolves credentials via resolveMediaProvider(), initialises the matching image provider, converts the input image to a Buffer, and dispatches to the provider's variateImage method.

    For providers without a native variation endpoint, the high-level API falls back to an img2img call with strength = variance to produce similar output.

    Parameters

    Returns Promise<VariateImageResult>

    A promise resolving to the variation result with image data.

    Throws

    When the resolved provider does not implement image variations and has no img2img fallback.

    Throws

    When no provider can be determined or credentials are missing.

    Example

    const result = await variateImage({
    provider: 'openai',
    image: 'https://example.com/hero.png',
    n: 4,
    });
    result.images.forEach((img, i) => console.log(`Variation ${i}:`, img.url));