boilerplate

class API[source]

Bases: object

Boilerplate for the redundant parts. Using the object as a context manager will automatically login using the environment variables NAI_USERNAME and NAI_PASSWORD.

Usage:

async with API() as api:
    api = api.api
    encryption_key = api.encryption_key
    logger = api.logger
    ...  # Do stuff

A custom base address can be passed to the constructor to replace the default (BASE_ADDRESS)

__init__(base_address: str | None = None)[source]
logger: logging.Logger
api: novelai_api.NovelAI_API.NovelAIAPI | None
property encryption_key
class JSONEncoder[source]

Bases: json.encoder.JSONEncoder

Extended JSON encoder to support bytes

default(o: Any) Any[source]
dumps(e: Any) str[source]

Shortcut to a configuration of json.dumps for consistency