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>

  • Request a presigned download URL for a stored image asset.

    Parameters

    Returns Promise<string>

    Presigned GET URL for the image. Throws if the server response does not include a downloadUrl.

  • 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.
      • hasVideoInput: Whether to price a Seedance estimate with video input.

    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

  • Request a presigned download URL for a stored audio or video asset.

    Parameters

    Returns Promise<string>

    Presigned GET URL for the media. Throws if the server response does not include a downloadUrl.

  • Request a presigned upload URL for an audio or video asset (reference audio, reference video, finished media artifacts, etc.). The caller uploads the media bytes via PUT to the returned URL before starting a project or workflow that references the asset.

    Parameters

    • params: MediaUrlParams

      Media asset coordinates:

      • id: Stable identifier for the asset within the job (e.g. "media_ref_1"). Optional for some asset roles.
      • jobId: Caller-generated job/correlation id.
      • type: Asset role. Supported values are 'referenceAudio', 'referenceVideo', 'preview', 'complete'.
      • contentType: Optional MIME type the caller will PUT (e.g. "audio/mp4" or "video/mp4").

    Returns Promise<string>

    Presigned PUT URL the caller should upload the media bytes to.

  • Request a presigned upload URL for an image asset (reference image, starting image, ControlNet image, context image, etc.). The caller uploads the image bytes via PUT to the returned URL before starting a project or workflow that references the asset.

    Parameters

    • params: ImageUrlParams

      Image asset coordinates:

      • imageId: Stable identifier for the asset within the job (e.g. "media_ref_1"). The same id is later used to reference the asset in workflow inputs.
      • jobId: Caller-generated job/correlation id (e.g. "sogni-agent-1735000000-1-abcdef"). Ties the asset to a specific request.
      • type: Asset role. Supported values include 'referenceImage', 'referenceImageEnd', 'startingImage', 'cnImage', 'contextImage1'..'contextImage16', 'preview', 'complete'.
      • contentType: Optional MIME type the caller will PUT (e.g. "image/png"). Forwarded so the storage layer can pin the Content-Type on the presigned URL.

    Returns Promise<string>

    Presigned PUT URL the caller should upload the image bytes to. Short-lived; use immediately.

  • 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[]>