Inference Client Errors

Hi! I recently hosted " [runwayml/stable-diffusion-v1-5]" on the InferenceApi. I am trying to hit the endpoint and store the resulting image locally. My code is as follows:

def client():
    token = '<my_token>'
    client = InferenceClient(
    image = client.text_to_image("An astronaut riding a horse on the moon.")"astronaut.png")

However I keep getting this error output:

raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x1042384f0>

Any help here would be much appreciated!