File size: 1,255 Bytes
a7fe9c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()