Skip to main content

API Wrapper for HappyAccidents

Project description

banner

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

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.3.tar.gz (12.6 kB view hashes)

Uploaded Source

Built Distribution

happyaccidentsapi-0.0.3-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page