Images: Generate, but not render

Is it possible to generate an image or acknowledge an image’s URL without actually displaying the image?

Perhaps just displaying the hyperlink in the chat…

It seems like a simple request, but I’ve been arguing with my pickaxe about this concept for 12 hours :upside_down_face:

Thanks legends!

Right now, that’s not possible with the current image actions. But likely possible through a a custom action. @nathanielmhld could probably tell how you how to do it.

1 Like

This is not possible currently.

2 Likes

No problem, I’ll create the image externally :smiley:

Cheers guys!

Hi @fluent_friends,

You can do it with a custom action using Dalle.

import os
import requests

def generate_dalle_3_image_own_key_copy(image_prompt: str):
“”"
Allows your Pickaxe to generate DALL·E 3 images and prints the image URL.

Args:
    image_prompt (string): Prompt for the image to be generated
"""

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": "dall-e-3",
    "n": 1,
    "size": "1024x1024"
}

response = requests.post(api_url, headers=headers, json=data)

if response.status_code == 200:
    image_url = response.json()["data"][0]["url"]
    # Print the generated image URL instead of downloading the image
    print(f"Generated image URL: {image_url}")
    return image_url
else:
    print(f"Failed to generate image. Status code: {response.status_code}")
    print(f"Response: {response.text}")
    return None
2 Likes

Thankyou Ab, I appreciate your suggestions. Cheers