Skip to main content
This example streams a live world model with Matrix-Game. WebRTC is the transport layer for low-latency, real-time video streaming.

πŸš€ Try this Example

View the complete source code on GitHub. Steps to run:
  1. Install fal:
pip install fal
  1. Authenticate:
fal auth login
  1. Clone the demos repo and install dependencies:
git clone https://github.com/fal-ai-community/fal-demos.git
cd fal-demos
pip install -e .
  1. Run the backend (local dev):
fal run fal_demos/video/matrix_webrtc/matrix.py::MatrixGame2
  1. Run the frontend:
cd fal_demos/video/matrix_webrtc/frontend
npm install
FAL_KEY=myfalkey npm run dev
Open the Vite dev server in your browser and set the Endpoint field to the full real-time endpoint (for example: myuser/myapp/webrtc).
This deployment flow is the same as other serverless examples, like Deploy Text-to-Image Model, but the request path is a real-time endpoint.

Deploy to fal

To host the backend, deploy the app and use the resulting endpoint in the UI:
fal deploy fal_demos/video/matrix_webrtc/matrix.py::MatrixGame2
The real-time endpoint will be your-username/your-app/webrtc.

Game modes and seed image

The backend defaults to the universal mode in MatrixGame2.setup(). Other supported modes include universal and gta_drive. To switch modes, update self._default_mode and self._mode_seed_dirs in matrix.py. The seed image path is derived in MatrixGame2.setup() from the selected mode. If you want a different seed, update self._default_seed_path in matrix.py.