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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file happyaccidentsapi-0.0.3.tar.gz.

File metadata

  • Download URL: happyaccidentsapi-0.0.3.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Linux/6.4.4-arch1-1

File hashes

Hashes for happyaccidentsapi-0.0.3.tar.gz
Algorithm Hash digest
SHA256 20b19ac87292e158099527b7ea5e023ff5f68adfeb41df604537d8993511d1ca
MD5 5752be0b6e4ac2f633d654003a6b2696
BLAKE2b-256 ee7cd4d8ab280e8c7996b846bd3fa3a261d13a7a390fc384dffcb6a16cb1825a

See more details on using hashes here.

File details

Details for the file happyaccidentsapi-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: happyaccidentsapi-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Linux/6.4.4-arch1-1

File hashes

Hashes for happyaccidentsapi-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8b403b30abb9b31f65945fa7dd3b854a72499563e9ad5c2ed85e61db2f92ec8e
MD5 e51b972ce9b6fc1f66eb5d4580021cb6
BLAKE2b-256 4b434c42544d416bae7c76e466242d527ee5c56a06d388bb59f3214d7a57c425

See more details on using hashes here.

Supported by

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