Spaces:
Running
Running
Tobias Geisler
commited on
Commit
·
6504b4e
1
Parent(s):
cf7cca5
api fix
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
import
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
|
5 |
-
# Ensure the OPENAI_API_KEY environment variable is set
|
6 |
-
|
7 |
|
8 |
-
if
|
9 |
raise ValueError("Die Umgebungsvariable OPENAI_API_KEY ist nicht gesetzt.")
|
10 |
|
11 |
def generate_image(hair_color, mood, eye_color):
|
@@ -16,10 +16,10 @@ def generate_image(hair_color, mood, eye_color):
|
|
16 |
print("Prompt:", prompt)
|
17 |
|
18 |
try:
|
19 |
-
response =
|
20 |
model="dall-e-3",
|
21 |
prompt=prompt,
|
22 |
-
size="
|
23 |
quality="standard", # Choose "standard" or "hd" for higher quality
|
24 |
n=1 # Number of images to generate
|
25 |
)
|
|
|
1 |
+
from openai import OpenAI
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Ensure the OPENAI_API_KEY environment variable is set; it's automagically loaded into the client
|
6 |
+
client = OpenAI()
|
7 |
|
8 |
+
if client.api_key is None:
|
9 |
raise ValueError("Die Umgebungsvariable OPENAI_API_KEY ist nicht gesetzt.")
|
10 |
|
11 |
def generate_image(hair_color, mood, eye_color):
|
|
|
16 |
print("Prompt:", prompt)
|
17 |
|
18 |
try:
|
19 |
+
response = client.images.create(
|
20 |
model="dall-e-3",
|
21 |
prompt=prompt,
|
22 |
+
size="1024x1024", # Choose from "1024x1024", "1024x1792", or "1792x1024"
|
23 |
quality="standard", # Choose "standard" or "hd" for higher quality
|
24 |
n=1 # Number of images to generate
|
25 |
)
|