> For the complete documentation index, see [llms.txt](https://xalora-ai.gitbook.io/xalora-ai-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xalora-ai.gitbook.io/xalora-ai-docs/text2video-workflow.md).

# Text2Video Workflow

Generate videos from text descriptions using advanced AI models.

This workflow extends the base [ComfyUI Workflow](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-workflow) functionality to support text-to-video generation.

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#supported-models-to-workflow-id-mapping)Supported Models to Workflow ID Mapping <a href="#supported-models-to-workflow-id-mapping" id="supported-models-to-workflow-id-mapping"></a>

| Workflow ID | Model   |
| ----------- | ------- |
| 1           | Hunyuan |

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#before-you-start)Before you start <a href="#before-you-start" id="before-you-start"></a>

1. [Get an API key](https://heurist.ai/credits)
2. Define environment variables in `.env` file:

Copy

```
XALORA_API_KEY=your_api_key
XALORA_WORKFLOW_URL=https://sequencer-v2.xalora.xyz
```

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#example-request)Example Request <a href="#example-request" id="example-request"></a>

Copy

```
import Xalora from 'xalora'

const xalora = new Xalora({
  apiKey: process.env['XALORA_API_KEY']
});

async function generateVideo() {
  const text2VideoTask = new Text2VideoTask({
    workflow_id: '1',
    prompt: 'a rabbit moving quickly in a beautiful winter scenery nature trees sunset tracking camera',
    timeout_seconds: 600 // optional
  });

  const response = await xalora.workflow.executeWorkflowAndWaitForResult(
    text2VideoTask,
    600000,  // 10 minutes timeout
    15000    // 15 seconds polling interval
  );

  console.log('Generated video URL:', response.result);
}
```

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#example-response)Example Response <a href="#example-response" id="example-response"></a>

Copy

```
{
  "task_id": "7599f1f038",
  "create_timestamp": 1733965543,
  "inference_latency": 0.608921,
  "upload_latency": 2.316333,
  "task_type": "txt2vid",
  "status": "finished",
  "result": "https://example.com/generated-video.webp",
  "task_details": {
    "parameters": {
      "fps": 24,
      "height": 480,
      "length": 37,
      "prompt": "a rabbit moving quickly in a beautiful winter scenery nature trees sunset tracking camera",
      "quality": 80,
      "seed": 704883238463297,
      "steps": 30,
      "width": 848
    }
  },
  "timeout_seconds": 600,
  "workflow_id": "1"
}
```

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#parameters)Parameters <a href="#parameters" id="parameters"></a>

**Type**: `Text2VideoTask`

| Property         | Type   | Required | Description                                                                                               |
| ---------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------- |
| workflow\_id     | string | true     | The ID of the workflow to execute.                                                                        |
| prompt           | string | true     | The prompt to use for the video generation.                                                               |
| width            | number | false    | The width of the video. Default is 848.                                                                   |
| height           | number | false    | The height of the video. Default is 480.                                                                  |
| length           | number | false    | The length of the video in frames. Default is 37.                                                         |
| steps            | number | false    | The number of steps to use for the video generation. Default is 30.                                       |
| seed             | number | false    | The seed to use for the video generation.                                                                 |
| fps              | number | false    | The frames per second of the video. Default is 24.                                                        |
| quality          | number | false    | The quality of the video. Default is 80.                                                                  |
| job\_id\_prefix  | string | false    | An optional prefix for the job ID. Default is “sdk-workflow”.                                             |
| timeout\_seconds | number | false    | The timeout for the task in seconds. If the task is not finished within the timeout, it will be canceled. |
| consumer\_id     | string | false    | The ID of the consumer.                                                                                   |
| api\_key         | string | false    | The API key of the consumer.                                                                              |

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#returns)Returns <a href="#returns" id="returns"></a>

**Type**: `WorkflowTaskResult`

| Property           | Type   | Required | Description                                    |
| ------------------ | ------ | -------- | ---------------------------------------------- |
| task\_id           | string | true     | The ID of the executed task.                   |
| status             | enum   | true     | The status of the task.                        |
| result             | any    | false    | The result of the task, if available.          |
| task\_details      | any    | false    | The details of the task, if available.         |
| timeout\_seconds   | number | false    | The timeout for the task in seconds.           |
| workflow\_id       | string | false    | The ID of the workflow that executed the task. |
| create\_timestamp  | number | false    | The timestamp when the task was created.       |
| inference\_latency | number | false    | The latency of the inference in seconds.       |
| upload\_latency    | number | false    | The latency of the upload in seconds.          |

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#authentication)Authentication <a href="#authentication" id="authentication"></a>

Authentication uses a combined consumer ID and API key format: `consumerId#apiKey`. You can provide these in two ways:

1. In the Xalora client initialization using environment variables:

Copy

```
const xalora = new Xalora({
  apiKey: process.env['XALORA_API_KEY']  // format: consumerId#apiKey
});
```

2. In the `Text2VideoTask` object, the task-specific values will override the client defaults if provided.

Copy

```
const text2VideoTask = new Text2VideoTask({
  consumer_id: 'consumerId',
  api_key: 'apiKey',
  ...
});
```

## [​](https://docs.heurist.ai/dev-guide/heurist-sdk/comfyui-txt2vid#types)Types <a href="#types" id="types"></a>

`Text2VideoTask`

A class representing a text-to-video task, extending the abstract `WorkflowTask` class.

Copy

```
class Text2VideoTask extends WorkflowTask {
  constructor(options: Text2VideoTaskOptions)
  get task_type(): WorkflowTaskType.Text2Video
  get task_details(): {
    parameters: {
      prompt: string
      width?: number
      height?: number
      length?: number
      steps?: number
      seed?: number
      fps?: number
      quality?: number
    }
  }
}
```

`WorkflowTaskType`

An enum representing the types of workflow tasks.

Copy

```
enum WorkflowTaskType {
  Text2Video = 'txt2vid'
}
```
