In Development: This feature is in development. Not ready for use.

Example Request

import Heurist from 'heurist'
 
const heurist = new Heurist({
  apiKey: process.env['HEURIST_API_KEY'],
})
 
async function main() {
  const upscalerTask = new UpscalerTask({
    consumer_id: 'example-id',
    image_url: 'https://example.com/sample.jpg',
    timeout_seconds: 300 // optional
  });
  const response = await heurist.workflow.executeWorkflowAndWaitForResult(upscalerTask);
}
 
main()

Example Response

{
  "task_id": "example-task-id",
  "status": "finished",
  "result": "upscaled-image.png"
}

Parameters

Type: UpscalerTask

PropertyTypeRequiredDescription
consumer_idstringtrueThe ID of the consumer initiating the task. Preferably use UUID to uniquely identify the consumer. This is used to allocate computing resource for this consumer.
image_urlstringtrueThe URL of the image to be upscaled.
job_id_prefixstringfalseAn optional prefix for the job ID. Default is “sdk-workflow”.
timeout_secondsnumberfalseAn optional timeout for the task in seconds. If the task is not finished within the timeout, it will be canceled.

Returns

Type: WorkflowTaskResult

PropertyTypeRequiredDescription
task_idstringtrueThe ID of the executed task.
statusenumtrueThe status of the task.
resultanyfalseThe result of the task, if available.
{
  task_id: 'example-task-id',
  status: 'finished',
  result: {
    url: 'https://example.com/upscaled-image.png'
  }
}

Types

UpscalerTask

A class representing an upscaler task, extending the abstract WorkflowTask class.

class UpscalerTask extends WorkflowTask {
  constructor(options: UpscalerTaskOptions)
  get task_type(): WorkflowTaskType.Upscaler
  get task_details(): { parameters: { image: string } }
}

WorkflowTaskType An enum representing the types of workflow tasks.

enum WorkflowTaskType {
  Upscaler = 'upscaler'
}

Additional Methods

executeWorkflow

Executes a workflow task without waiting for the result.

async executeWorkflow(task: WorkflowTask): Promise<string>

Returns a Promise that resolves to the task ID.

queryTaskResult

Queries the result of a previously executed task.

async queryTaskResult(task_id: string): Promise<WorkflowTaskResult>

Returns a Promise that resolves to the task result.

cancelTask

Cancels a previously submitted task.

async cancelTask(task_id: string): Promise<{ task_id: string; msg: string }>

Returns a Promise that resolves to the task ID and message.