Skip to main content

High-level async API for NovelAI image generation

Project description

NovelAI Icon NovelAI-API

A lightweight asynchronous Python wrapper for the NovelAI image generation API supporting both web and api backend.

Installation

pip install novelai

Usage

Initialization

import asyncio
from novelai import NAIClient

# Replace string 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())

References

NovelAI Backend

Aedial/novelai-api

NovelAI Unofficial Knowledgebase

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

novelai-0.0.1.tar.gz (10.6 kB view hashes)

Uploaded Source

Built Distribution

novelai-0.0.1-py3-none-any.whl (7.5 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