OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

APIRemovedInV1: You tried to access openai.Image, but this is no longer supported in openai>=1.0.0

  • Thread starter Thread starter Arnav Rangari
  • Start date Start date
A

Arnav Rangari

Guest
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.

Code:
# 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.
<p>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.</p>
<pre><code># 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)
</code></pre>
<p>I thought it would work as expected but it doesn't.</p>
 

Latest posts

Online statistics

Members online
0
Guests online
3
Total visitors
3
Ads by Eonads
Top