Hierarchy (View Summary)

Constructors

Properties

client: ApiClient
eip712: EIP712Helper
listeners: {
    availableModels?: (data: AvailableModel[]) => void[];
    job?: (data: JobEvent) => void[];
    project?: (data: ProjectEvent) => void[];
} = {}

Accessors

  • get trackedProjects(): Project[]
  • Retrieves a list of projects created and tracked by this SogniClient instance.

    Note: When a project is finished, it will be removed from this list after 30 seconds

    Returns Project[]

    A copy of the array containing the tracked projects.

Methods

  • Cancel project by id. This will cancel all jobs in the project and mark project as canceled. Client may still receive job events for the canceled jobs as it takes some time, but they will be ignored

    Parameters

    • projectId: string

    Returns Promise<void>

  • Estimate the cost of an audio generation job.

    Parameters

    • params: AudioEstimateRequest

      The parameters required for audio cost estimation. This includes:

      • tokenType: The type of token to be used for generation.
      • model: The model to be used for audio generation.
      • duration: Duration of the audio in seconds.
      • steps: Number of inference steps.
      • numberOfMedia: Number of audio tracks to generate.

    Returns Promise<CostEstimation>

    Returns an object containing the estimated costs in different units.

  • Estimates the cost of generating a video based on the provided parameters.

    Parameters

    • params: VideoEstimateRequest

      The parameters required for video cost estimation. This includes:

      • tokenType: The type of token to be used for generation.
      • model: The model to be used for video generation.
      • width: The width of the video in pixels.
      • height: The height of the video in pixels.
      • frames: The total number of frames in the video.
      • fps: The frames per second for the video.
      • steps: Number of steps.

    Returns Promise<{ sogni: string; spark: string; token: string; usd: string }>

    Returns an object containing the estimated costs for the video in different units:

    • token: Cost in tokens.
    • usd: Cost in USD.
    • spark: Cost in Spark.
    • sogni: Cost in Sogni.
  • Get supported size presets for the model and network. Size presets are cached for 10 minutes.

    Parameters

    • network: SupernetType

      'fast' or 'relaxed'

    • modelId: string

      model id (e.g. 'flux1-schnell-fp8')

    • forceRefresh: boolean = false

      force refresh cache

    Returns Promise<SizePreset[]>

    const presets = await sogni.projects.getSizePresets('fast', 'flux1-schnell-fp8');
    console.log(presets);
  • Retrieves the video asset configuration for a given video model identifier. Validates whether the provided model ID corresponds to a video model. If it does, returns the appropriate video asset configuration based on the workflow type.

    Parameters

    • modelId: string

      The identifier of the video model to retrieve the configuration for.

    Returns Promise<
        | { assets?: undefined; workflowType: null }
        | {
            assets: Record<VideoAssetKey, AssetRequirement>;
            workflowType:
                | "t2v"
                | "i2v"
                | "s2v"
                | "ia2v"
                | "a2v"
                | "v2v"
                | "animate-move"
                | "animate-replace";
        },
    >

    The video asset configuration object where key is asset field and value is either required, forbidden or optional. Returns null if no rules defined for the model.

    {
    "workflowType": "i2v",
    "assets": {
    "referenceImage": "required",
    "referenceImageEnd": "optional",
    "referenceAudio": "forbidden",
    "referenceVideo": "forbidden"
    }
    }

    Throws an error if the provided model ID is not a video model.

  • Check if a model produces audio output using the cached models list. Uses the media property from the models API when available, falls back to model ID prefix check if models aren't loaded yet.

    Parameters

    • modelId: string

    Returns boolean

  • Check if a model produces video output using the cached models list. Uses the media property from the models API when available, falls back to model ID prefix check if models aren't loaded yet.

    Parameters

    • modelId: string

    Returns boolean

  • Wait for available models to be received from the network. Useful for scripts that need to run after the models are loaded.

    Parameters

    • timeout: number = 10000

      timeout in milliseconds until the promise is rejected

    Returns Promise<AvailableModel[]>