I am working on a project which can generate the sketch of a person based on the prompts given by user. But as always my code is not working and giving me APIRemovedInV1 error.
# Import necessary libraries
import openai
from IPython.display import display, Image
# Set up your OpenAI API key
openai.api_key = 'my_api_key'
# function to generate a sketch
def generate_sketch(prompt):
response = openai.Image.create(
prompt=prompt,
n=1,
size="512x512"
)
image_url = response['data'][0]['url']
return image_url
# function to display the sketch
def display_sketch(image_url):
display(Image(url=image_url))
# user's code to get input and generate the sketch
description = input("Describe the person: ")
image_url = generate_sketch(description)
display_sketch(image_url)
I thought it would work as expected but it doesn’t.
New contributor
Arnav Rangari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.