Attribute error in Module 3

repeatedly getting same error when i run the code
screenshot is attached below.

Hi @sufiyaanzafar2003

Please modify your response statement on the 4th line to response = client.images.generate

do try this and let us know. If yoou still face any issues, please fee free to get back to us

getting this error now…

Hi @sufiyaanzafar2003

This program is incomplete. Please check module 3 in the training and you will find the entire working code of the project.

If you still get issues, please feel free to get back to us

Try this code

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('''
  <!DOCTYPE html>
    <title>Infinite Image Generator</title>
    <link href="" rel="stylesheet">
    <div class="container">
    <h1 class="my-4">Custom Image Generator</h1>
    <form id="tutorial-form" onsubmit="event.preventDefault(); generateTutorial();" class="mb-3">
    <div class="mb-3">
    <label for="components" class="form-label">Textual Description of the Image:</label>
    <input type="text" class="form-control" id="components" name="components" placeholder="Enter the Description (Ex: A Lion in a Cage)" required>
    <button type="submit" class="btn btn-primary">Share with the Image</button>
    <div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
    <button class="btn btn-secondary btn-sm" onclick="copyToClipboard()">Copy</button>
    <div class="card-body">
    <p id="output" style="white-space: pre-wrap;"></p>
    <img id="myImage" src="" style="width: auto; height: 300px;">
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)

@sufiyaanzafar2003 Is your issue resolved after following the above steps? Do share the screenshot of your code and error if you are still facing issues after the above step.