Tutorials
Free, Unlimited GPT Image API
This tutorial will show you how to use Puter.js to access GPT Image for free image generation, without needing an OpenAI API key. Puter.js is completely free and open-source, allowing you to provide your users with OpenAI's image generation capabilities without any API keys or usage restrictions. Using Puter.js, you can access GPT Image-1 directly from your frontend code without any server-side setup.
GPT Image-1 is OpenAI's latest image generation model that creates high-quality images from text descriptions with flexible quality settings. Puter is the pioneer of the "User Pays" model, which allows developers to incorporate AI capabilities into their applications while each user covers their own usage costs. This model enables developers to offer advanced image generation capabilities to users at no cost to themselves, without any API keys or server-side setup.
Getting Started
You can use Puter.js without any API keys or sign-ups. To start using Puter.js, include the following script tag in your HTML file, either in the <head> or <body> section:
<script src="https://js.puter.com/v2/"></script>
Nothing else is required to start using Puter.js for free access to GPT Image generation capabilities.
Example 1Generate a simple image with GPT Image
To generate an image using GPT Image, use the puter.ai.txt2img() function with the gpt-image-1 model:
puter.ai.txt2img("A serene Japanese garden with cherry blossoms", {
model: "gpt-image-1"
})
.then(imageElement => {
document.body.appendChild(imageElement);
});
Full code example:
<html>
<body>
<h1>GPT Image Generation</h1>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.txt2img("A serene Japanese garden with cherry blossoms", {
model: "gpt-image-1"
})
.then(imageElement => {
document.body.appendChild(imageElement);
});
</script>
</body>
</html>
Example 2Use different quality settings
GPT Image-1 supports three quality levels: high, medium, and low. You can specify the quality to balance between image quality and generation speed:
<html>
<body>
<h2>Quality Comparison</h2>
<div id="images"></div>
<script src="https://js.puter.com/v2/"></script>
<script>
const prompt = "A cyberpunk street scene with neon lights";
const container = document.getElementById('images');
// Low quality (fastest)
puter.ai.txt2img(prompt, { model: "gpt-image-1", quality: "low" })
.then(img => {
const div = document.createElement('div');
div.innerHTML = '<h3>GPT Image-1 (Low Quality)</h3>';
div.appendChild(img);
container.appendChild(div);
});
// Medium quality
puter.ai.txt2img(prompt, { model: "gpt-image-1", quality: "medium" })
.then(img => {
const div = document.createElement('div');
div.innerHTML = '<h3>GPT Image-1 (Medium Quality)</h3>';
div.appendChild(img);
container.appendChild(div);
});
// High quality (best quality, slower)
puter.ai.txt2img(prompt, { model: "gpt-image-1", quality: "high" })
.then(img => {
const div = document.createElement('div');
div.innerHTML = '<h3>GPT Image-1 (High Quality)</h3>';
div.appendChild(img);
container.appendChild(div);
});
</script>
</body>
</html>
Other image generation models
GPT Image-1 is not the only image generation model supported by Puter.js. You can also use the following models with the puter.ai.txt2img() function:
gpt-image-1
gpt-image-1-mini
gemini-2.5-flash-image-preview
dall-e-3
That's it! You now have free access to OpenAI's powerful GPT Image-1 model using Puter.js. This allows you to create applications with cutting-edge AI-powered image generation capabilities without needing OpenAI API keys, backend infrastructure, or managing costs. True serverless image generation with OpenAI's latest technology!
Related
Free, Serverless AI and Cloud
Start creating powerful web applications with Puter.js in seconds!
Get Started Now