Tutorials

Free, Unlimited Wan AI API

This tutorial shows how to use Puter.js for generating videos with Wan 2.2 AI models for free, without needing API keys or backend infrastructure. With Puter.js, you gain immediate access to Wan AI's powerful models including Wan 2.2 Text-to-Video (T2V) for creating videos from text prompts and Wan 2.2 Image-to-Video (I2V), all callable directly from client-side JavaScript.

Puter pioneered the "User-Pays" model, allowing you to integrate advanced AI video generation into your apps while users handle their individual usage costs. This approach lets you deliver video generation features without incurring costs, managing API credentials, or configuring server infrastructure.

Getting Started

Using Puter.js requires zero configuration and no API keys. Simply add this script tag to your HTML file (works in both <head> and <body> sections):

<script src="https://js.puter.com/v2/"></script>

This single script tag is all you need to start generating videos with Wan 2.2 models in your application.

Example 1: Generate video from text with Wan 2.2 Text-to-Video

Wan 2.2 Text-to-Video (T2V) enables powerful video generation from text descriptions. To generate a video from a text prompt, use the puter.ai.txt2vid() function:

puter.ai.txt2vid(
    "A fox sprinting through a snow-covered forest at dusk",
    { model: "Wan-AI/Wan2.2-T2V-A14B" }
)
.then(videoElement => {
    document.body.appendChild(videoElement);
    videoElement.addEventListener('loadeddata', () => videoElement.play().catch(() => {}));
})

Full code example:

<html>
<body>
    <h1>Wan 2.2 Text-to-Video Generation</h1>
    <div id="status"></div>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        // Start timer
        const status = document.getElementById('status');
        const startTime = Date.now();
        const timerInterval = setInterval(() => {
            const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
            status.textContent = `Loading (${elapsed} seconds)`;
        }, 100);

        // Generate video from text
        puter.ai.txt2vid(
            "A fox sprinting through a snow-covered forest at dusk",
            { model: "Wan-AI/Wan2.2-T2V-A14B" }
        )
        .then(videoElement => {
            document.body.appendChild(videoElement);
            videoElement.addEventListener('loadeddata', () => videoElement.play().catch(() => {}));

            // Clear timer and show finished status
            clearInterval(timerInterval);
            const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
            status.textContent = `Finished (${totalTime} seconds)`;
        }).catch(error => {
            console.error(error);
            clearInterval(timerInterval);
            status.textContent = JSON.stringify(error);
        })
    </script>
</body>
</html>

Example 2: Generate video from image with Wan 2.2 Image-to-Video

Wan 2.2 Image-to-Video (I2V) enables transforming static images into dynamic videos. To generate a video from an image, use the puter.ai.txt2vid() function with an image URL parameter:

<html>
<body>
    <h1>Wan 2.2 Image-to-Video Generation</h1>
    <div id="status"></div>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        // Start timer
        const status = document.getElementById('status');
        const startTime = Date.now();
        const timerInterval = setInterval(() => {
            const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
            status.textContent = `Loading (${elapsed} seconds)`;
        }, 100);

        // Generate video from image
        puter.ai.txt2vid(
            "A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail.",
            {
                model: "Wan-AI/Wan2.2-I2V-A14B",
                image_url: "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
            }
        )
        .then(videoElement => {
            document.body.appendChild(videoElement);
            videoElement.addEventListener('loadeddata', () => videoElement.play().catch(() => {}));

            // Clear timer and show finished status
            clearInterval(timerInterval);
            const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
            status.textContent = `Finished (${totalTime} seconds)`;
        }).catch(error => {
            console.error(error);
            clearInterval(timerInterval);
            status.textContent = JSON.stringify(error);
        })
    </script>
</body>
</html>

Available Models

The following Wan 2.2 AI models are supported by Puter.js:

Wan-AI/Wan2.2-T2V-A14B
Wan-AI/Wan2.2-I2V-A14B



You're all set! With Puter.js, you've unlocked free access to Wan 2.2's powerful video generation models. Build stunning AI-powered video generation features into your apps—whether transforming text or images into videos. All of this comes without API keys to manage, no backend servers to maintain, and zero infrastructure costs. Experience truly serverless video generation with Wan AI!

Related

Free, Serverless AI and Cloud

Start creating powerful web applications with Puter.js in seconds!

Get Started Now

Read the Docs Try the Playground