Blog

Grok Image Generation Is Now Available in Puter.js

On this page

Puter.js now supports Grok-2-Image, xAI's text-to-image model. Generate visuals straight from the browser—no API keys or backend required.

What is Grok-2-Image?

Grok-2-Image turns prompts into high-quality images with low latency. In Puter.js, it returns a ready-to-use DOM Image element you can append, download, or send to a canvas.

Examples

Basic image generation

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.txt2img({
            prompt: "A cozy cabin at dusk in the snow, cinematic lighting",
            model: "grok-2-image",
            provider: "xai",
        }).then((image) => {
            document.body.appendChild(image);
        });
    </script>
</body>
</html>

Get Started Now

Add one script tag to your page:

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

Then call puter.ai.txt2img with model: "grok-2-image" and provider: "xai". Puter handles auth, rate limits, and retries—no keys or servers needed.

Learn more:

Free, Serverless AI and Cloud

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

Get Started Now

Read the Docs Try the Playground