How caru-ini/novelai-sdk works
Project type and purpose
• This is an open-source Python SDK (“novelai-sdk”) whose sole purpose is to provide a modern, type-safe interface to NovelAI’s image-generation REST API.
• It exposes a high-level client API (with Pydantic validation, convenience methods, PIL support and SSE streaming) and a low-level HTTP wrapper for advanced use.
File structure
• Top-level:
‣ src/novelai/ – main package
· __main__.py – CLI entrypoint if invoked as python -m novelai
· _api/client.py – low-level HTTP/REST interface (HTTPX calls, JSON marshaling)
· _client/client.py – high-level façade, exposes .image.generate(), .image.generate_stream(), etc.
· _utils/ – helpers (image I/O, converter functions)
· constants/ – enumeration of models, samplers, sizes, schedules, presets
· types/ – Pydantic models for request/response schemas (api/image.py, user/image.py)
· exceptions.py – custom exceptions for error handling
‣ examples/ – usage demos
‣ docs/ – images and Markdown docs
‣ tests/ – placeholder for future tests
‣ pyproject.toml, pre-commit, CI configs – build and style enforcement
README for additional insights
• Confirms two-layer API design (high-level vs. low-level).
• Lists dependencies: HTTPX, Pillow, Pydantic v2, python-dotenv.
• Describes features: streaming (SSE), ControlNet, character references, multi-character positioning.