Image-1 is outstanding and I tried to create a custom action and it failed, not sure what is wrong as I am not a real engineer, this appears to be an easy win for the community. This API is light years ahead of others offered.
you could also just call a make.com scenario that will run the API
I would much rather have it as an action. I do not want to build this custom to me but have it for the community at large.
Understood - but that may take some time before it is released.
Using a make.com is still calling an action and would get you up and running almost immediately.
Ok thanks for the help, I created the make.com action but the image is not displaying in my pickaxe. The instructions only say that it will display once it is finished but it is not returning the image json that the make.com web hook is returning
Can you create a loom showing what you did - it is tough to troubleshoot without knowing what you actually did.
It seems that someone created the action for gpt images now. I’ve been testing it and don’t feel the issue was at make.com and more of the Ui is not waiting long enough for the response to show?
Some people are having the same issue via the action that I had from make.
The actions does seem to work for me for simple requests but if it is a longer prompt for a more detailed image the UI never shows the image. Only a description of what it creates.
Do you have the link to it ?
Yes, I always end up changing the timing in the action for those that take longer to generate.
I don’t have the action link at the moment. It showed up under latest actions. “Gpt images” or something along those lines.
@gilstrickland in the action code, you will need to increase the time-out from 10 to 30 seconds (or whatever time needed for the make scenario to execute)
How do you do that? I looked at the code and there is no way to set a time-out
@gilstrickland if you clone the create GPT image action you can add the timeout as per below (line 33)
import os
import requests
import base64
import shutil
def generate_gpt_images_copy(image_prompt: str):
"""
Allows your Pickaxe to generate GPT Images.
Args:
image_prompt (string): Prompt for the image to be generated
Envs:
OPENAI_API_KEY (string): Your OpenAI API key, required for generating images with GPT Image
"""
# Insert your PYTHON code below. You can access environment variables using os.environ[].
# Currently, only the requests library is supported, but more libraries will be available soon.
# Use print statements or return values to display results to the user.
# If you save a png, pdf, csv, jpg, webp, gif, or html file in the root directory, it will be automatically displayed to the user.
# You do not have to call this function as the bot will automatically call and fill in the parameters.
api_key = os.environ["OPENAI_API_KEY"]
api_url = "https://api.openai.com/v1/images/generations"
headers = {
"Content-Type": "application/json",
}
headers["Authorization"] = f"Bearer {api_key}"
data = {"prompt": image_prompt, "model": "gpt-image-1", "n": 1, "size": "1024x1024"}
response = requests.post(api_url, headers=headers, json=data, timeout=60) # <- how long to wait (in seconds) before aborting the HTTP request
if response.status_code == 200:
image_base64 = response.json()["data"][0]["b64_json"]
image_bytes = base64.b64decode(image_base64)
output_file = "gpt-image.png"
with open(output_file, "wb") as f:
f.write(image_bytes)
shutil.copy(output_file, "generated_image.png")
else:
print("Failed to generate image")