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.
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
Release files for happyaccidentsapi 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| happyaccidentsapi-0.0.3.tar.gz | 12.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| happyaccidentsapi-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.1 kB
Release files / happyaccidentsapi-0.0.3.tar.gz
| Download URL | happyaccidentsapi-0.0.3.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20b19ac87292e158099527b7ea5e023ff5f68adfeb41df604537d8993511d1ca
|
|
BLAKE2b-256 checksum How to use checksums |
ee7cd4d8ab280e8c7996b846bd3fa3a261d13a7a390fc384dffcb6a16cb1825a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.3 Linux/6.4.4-arch1-1
|
Release files / happyaccidentsapi-0.0.3-py3-none-any.whl
| Download URL | happyaccidentsapi-0.0.3-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b403b30abb9b31f65945fa7dd3b854a72499563e9ad5c2ed85e61db2f92ec8e
|
|
BLAKE2b-256 checksum How to use checksums |
4b434c42544d416bae7c76e466242d527ee5c56a06d388bb59f3214d7a57c425
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.3 Linux/6.4.4-arch1-1
|