Spaces:
Runtime error
Runtime error
import gradio as gr | |
from openai import OpenAI | |
def generate_images(token, size, quality, style, prompt): | |
client = OpenAI(api_key= token, base_url= "https://zukijourney.xyzbot.net/v1") | |
response = client.images.generate(prompt=prompt, model = 'dall-e-3', n=1, quality=quality, size=size, style=style) | |
return response.data[0].url | |
with gr.Blocks(analytics_enabled=False) as demo: | |
gr.Markdown("Generate images using OpenAI's API") | |
with gr.Row(): | |
token_input = gr.Textbox(label="API Token", placeholder="Enter your OpenAI API token here") | |
size_input = gr.Radio(choices=["1024x1024", "1792x1024", "1024x1792"], label="Image Size", value="1024x1024") | |
quality_input = gr.Radio(choices=["standard", "hd"], label="Quality", value="standard") | |
style_input = gr.Radio(choices=["vivid", "natural"], label="Style", value="vivid") | |
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter a prompt for the image generation") | |
submit_button = gr.Button("Generate") | |
output_images = gr.Gallery(label="Generated Images") | |
submit_button.click( | |
generate_images, | |
inputs=[token_input, size_input, quality_input, style_input, prompt_input], | |
outputs=output_images | |
) | |
demo.launch() |