Initial commit

This commit is contained in:
Brayd 2023-01-15 14:32:11 +01:00
commit 25347a86e6
Signed by: brayd
GPG Key ID: C2B176B9DEB8BA48
1 changed files with 24 additions and 0 deletions

24
main.py Normal file
View File

@ -0,0 +1,24 @@
import openai
import datetime
import requests
openai.api_key = "API_TOKEN"
promtInput = input("Your prompt: ")
response = openai.Image.create(
prompt = promtInput,
n = 4,
size = "1024x1024"
)
# Current time
current_time = datetime.datetime.now()
# Format current time to a filename and save it to disk
for i in range(4):
image_url = response['data'][i]['url']
formatDateTime = str(current_time.year) + "-" + str(current_time.month) + "-" + str(current_time.day) + "_" + str(current_time.hour) + "-" + str(current_time.minute) + "-" + str(current_time.second) + "_Image-" + str(i+1) + ".png"
img_data = requests.get(image_url).content
with open(formatDateTime, 'wb') as handler:
handler.write(img_data)
print("Image " + str(i+1) + " saved.")