Skip to content

eeemoon/perchance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

perchance

pypi python 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())