A lightweight async wrapper for NovelAI image generation API
Project description
NovelAI-API
A lightweight asynchronous Python wrapper for NovelAI image generation API. Supports both web and api backend.
Installation
pip install novelai
Usage
Initialization
import asyncio
from novelai import NAIClient
# Replace argument values with your actual account credentials
username = "Your NovelAI username"
password = "Your NovelAI password"
async def main():
client = NAIClient(username, password, proxy=None)
await client.init()
asyncio.run(main())
Generate
from pathlib import Path
async def main():
# Choose host between "api" and "web"
output = await client.generate_image(prompt="1girl", host="api")
path = Path("output")
path.mkdir(parents=True, exist_ok=True)
for filename, data in output.items():
Path(path / filename).write_bytes(data)
asyncio.run(main())
Use in CLI
Optionally, a module function is also provided to directly generate access token in CLI.
Once a access token is generated, it will be valid for 30 days. Token can be used as the authentication header to make requests to NovelAI.
# Replace argument values with your actual account credentials
python3 -m novelai login <username> <password>
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
novelai-0.1.0.tar.gz
(16.6 kB
view hashes)
Built Distribution
novelai-0.1.0-py3-none-any.whl
(12.1 kB
view hashes)