Free, Unlimited FLUX AI API
On this page
This tutorial shows you how to add FLUX image generation to your web application using Puter.js, without needing API keys or backend infrastructure. With Puter.js, you can gain access to Black Forest Labs' FLUX models such as FLUX.2 [pro], FLUX.2 [dev], FLUX.2 Klein, FLUX.1 Schnell, and FLUX 1.1 Pro.
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' image generation, making your app practically free to run. You can scale to unlimited users and pay nothing for the AI or server usage.
Getting Started
With Puter.js, you simply add this script tag to your HTML file (works in both <head> and <body>):
<script src="https://js.puter.com/v2/"></script>
This is all you need to start generating images with FLUX models in your application.
Example 1: Basic Image Generation
To generate an image using FLUX.2 Pro, use the puter.ai.txt2img() function:
<html>
<body>
<h1>FLUX.2 Pro Image Generation</h1>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.txt2img(
"A serene Japanese garden with cherry blossoms and a koi pond",
{ model: "black-forest-labs/flux-2-pro", disable_safety_checker: true }
)
.then(imageElement => {
document.body.appendChild(imageElement);
});
</script>
</body>
</html>
Example 2: In-Context Image Editing
To perform image-to-image editing using FLUX.2 [dev], which supports multi-reference image editing, you can provide an input image:
<html>
<body>
<h1>FLUX.2 [dev] Image Editing</h1>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.txt2img("Draw an anime style version of this image.", {
model: "black-forest-labs/flux-2-dev",
input_image: "https://assets.puter.site/doge.jpeg"
}).then((image) => {
document.body.appendChild(image);
});
</script>
<img src="https://assets.puter.site/doge.jpeg">
</body>
</html>
Example 3: Fast and Efficient Generation
FLUX.1 Schnell is optimised for speed, making it ideal for applications that need quick image generation:
<html>
<body>
<h1>FLUX.1 Schnell Fast Generation</h1>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.txt2img(
"A cyberpunk cityscape with neon lights and flying vehicles",
{ model: "black-forest-labs/flux-schnell" }
)
.then(imageElement => {
document.body.appendChild(imageElement);
});
</script>
</body>
</html>
Example 4: Customizable Image Generation
FLUX.2 Klein offers customizable parameters like dimensions, seed control, and diffusion steps for more precise image generation:
<html>
<body>
<h1>FLUX.2 Klein Customizable Generation</h1>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.txt2img(
"A majestic dragon perched on a mountain peak, fantasy art style, detailed scales, dramatic lighting",
{
model: "black-forest-labs/flux-2-klein-9b-base",
width: 768,
height: 1024,
steps: 30,
seed: 42,
disable_safety_checker: true
}
)
.then(imageElement => {
document.body.appendChild(imageElement);
});
</script>
</body>
</html>
Supported FLUX Models
The following FLUX models are supported by Puter.js, which can be used with the puter.ai.txt2img() function:
black-forest-labs/flux-2-klein-4b
black-forest-labs/flux-2-klein-9b-base
black-forest-labs/flux-2-dev
black-forest-labs/flux-2-pro
black-forest-labs/flux-1.1-pro
black-forest-labs/flux-schnell
Conclusion
Using Puter.js, you can integrate FLUX image generation into your app without having to use API keys or set up an AI server yourself. And thanks to the User-Pays model, you can add this feature for free to your application, since your users cover their own image generation usage, not you as the developer.
You can find more details about Puter.js image generation API in the documentation.
Related
- FLUX API Pricing
- Best Image Generation APIs in 2026
- Free, Unlimited GPT Image API
- Free, Unlimited Imagen API
- Free, Unlimited Nano Banana API
- Free, Unlimited Stable Diffusion API
- Free, Unlimited ByteDance Seedream API
- Free, Unlimited Leonardo.Ai API
- Free, Unlimited Ideogram API
- Ideogram API Pricing
- Free, Unlimited HiDream API
- Free, Unlimited RunDiffusion API
- Free, Unlimited Image Generation API
- Free, Unlimited OpenAI API
- Free, Unlimited Claude API
- Free, Unlimited AI API
- Free, Unlimited Veo API
Ship a Full-Stack App with One Prompt
Build an AI chat app using Puter.js
Coding manually? see the guide