Metadata-Version: 2.1
Name: happyaccidentsapi
Version: 0.0.3
Summary: API Wrapper for HappyAccidents
Home-page: https://github.com/hoopengo/happyaccidentsapi
License: Apache-2.0
Keywords: api,happyaccidents,ai
Author: hoopengo
Author-email: hoopengo@yandex.ru
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Dist: aiofiles (>=23.1.0,<24.0.0)
Requires-Dist: aiohttp[speedups] (>=3.8.4,<4.0.0)
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
Project-URL: Repository, https://github.com/hoopengo/happyaccidentsapi
Description-Content-Type: text/markdown

<img alt="banner" src="https://raw.githubusercontent.com/hoopengo/hoopengo/master/images/HappyAccidentsAPI/banner-light.svg" style="max-width: 100%;">

## 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.](https://github.com/hoopengo/HappyAccidentsAPI/issues)

## Quick example

```python
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

- [Repository](https://github.com/hoopengo/HappyAccidentsAPI)
- [Documentation](https://github.com/hoopengo/HappyAccidentsAPI/tree/master/docs/)
- [Examples](https://github.com/hoopengo/HappyAccidentsAPI/tree/master/examples/)
- [How to get token?](https://github.com/hoopengo/HappyAccidentsAPI/blob/master/docs/get_token.md)

[//]: <- [Try it Out](https://t.me/HotBebrasBot)>

