API Wrapper for HappyAccidents
Project description
HappyAccidentsAPI
At the moment, HappyAccidents has not provided an official API and the library is built on the basis of the client API. Because of this, you may find bugs and shortcomings, if this happened, please provide a report in Issues.
Installation
# Via pip
## Linux/macOS
python3 -m pip install -U happyaccidentsapi
## Windows
py -3 -m pip install -U happyaccidentsapi
# Via poetry
poetry add happyaccideentsapi
# [SOON]Via pacman
# pacman -Sy python-happyaccidentsapi
Quick example
import asyncio
from happyaccidentsapi import ClientAPI
from happyaccidentsapi.models import CreateInferenceParams
async def main():
api = ClientAPI(token="...")
model = (await api.fetch_metadata_items("Stable Diffusion v1.5")).first()
inference_params = CreateInferenceParams(
modelId=model.id,
prompt="Beautiful girl on the beach",
numImagesToGenerate=5,
)
inference = await api.create_inference(inference_params) # <InferenceHistoricalResult ...>
for image in inference.images: # [<ImageRecord ...>, ...]
print(image.get_url()) # https://https://ik.imagekit.io/.../result-4.png
await image.save(f"./images/{image.id}-{image.filename}")
if __name__ == "__main__":
asyncio.run(main())
NOTE: It is not advised to leave your token directly in your code, as it allows anyone with it to access your account. If you intend to make your code public you should store it securely.
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
happyaccidentsapi-0.0.0.tar.gz
(13.1 kB
view hashes)
Built Distribution
Close
Hashes for happyaccidentsapi-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 142f020ca39c07db34ac6e671882e4a15379a318ae45d20ef25c81ae47643984 |
|
MD5 | 9ac9b0375c8172ad55eb2097eaab214b |
|
BLAKE2b-256 | eb012e320a6e41a2537a1508ffad0b95560b24563f2b2ebc4e3516b99a4d4ffc |