Ship a Full-Stack App with One Prompt

Copy this prompt into your AI coding agent, or open it in one below.

Give this to your AI Create a to-do list app using Puter.js

Coding manually? see the guide

Tutorials

Free, Unlimited Meta Muse API

On this page

In this tutorial, you will learn how to add Meta's Muse models into your application for free using Puter.js. The Muse family from Meta Superintelligence Labs includes Muse Wonder, the Muse Spark line, the open-weight Muse Spark Open, the smaller Muse Glimmer 30B, and the low-cost Muse Ember, covering agentic work, coding, and multimodal tasks.

Puter.js uses the User-Pays model, where users of your application cover their own AI costs. This means you as a developer don't pay anything for your users' usage, making your app practically free to run. You can scale to unlimited users and pay nothing for the AI or server usage.

Getting Started

To use Puter.js, import our npm module in your project:

// npm install @heyputer/puter.js
import { puter } from '@heyputer/puter.js';

Or alternatively, add our script via CDN if you are working directly with HTML, simply add it to the <head> or <body> section of your code:

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

Nothing else is required to start using Puter.js for free access to Meta's Muse models.

Example 1: Basic Text Generation with Muse Wonder

To generate text, use the puter.ai.chat() function with Muse Wonder, Meta's agent model for long, multi-step tasks:

puter.ai.chat(
    "Plan the steps to migrate a small web app from REST to GraphQL, and list the risks at each step.",
    { model: "meta/muse-wonder" }
).then(response => {
    puter.print(response);
});

Full code example:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.chat(
            "Plan the steps to migrate a small web app from REST to GraphQL, and list the risks at each step.",
            { model: "meta/muse-wonder" }
        ).then(response => {
            puter.print(response);
        });
    </script>
</body>
</html>

Example 2: Streaming a Coding Task with Muse Spark 1.3

For longer responses such as generated code, use streaming to show the output as it arrives. This example uses Muse Spark 1.3:

<html>
<body>
    <div id="response"></div>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        async function streamResponse() {
            const outputDiv = document.getElementById('response');

            const response = await puter.ai.chat(
                "Write a JavaScript function that debounces another function, then explain how it works line by line.",
                { model: 'meta/muse-spark-1.3', stream: true }
            );

            for await (const part of response) {
                if (part?.text) {
                    outputDiv.innerHTML += part.text;
                }
            }
        }

        streamResponse();
    </script>
</body>
</html>

Example 3: Image Analysis with Muse Glimmer 30B

Muse models accept images as input. Pass an image URL to puter.ai.chat() along with your prompt. This example uses Muse Glimmer 30B:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.chat(
            "What do you see in this image?",
            "https://assets.puter.site/doge.jpeg",
            { model: "meta/muse-glimmer-30b" }
        ).then(response => {
            puter.print(response);
        });
    </script>
</body>
</html>

Example 4: Tool Calling with Muse Spark Open

Muse models can call functions you define in your code. Pass a tools array to puter.ai.chat(), and the model returns a structured tool call when it needs one. This example uses Muse Spark Open, Meta's open-weight model for agentic and tool-use work:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        // Define a weather tool
        const tools = [{
            type: "function",
            function: {
                name: "get_weather",
                description: "Get the current weather for a city",
                parameters: {
                    type: "object",
                    properties: {
                        city: { type: "string", description: "City name, e.g. Tokyo" }
                    },
Show 20 more lines...
<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        // Define a weather tool
        const tools = [{
            type: "function",
            function: {
                name: "get_weather",
                description: "Get the current weather for a city",
                parameters: {
                    type: "object",
                    properties: {
                        city: { type: "string", description: "City name, e.g. Tokyo" }
                    },
                    required: ["city"]
                }
            }
        }];

        puter.ai.chat(
            "What's the weather like in Tokyo right now?",
            { model: "meta/muse-spark-open", tools }
        ).then(response => {
            if (response.message.tool_calls) {
                const call = response.message.tool_calls[0];
                const args = JSON.parse(call.function.arguments);
                puter.print(`Model requested ${call.function.name} with city: ${args.city}`);
            } else {
                puter.print(response);
            }
        });
    </script>
</body>
</html>
Collapse code

Your code runs the requested function and sends the result back in a follow-up message, so the model can write its final answer from that data.

Example 5: Routing Requests with Muse Ember

Muse Ember is Meta's smallest and most efficient Muse model, built for repetitive agent work such as routing, document extraction, and tool calls. This example uses it to sort incoming support messages into categories:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        const messages = [
            "I was charged twice for my subscription this month.",
            "The export button does nothing when I click it.",
            "Can you add a dark mode to the dashboard?"
        ];

        for (const message of messages) {
            puter.ai.chat(
                `Classify this support message as billing, bug, or feature_request. Reply with the category only.\n\nMessage: ${message}`,
                { model: "meta/muse-ember" }
            ).then(response => {
                puter.print(`${message} → ${response}<br>`);
            });
        }
    </script>
</body>
</html>

Your code can use the returned category to decide where each message goes next, such as a billing handler or a larger model like Muse Wonder for the harder cases.

Example 6: Compare Muse Spark Versions

All Muse Spark versions share the same API, so you can switch between them by changing the model parameter. This example sends the same prompt to Muse Spark 1.3 and Muse Spark 1.2:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        const prompt = "Explain the difference between a process and a thread.";

        puter.ai.chat(prompt, { model: "meta/muse-spark-1.3" })
            .then(response => {
                puter.print("<h2>Muse Spark 1.3</h2>");
                puter.print(response);
            });

        puter.ai.chat(prompt, { model: "meta/muse-spark-1.2" })
            .then(response => {
                puter.print("<h2>Muse Spark 1.2</h2>");
                puter.print(response);
            });
    </script>
</body>
</html>

Available Models

The following Meta Muse models are supported by Puter.js:

meta/muse-ember
meta/muse-spark-open
meta/muse-wonder
meta/muse-spark-1.3
meta/muse-glimmer-30b
meta/muse-spark-1.2
meta/muse-spark-1.1

Replace the model name in the puter.ai.chat() function to use a different model.

Conclusion

You now have free access to Meta's Muse models using Puter.js. This allows you to use Muse Wonder, Muse Spark, Muse Spark Open, Muse Glimmer, and Muse Ember for text generation, coding, tool calling, image understanding, and request routing without needing API keys or backend infrastructure.

Ship a Full-Stack App with One Prompt

Give this to your AI Build an AI chat app using Puter.js

Coding manually? see the guide