Aniquel commited on
Commit
f0efdce
1 Parent(s): 78610a7
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -1,8 +1,12 @@
1
  import gradio as gr
2
  import requests
 
3
  from PIL import Image
4
  from io import BytesIO
5
 
 
 
 
6
  # Define the function that generates the image
7
  def generate_image(prompt):
8
  response = requests.post("https://api.openai.com/v1/images/generations", json={
@@ -13,7 +17,7 @@ def generate_image(prompt):
13
  "response_format": "url"
14
  }, headers={
15
  "Content-Type": "application/json",
16
- "Authorization": "Bearer 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"
17
  })
18
  response.raise_for_status()
19
  image_url = response.json()["data"][0]["url"]
 
1
  import gradio as gr
2
  import requests
3
+ imort openai
4
  from PIL import Image
5
  from io import BytesIO
6
 
7
+ openai.api_key = os.getenv("OPENAI_API_KEY")
8
+
9
+
10
  # Define the function that generates the image
11
  def generate_image(prompt):
12
  response = requests.post("https://api.openai.com/v1/images/generations", json={
 
17
  "response_format": "url"
18
  }, headers={
19
  "Content-Type": "application/json",
20
+ "Authorization": "Bearer "
21
  })
22
  response.raise_for_status()
23
  image_url = response.json()["data"][0]["url"]