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(
        model="<my_model_endpoint>",
        token=token
    )
    image = client.text_to_image("An astronaut riding a horse on the moon.")
    image.save("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!