Metadata-Version: 2.1
Name: perchance
Version: 0.0.1
Summary: Unofficial Python API for Perchance.
Home-page: https://github.com/EeeMoon/perchance
License: MIT
Author: EeeMoon
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: aiofiles (>=23.2.1,<24.0.0)
Requires-Dist: aiohttp (>=3.9.5,<4.0.0)
Requires-Dist: playwright (>=1.44.0,<2.0.0)
Description-Content-Type: text/markdown

# perchance
[![pypi](https://img.shields.io/pypi/v/perchance)](https://pypi.org/project/perchance)
[![python](https://img.shields.io/badge/python-3.10-blue)](https://www.python.org/downloads)
[![CodeFactor](https://www.codefactor.io/repository/github/eeemoon/perchance/badge)](https://www.codefactor.io/repository/github/eeemoon/perchance)
[![BuyMeACoffee](https://img.shields.io/badge/support-yellow)](https://www.buymeacoffee.com/eeemoon)

Unofficial Python API for [Perchance](https://perchance.org).

## Installation
To install this module, run the following command:
```
pip install perchance
```

## Examples
### Text generation
```python
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
```python
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())
```
