Quotation_App / test_openai.py
NayabShakeel's picture
Create test_openai.py
d9d4282 verified
raw
history blame
569 Bytes
import openai
# Set your OpenAI API key
openai.api_key = "YOUR_OPENAI_API_KEY" # Replace with your OpenAI API key
# Define a quote
random_text = "The only way to do great work is to love what you do."
# Call OpenAI's DALL·E model to generate an image from the quote
response = openai.Image.create(
prompt=random_text, # Use the random quote as the prompt
n=1, # Generate 1 image
size="1024x1024" # Image size
)
# Extract the image URL from the response
image_url = response['data'][0]['url']
# Print the image URL
print(f"Image URL: {image_url}")