Hierarchy

  • CachedApi
    • ServiceApi

Constructors

  • Parameters

    • options: Pick<CachedApiOptions, "client"> & Partial<Omit<CachedApiOptions, "client">>

    Returns ServiceApi

Properties

_cache: Record<string, {
    data: any;
    expires: number;
}> = ...

Type declaration

  • data: any
  • expires: number
options: CachedApiOptions

Accessors

Methods

  • Type Parameters

    • T

    Parameters

    • key: string

    Returns Promise<null | T>

  • Type Parameters

    • T

    Parameters

    • key: string
    • fetch: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    Returns Promise<T>

  • Type Parameters

    • T

    Parameters

    • key: string
    • data: T

    Returns Promise<void>

  • Clears the cache by resetting the _cache object to an empty object.

    Returns void

  • Asynchronously creates a batch of image-to-image generations and returns the batch object.

    Parameters

    • body: StableDiffusionProcessingImg2Img

      The image to be processed.

    • options: {
          batchSize: number;
          manual?: boolean;
          numBatches: number;
      }

      The options for the batch generation.

      • batchSize: number

        The number of images to generate in each batch.

      • Optional manual?: boolean

        Whether to manually run the batch generation.

      • numBatches: number

        The total number of batches to generate.

    Returns Promise<Img2imgBatchGeneration>

    A promise that resolves to the batch object.

  • Pings the API to check the response time.

    Returns Promise<{
        error: undefined;
        success: boolean;
        time: number;
    } | {
        error: unknown;
        success: boolean;
        time: number;
    }>

    An object containing the success status, the response time in milliseconds, and an optional error object if the ping fails.

  • Removes a cache entry with the specified key.

    Parameters

    • key: string

      The key of the cache entry to remove.

    Returns void

  • Asynchronously creates a batch of text-to-image generations and returns the batch object.

    Parameters

    • body: StableDiffusionProcessingTxt2Img

      The text to be processed.

    • options: {
          batchSize: number;
          manual?: boolean;
          numBatches: number;
      }

      The options for the batch generation.

      • batchSize: number

        The number of images to generate in each batch.

      • Optional manual?: boolean

        Whether to manually run the batch generation.

      • numBatches: number

        The total number of batches to generate.

    Returns Promise<Txt2imgBatchGeneration>

    A promise that resolves to the batch object.

  • Asynchronously watches the progress of current task.

    Parameters

    • options: {
          getCurrentImage?: boolean;
          intervalMs: number;
          manual?: boolean;
      }

      The options for the progress watcher.

      • Optional getCurrentImage?: boolean

        Whether to include the current image in the response. Defaults to false.

      • intervalMs: number

        The interval in milliseconds to check the progress.

      • Optional manual?: boolean

        Whether to manually start the progress watcher.

    Returns ProgressWatcher

    The progress watcher object.