API Code Examples
cURL
curl -X POST \
https://ai-image.justpump.pro \
-H 'Content-Type: application/json' \
-d '{
"prompt": "A beautiful sunset over a mountain lake"
}' \
--output image.pngJavaScript
async function generateImage(prompt) {
try {
const response = await fetch('https://ai-image.justpump.pro', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt })
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.message || 'Failed to generate image');
}
// Response is a PNG image
const imageBlob = await response.blob();
return imageBlob;
} catch (error) {
console.error('Error:', error);
throw error;
}
}
// Example usage with HTML img element
async function displayGeneratedImage(prompt) {
try {
const imageBlob = await generateImage(prompt);
const imageUrl = URL.createObjectURL(imageBlob);
const imgElement = document.createElement('img');
imgElement.src = imageUrl;
document.body.appendChild(imgElement);
} catch (error) {
console.error('Failed to generate image:', error);
}
}Python
Last updated