Skip to main content
This guide demonstrates how to run the Mochi-1 text-to-video model on Beam. Mochi-1 is a powerful model for generating high-quality videos based on text prompts.

View the Code

See the code for this example on Github.

Introduction

Mochi-1 is a state-of-the-art text-to-video model. This guide will help you deploy and use the model as a serverless API on Beam.

Upload Model Weights

Before using the Mochi-1 model, you need to upload its weights to Beam. This is handled by the upload.py script:

Steps to Run the Script

Run the script locally to upload the weights:
Once the weights are uploaded, the generate_video endpoint can access them for inference.

Setup Remote Environment

The model and its dependencies are defined in the mochi_image. Here’s how it’s configured:
The mochi_image includes all necessary Python packages and system dependencies:

Inference Function

The generate_video function processes text prompts and generates a video:
This example uses gpu_count=2 to run across multiple GPUs. Multi-GPU workloads are available by request only — please send us a message in Slack, and we’ll enable it on your account.

Deployment

Deploy the API to Beam:

Invoking the API

To invoke the API, send a POST request with the following payload:
Here’s an example of a cURL request:

Example Output

The API will return a generated video URL. Here’s an example:

Example Video

Here is an example video generated by the Mochi-1 model:

Summary

You’ve successfully deployed and tested a Mochi-1 text-to-video generation API using Beam.