chat-image-edit / src /services /openai_file_upload.py
simonlee-cb's picture
feat: working magic replace
9e822e4
raw
history blame
346 Bytes
from openai import OpenAI
from dotenv import load_dotenv
import os
load_dotenv()
class OpenAIFileUpload:
def __init__(self):
self.client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
def upload_image(self, image, purpose) -> str:
file = self.client.files.create(file=image, purpose=purpose)
return file.id