Python API for the NovelAI REST API
This module is intended to be used by developers as a helper for using NovelAI's REST API.
Category | Badges |
---|---|
Pypi | |
Quality checking | |
Stats | |
Activity |
Retired versions: 3.7.2
Final commit of retired versions can be found with the tag py<version>
(e.g. py3.7.2
).
Download via pip:
pip install novelai-api
Get the access key for your account. This key is used to login to the API through the /login endpoint.
python -m novelai_api get_access_key <username> <password>
Login to the API and get the access token. This token is valid 30 days and is required to use most of the API. Take care to properly escape the arguments if they contain special characters.
python -m novelai_api get_access_token <username> <password>
Run a sanity check on your user content. It will print what content couldn't be decrypted. Take care to properly escape the arguments if they contain special characters.
python -m novelai_api sanity_check <username> <password>
Decode a b64 encoded tokenized text. This will print the tokens and the decoded text.
python -m novelai_api decode <model> <data>
A full list of examples is available in the example directory
The API works through the NovelAIAPI object. It is split in 2 groups: NovelAIAPI.low_level and NovelAIAPI.high_level
The low level interface is a strict implementation of the official API (https://api.novelai.net/docs). It only checks for input types via assert, and output schema if NovelAIAPI.low_level.is_schema_validation_enabled is True
The high level interface builds on the low level one for easier handling of complex settings. It handles many tasks from the frontend
All relevant objects are in the novelai_api directory.
The Poetry package is required (pip install poetry
) as the venv manager.
You can contribute features and enhancements through PR. Any PR should pass the tests and the pre-commits before submission. The pre-commit hook can be installed via
poetry run nai-pre-commit
To run against the API, you can use poetry run nai-test-api
.
To run against the mocked API, you can use poetry run nai-test-mock
.
To build the docs, run
poetry run nai-build-docs
The docs will be locally viewable at docs/build/html/index.html