Skip to main content

perchance-api

pypi python

Unofficial Python API for Perchance.

Installation

To install this module, run the following command:

pip install perchance-api

Examples

Text generation

import asyncio
from perchance import TextGenerator

async def main():
    async with TextGenerator() as gen:
        prompt = "How far is the Moon?"

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

asyncio.run(main())

Image generation

import asyncio
from PIL import Image
from perchance import ImageGenerator

async def main():
    async with ImageGenerator() as gen:
        prompt = "Fantasy landscape"

        result = await gen.image(prompt, shape='landscape')
        binary = await result.download()
        image = Image.open(binary)
        image.show()

asyncio.run(main())

Metadata

Release files for perchance-api 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for perchance-api 0.2.0
File Size Uploaded
perchance_api-0.2.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for perchance-api 0.2.0
File Interpreter ABI Platform
perchance_api-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / perchance_api-0.2.0.tar.gz

Download URL perchance_api-0.2.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
64a2a3505aa76aa421b2ac0385660540a2370cfe8546d806b5cc0a10340d3ee6
BLAKE2b-256 checksum
How to use checksums
83941b54b839825cc3a5e1b6c4d5d7035679f5c2fc2b90e518c5db02f85b776e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / perchance_api-0.2.0-py3-none-any.whl

Download URL perchance_api-0.2.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3809ae4f3620b95b19790e37b3e67c785e9506665b17c3ebc8aec0960ed7098b
BLAKE2b-256 checksum
How to use checksums
3a6e2b867f61db1f42dc50e066d7af97cfddbed5537d7970d338617a7101b144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

0.2.1

2 release files

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page