create image

Image Generation and Handling

First, send a request to generate an image. You will receive a request_id in the response, which allows you to track the generation status and retrieve the final image.

from zerogpt import Client

client = Client()
request_id = client.create_image('a beautiful girl')['data']['request_id']

With the obtained request_id, retrieve the image.

image = client.get_image(request_id)
image.download('image.png')

In the example above, we used the download() method to load an image. However, you can preview the image using image.open(), which is particularly handy on a computer. Note: The open() method doesn't work on mobile devices.

Below is an example of an interactive program that allows users to view and save images upon request:

from zerogpt import Client

client = Client()
request_id = client.create_image('a beautiful girl')['data']['request_id']
image = client.get_image(request_id)

image.open()
if input('save image? (y/n): ').lower() == 'y':
    image.download('image.png')

Last updated

Was this helpful?