Created
May 7, 2025 00:28
-
-
Save alexandreaquiles/119b54eb57505e7aa41d8df564703986 to your computer and use it in GitHub Desktop.
Revisions
-
alexandreaquiles created this gist
May 7, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ import base64 import time import os from dotenv import load_dotenv from openai import OpenAI load_dotenv() client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) prompt = """ Generate a Dragon Ball Z style version of the photo attached. """ result = client.images.edit( model="gpt-image-1", image=open("eu-gleice-cachoeira.jpg", "rb"), prompt=prompt ) image_base64 = result.data[0].b64_json image_bytes = base64.b64decode(image_base64) # Save the image to a file with open(f"dragonball-{time.time_ns()}.png", "wb") as f: f.write(image_bytes)