test2.py 556 Bytes
Newer Older
chenyuanjie committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import requests

response = requests.post(
    f"https://api.stability.ai/v2beta/stable-image/generate/ultra",
    headers={
        "authorization": f"sk-f2iOAkResIloOY3yE6xk2LlQbVrtQi3EczZDjA3n9ns7bmeR",
        "accept": "image/*"
    },
    files={"none": ''},
    data={
        "prompt": "A little cat is in a bedroom with a bed, TV, and sofa",
        "output_format": "webp",
    },
)

if response.status_code == 200:
    with open("./cat01.webp", 'wb') as file:
        file.write(response.content)
else:
    raise Exception(str(response.json()))