Skip to main content

nai-cli

English | 中文

nai-cli is an unofficial command-line client for NovelAI image generation. It covers text to image, image to image, inpainting, Enhance, upscaling, the Director tools, Vibes and precise references on V5, V4.5 and V4, and reads the settings stored in images so they can be generated again.

It builds requests by the same rules as the official web client, so the same settings and seed produce the same image; the parity notes list the exceptions. Every command prints JSON, one object or one line per job, which makes it easy to call from scripts and other programs.

Documentation: usage guide, official client parity, compatibility

Install

Python 3.11 or later is required:

pipx install nai-cli

This installs the nai command in an environment of its own. uv tool install nai-cli and pip install nai-cli work as well. Reading tags from images and masking objects run on your computer and need pipx install "nai-cli[local]".

Configure

Create a persistent API token in NovelAI under Account Settings (it starts with pst-), then create a config file:

nai config init

The command prints the path of the new file. Put the token in its novelai_token field, or set the NOVELAI_TOKEN environment variable instead. Once the token works, nai account shows your balance.

Usage

nai gen --prompt "1girl, rooftop, night" --dry-run
nai gen --prompt @prompt.txt --size landscape
nai inpaint --image a.png --region ellipse:0.62,0.40,0.80,0.58 --prompt "1girl, rooftop, night, open hand" --preview
nai enhance --image a.png
nai meta a.png
nai batch jobs.jsonl --dry-run

--dry-run builds and prices the request without sending anything paid. The prompt and negative fields of the output hold the final text, including the quality tags and UC preset added automatically; without --dry-run, the saved files are listed in images. @prompt.txt reads the prompt from a file. inpaint repaints an area given in fractions of the image and composites the result back onto it, and --preview saves an image marking that area before anything is sent. enhance upscales and refines an image with the settings stored in it, and meta reads those settings so that nai gen can reproduce the image. batch runs a list of commands, one per line, and prints a JSON line for each, so other programs can queue work and resume it after a failure.

nai --help lists all commands, and nai COMMAND --help shows their options. The usage guide covers each command, the output format and the error codes.

Agent skill

nai-cli includes a skill in the Agent Skills format that teaches AI agents to use it: dry-running before spending Anlas, asking before exceeding the spending limit, recovering from errors and repainting part of an image. Install it with:

npx skills add obzawa/nai-cli

This installs it for the current project; add -g to install it for all projects. The skill itself is in skills/nai-cli.

Development

See CONTRIBUTING.md for setting up, the checks a change must pass and how to report bugs; coding agents follow AGENTS.md.

Acknowledgements

Thanks to NovelAI for the models and the service. Many of the defaults and conveniences follow NAI Launcher, and image resizing is ported from Pica.

License

MIT

Third-party code and its licenses are listed in THIRD_PARTY_NOTICES.md.

Metadata

Release files for nai-cli 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nai-cli 0.2.0
File Size Uploaded Provenance Actions
nai_cli-0.2.0.tar.gz 335.5 kB With provenance Details for nai_cli-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nai-cli 0.2.0
File Interpreter ABI Platform Actions
nai_cli-0.2.0-py3-none-any.whl Python 3 none any Details for nai_cli-0.2.0-py3-none-any.whl

Total release size: 559.6 kB

Release files / nai_cli-0.2.0.tar.gz

Download URL nai_cli-0.2.0.tar.gz
Size 335.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0d5ab867e6d5b6cb8468ddfebfeef1e115c1adea96eddf1f2c5a5e21e203615d
BLAKE2b-256 checksum
How to use checksums
605d8d908595f79cfac89472d7e3b7c138f89210efd49a85e4f41fac15ab436f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / nai_cli-0.2.0-py3-none-any.whl

Download URL nai_cli-0.2.0-py3-none-any.whl
Size 224.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
503c7ccb851e75743106aea6871e1d0583ba837c93487795eaf6209c0bd80be6
BLAKE2b-256 checksum
How to use checksums
f1f05e39e00e555e55cbd1fbfabd0ed2bb7163ba0451d77f68534421a49da1e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for nai-cli 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nai_cli-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page