|
| 1 | +<!--- |
| 2 | +This markdown file has been generated from a script. Please do not edit it directly. |
| 3 | +For more details, check out: |
| 4 | +- the `generate.ts` script: https://github.com/huggingface/hub-docs/blob/main/scripts/inference-providers/scripts/generate.ts |
| 5 | +- the task template defining the sections in the page: https://github.com/huggingface/hub-docs/tree/main/scripts/inference-providers/templates/task/text-to-video.handlebars |
| 6 | +- the input jsonschema specifications used to generate the input markdown table: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/tasks/text-to-video/spec/input.json |
| 7 | +- the output jsonschema specifications used to generate the output markdown table: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/tasks/text-to-video/spec/output.json |
| 8 | +- the snippets used to generate the example: |
| 9 | + - curl: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/snippets/curl.ts |
| 10 | + - python: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/snippets/python.ts |
| 11 | + - javascript: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/snippets/js.ts |
| 12 | +- the "tasks" content for recommended models: https://huggingface.co/api/tasks |
| 13 | +---> |
| 14 | + |
| 15 | +## Text to Video |
| 16 | + |
| 17 | +Generate an video based on a given text prompt. |
| 18 | + |
| 19 | +<Tip> |
| 20 | + |
| 21 | +For more details about the `text-to-video` task, check out its [dedicated page](https://huggingface.co/tasks/text-to-video)! You will find examples and related materials. |
| 22 | + |
| 23 | +</Tip> |
| 24 | + |
| 25 | +### Recommended models |
| 26 | + |
| 27 | +- [tencent/HunyuanVideo](https://huggingface.co/tencent/HunyuanVideo): A strong model for consistent video generation. |
| 28 | +- [Lightricks/LTX-Video](https://huggingface.co/Lightricks/LTX-Video): A text-to-video model with high fidelity motion and strong prompt adherence. |
| 29 | +- [Wan-AI/Wan2.1-T2V-1.3B](https://huggingface.co/Wan-AI/Wan2.1-T2V-1.3B): A robust model for video generation. |
| 30 | + |
| 31 | +Explore all available models and find the one that suits you best [here](https://huggingface.co/models?inference=warm&pipeline_tag=text-to-video&sort=trending). |
| 32 | + |
| 33 | +### Using the API |
| 34 | + |
| 35 | + |
| 36 | +<InferenceSnippet |
| 37 | + pipeline=text-to-video |
| 38 | + providersMapping={ {"fal-ai":{"modelId":"Wan-AI/Wan2.1-T2V-14B","providerModelId":"fal-ai/wan-t2v"},"hf-inference":{"modelId":"AdamLucek/Wan2.1-T2V-14B-OldBookIllustrations","providerModelId":"black-forest-labs/FLUX.1-dev"},"novita":{"modelId":"Wan-AI/Wan2.1-T2V-14B","providerModelId":"wan-t2v"},"replicate":{"modelId":"Wan-AI/Wan2.1-T2V-14B","providerModelId":"wavespeedai/wan-2.1-t2v-480p"}} } |
| 39 | +/> |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +### API specification |
| 44 | + |
| 45 | +#### Request |
| 46 | + |
| 47 | +| Payload | | | |
| 48 | +| :--- | :--- | :--- | |
| 49 | +| **inputs*** | _string_ | The input text data (sometimes called "prompt") | |
| 50 | +| **parameters** | _object_ | | |
| 51 | +| ** num_frames** | _number_ | The num_frames parameter determines how many video frames are generated. | |
| 52 | +| ** guidance_scale** | _number_ | A higher guidance scale value encourages the model to generate videos closely linked to the text prompt, but values too high may cause saturation and other artifacts. | |
| 53 | +| ** negative_prompt** | _string[]_ | One or several prompt to guide what NOT to include in video generation. | |
| 54 | +| ** num_inference_steps** | _integer_ | The number of denoising steps. More denoising steps usually lead to a higher quality video at the expense of slower inference. | |
| 55 | +| ** seed** | _integer_ | Seed for the random number generator. | |
| 56 | + |
| 57 | + |
| 58 | +Some options can be configured by passing headers to the Inference API. Here are the available headers: |
| 59 | + |
| 60 | +| Headers | | | |
| 61 | +| :--- | :--- | :--- | |
| 62 | +| **authorization** | _string_ | Authentication header in the form `'Bearer: hf_****'` when `hf_****` is a personal user access token with Inference API permission. You can generate one from [your settings page](https://huggingface.co/settings/tokens). | |
| 63 | +| **x-use-cache** | _boolean, default to `true`_ | There is a cache layer on the inference API to speed up requests we have already seen. Most models can use those results as they are deterministic (meaning the outputs will be the same anyway). However, if you use a nondeterministic model, you can set this parameter to prevent the caching mechanism from being used, resulting in a real new query. Read more about caching [here](../parameters#caching]). | |
| 64 | +| **x-wait-for-model** | _boolean, default to `false`_ | If the model is not ready, wait for it instead of receiving 503. It limits the number of requests required to get your inference done. It is advised to only set this flag to true after receiving a 503 error, as it will limit hanging in your application to known places. Read more about model availability [here](../overview#eligibility]). | |
| 65 | + |
| 66 | +For more information about Inference API headers, check out the parameters [guide](../parameters). |
| 67 | + |
| 68 | +#### Response |
| 69 | + |
| 70 | +| Body | | |
| 71 | +| :--- | :--- | :--- | |
| 72 | +| **video** | _unknown_ | The generated video returned as raw bytes in the payload. | |
| 73 | + |
0 commit comments