Image not generating in dall-e project

i used the same code as present in the training. the image is not generating even after waiting for minutes. I also tried using the code provided in one of the responses… still the same.

try copy pasting below code , it has worked for me and make sure api key is correct

from boltiotai import openai
import os
from flask import Flask, render_template_string, request

openai.api_key = os.environ[‘OPENAI_API_KEY’]

def generate_tutorial(components):
response = openai.Images.create(

image_url = response[‘data’][0][‘url’]
return image_url

app = Flask(name)

@app.route(‘/’, methods=[‘GET’, ‘POST’])
def hello():
output = “”

if request.method == ‘POST’:
components = request.form[‘components’]
output = generate_tutorial(components)

return render_template_string(‘’’

Infinite Image Generator

/* Your CSS styles go here */

Custom Image Generator

Textual Description of the Image:

Share with the Image


async function generateTutorial() {
const components = document.querySelector(‘#components’).value;
const output = document.querySelector(‘#output’);
const imgElement = document.getElementById(‘myImage’);
const response = await fetch(‘/generate’, {
method: ‘POST’,
body: new FormData(document.querySelector(‘#tutorial-form’))
const imageUrl = await response.text();
imgElement.src = imageUrl;
output.textContent = ‘Generating an image for you…’;

            function copyToClipboard() {
                const imgElement = document.getElementById('myImage');
                const imageUrl = imgElement.src;
                const textarea = document.createElement('textarea');
                textarea.value = imageUrl;
                alert('Copied to clipboard');

@app.route(‘/generate’, methods=[‘POST’])
def generate():
components = request.form[‘components’]
return generate_tutorial(components)

if name == ‘main’:‘’, port=8080)

still does not work fine. image got generated only twice. @sneharsh.kerkar

Hi @muthammamaanya

The image generator tool takes some to generate the image. I would suggest you to be patient and not keep clicking the generate button since the image generation limit is up to 10 images.

If you have any other issues, please feel free to get back to us.

@muthammamaanya After you shared the repl with our email id on Replit we reviewed your code. You were getting the error that your image credits had been exceed.

As the image generation takes about 8-10 seconds you have to wait for sometime for the image to generate. If you click on the generate button multiple times, your credits will keep getting used. As a special case we have restored your credits and you have confirmed on Whatsapp that your issued was solved after this.

As we can provide limited credits, you can check your used credits while generating the images to ensure that you don’t finish your credits before the training is completed.