Skip to main content

Unofficial Python API for Perchance.

Project description

perchance

pypi python CodeFactor BuyMeACoffee

Unofficial Python API for Perchance.

Installation

To install this module, run the following command:

pip install perchance

Examples

Text generation

import asyncio
import perchance

async def main():
    gen = perchance.TextGenerator()
    prompt = "How far is the moon?"

    async for chunk in gen.text(prompt):
        print(chunk, end='')

asyncio.run(main())

Image generation

import asyncio
import perchance
from PIL import Image

async def main():
    gen = perchance.ImageGenerator()
    prompt = "Fantasy landscape"

    async with await gen.image(prompt) as result:
        binary = await result.download()
        image = Image.open(binary)
        image.show()

asyncio.run(main())

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

perchance-0.0.1.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

perchance-0.0.1-py3-none-any.whl (15.4 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