nekoai-api 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nekoai_api-0.1.1/LICENSE +21 -0
- nekoai_api-0.1.1/PKG-INFO +438 -0
- nekoai_api-0.1.1/README.md +413 -0
- nekoai_api-0.1.1/nekoai/__init__.py +3 -0
- nekoai_api-0.1.1/nekoai/__main__.py +40 -0
- nekoai_api-0.1.1/nekoai/_version.py +1 -0
- nekoai_api-0.1.1/nekoai/client.py +522 -0
- nekoai_api-0.1.1/nekoai/config.py +6 -0
- nekoai_api-0.1.1/nekoai/constant.py +153 -0
- nekoai_api-0.1.1/nekoai/exceptions.py +38 -0
- nekoai_api-0.1.1/nekoai/types/__init__.py +37 -0
- nekoai_api-0.1.1/nekoai/types/director.py +159 -0
- nekoai_api-0.1.1/nekoai/types/host.py +12 -0
- nekoai_api-0.1.1/nekoai/types/image.py +40 -0
- nekoai_api-0.1.1/nekoai/types/metadata.py +549 -0
- nekoai_api-0.1.1/nekoai/types/parameters.py +137 -0
- nekoai_api-0.1.1/nekoai/types/user.py +32 -0
- nekoai_api-0.1.1/nekoai/utils.py +170 -0
- nekoai_api-0.1.1/nekoai_api.egg-info/PKG-INFO +438 -0
- nekoai_api-0.1.1/nekoai_api.egg-info/SOURCES.txt +39 -0
- nekoai_api-0.1.1/nekoai_api.egg-info/dependency_links.txt +1 -0
- nekoai_api-0.1.1/nekoai_api.egg-info/entry_points.txt +2 -0
- nekoai_api-0.1.1/nekoai_api.egg-info/requires.txt +4 -0
- nekoai_api-0.1.1/nekoai_api.egg-info/top_level.txt +1 -0
- nekoai_api-0.1.1/pyproject.toml +64 -0
- nekoai_api-0.1.1/setup.cfg +4 -0
nekoai_api-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nya Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nekoai-api
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: 🎨 A lightweight async Python API for NovelAI image generation and director tools.
|
|
5
|
+
Author-email: "Nya Foundation Team (k3scat)" <k3scat@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/Nya-Foundation/NekoAI-API
|
|
8
|
+
Project-URL: Issues, https://github.com/Nya-Foundation/NekoAI-API/issues
|
|
9
|
+
Keywords: API,async,NovelAI,AI,image generation,nai3,nai4
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: httpx>=0.25.2
|
|
21
|
+
Requires-Dist: pydantic>=2.5.3
|
|
22
|
+
Requires-Dist: loguru>=0.7.2
|
|
23
|
+
Requires-Dist: argon2-cffi>=21.3.0
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# 🐾 NekoAI-API
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
<img src="https://raw.githubusercontent.com/Nya-Foundation/NekoAI-API/main/assets/banner.png" alt="NekoAI-API Banner" width="800" />
|
|
30
|
+
|
|
31
|
+
<h3>🎨 A lightweight async Python API for NovelAI image generation and director tools.</h3>
|
|
32
|
+
|
|
33
|
+
<div>
|
|
34
|
+
<a href="https://github.com/Nya-Foundation/NekoAI-API/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Nya-Foundation/nekoai-api.svg" alt="License"/></a>
|
|
35
|
+
<a href="https://pypi.org/project/nekoai-api/"><img src="https://img.shields.io/pypi/v/nekoai-api.svg" alt="PyPI version"/></a>
|
|
36
|
+
<a href="https://pypi.org/project/nekoai-api/"><img src="https://img.shields.io/pypi/pyversions/nekoai-api.svg" alt="Python versions"/></a>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div>
|
|
40
|
+
<a href="https://github.com/nya-foundation/nekoai-api/actions/workflows/scan.yml"><img src="https://github.com/nya-foundation/nekoai-api/actions/workflows/scan.yml/badge.svg" alt="CodeQL & Dependencies Scan"/></a>
|
|
41
|
+
<a href="https://github.com/Nya-Foundation/nekoai-api/actions/workflows/publish.yml"><img src="https://github.com/Nya-Foundation/nekoai-api/actions/workflows/publish.yml/badge.svg" alt="CI/CD Builds"/></a>
|
|
42
|
+
<a href="https://pepy.tech/projects/nekoai-api"><img src="https://static.pepy.tech/badge/nekoai-api" alt="PyPI Downloads"/></a>
|
|
43
|
+
<a href="https://deepwiki.com/Nya-Foundation/NekoAI-API"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"/></a>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
## 🌈 Introduction
|
|
48
|
+
|
|
49
|
+
> 🐾 **NekoAI-API** is a **lightweight** and **easy-to-use** Python wrapper for NovelAI's image generation capabilities. This project makes it simple to integrate NovelAI's powerful image generation and manipulation tools into your Python applications with minimal code overhead.
|
|
50
|
+
>
|
|
51
|
+
> Built with asyncio for efficient performance, it provides full access to NovelAI's latest models (V3, V4, V4.5) and Director tools while maintaining a clean, pythonic interface. This project was heavily inspired by [HanaokaYuzu's NovelAI-API](https://github.com/HanaokaYuzu/NovelAI-API), with a focus on providing more features support and enhanced usability.
|
|
52
|
+
|
|
53
|
+
## 🌟 Core Capabilities
|
|
54
|
+
|
|
55
|
+
| Feature | Description |
|
|
56
|
+
|------------------------------|---------------------------------------------------------------------------------------------------|
|
|
57
|
+
| 🚀 **Lightweight** | Focuses on image generation and Director tools, providing a simple and easy-to-use interface. |
|
|
58
|
+
| ⚙️ **Parameterized** | Provides a `Metadata` class to easily set up generation parameters with type validation. |
|
|
59
|
+
| ⚡ **Asynchronous** | Utilizes `asyncio` to run generating tasks and return outputs efficiently. |
|
|
60
|
+
| 🔑 **Multiple Authentication Methods** | Supports both username/password and direct token authentication. |
|
|
61
|
+
| 🌐 **Custom Hosts** | Allows specifying custom API hosts for flexibility. |
|
|
62
|
+
| ✨ **Latest Models** | Full support for V3, V4, and V4.5 models including multi-character generation. |
|
|
63
|
+
| 🛠️ **Director Tools** | Complete support for all NovelAI Director tools like line art, background removal, and emotion change. |
|
|
64
|
+
|
|
65
|
+
## 📦 Installation
|
|
66
|
+
|
|
67
|
+
> [!IMPORTANT]
|
|
68
|
+
>
|
|
69
|
+
> This package requires **Python 3.10 or higher**.
|
|
70
|
+
|
|
71
|
+
Install/update with pip:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
pip install -U nekoai-api
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 🚀 Usage
|
|
78
|
+
|
|
79
|
+
### 🔑 Initialization
|
|
80
|
+
|
|
81
|
+
Import required packages and initialize a client with your NovelAI credentials. You can use either **username/password** or a **direct token**.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import asyncio
|
|
85
|
+
from nekoai import NovelAI
|
|
86
|
+
|
|
87
|
+
# Option 1: Username and password
|
|
88
|
+
async def main_with_credentials():
|
|
89
|
+
client = NovelAI(username="your_username", password="your_password")
|
|
90
|
+
await client.init(timeout=30)
|
|
91
|
+
|
|
92
|
+
# Option 2: Direct token authentication
|
|
93
|
+
async def main_with_token():
|
|
94
|
+
client = NovelAI(token="your_access_token")
|
|
95
|
+
await client.init(timeout=30)
|
|
96
|
+
|
|
97
|
+
asyncio.run(main_with_token()) # Or main_with_credentials()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 🖼️ Image Generation
|
|
101
|
+
|
|
102
|
+
After initializing successfully, you can generate images with the `generate_image` method. The method takes parameters **directly** or a `Metadata` object, and an optional `host` argument to specify the backend to use.
|
|
103
|
+
|
|
104
|
+
By passing `verbose=True`, the method will print the **estimated Anlas cost** each time a generating request is going to be made.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from nekoai import NovelAI, Metadata
|
|
108
|
+
from nekoai.constant import Model, Resolution, Sampler, Noise
|
|
109
|
+
|
|
110
|
+
async def main():
|
|
111
|
+
client = NovelAI(token="your_access_token")
|
|
112
|
+
await client.init()
|
|
113
|
+
|
|
114
|
+
# Generate using Metadata object
|
|
115
|
+
metadata = Metadata(
|
|
116
|
+
prompt="1girl, cute, anime style, detailed",
|
|
117
|
+
model=Model.V4_5_CUR, # Use the latest V4.5 model
|
|
118
|
+
res_preset=Resolution.NORMAL_PORTRAIT,
|
|
119
|
+
n_samples=1,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Alternative: pass parameters directly
|
|
123
|
+
images = await client.generate_image(
|
|
124
|
+
prompt="1girl, cute, anime style, detailed",
|
|
125
|
+
model=Model.V4_5_CUR,
|
|
126
|
+
res_preset=Resolution.NORMAL_PORTRAIT,
|
|
127
|
+
verbose=True, # Show Anlas cost
|
|
128
|
+
seed=1234567890 # Fixed seed for reproducibility
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
for image in images:
|
|
132
|
+
image.save(path="output")
|
|
133
|
+
print(f"Image saved: {image.filename}")
|
|
134
|
+
|
|
135
|
+
asyncio.run(main())
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Multi-Character Generation (V4.5)
|
|
139
|
+
|
|
140
|
+
V4.5 models support generating multiple characters with character-specific prompts and positioning.
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from nekoai import NovelAI
|
|
144
|
+
from nekoai.constant import Model, Resolution
|
|
145
|
+
from nekoai.types import CharacterPrompt, PositionCoords
|
|
146
|
+
|
|
147
|
+
async def main():
|
|
148
|
+
client = NovelAI(token="your_access_token")
|
|
149
|
+
await client.init()
|
|
150
|
+
|
|
151
|
+
# Create character prompts with positioning
|
|
152
|
+
character_prompts = [
|
|
153
|
+
CharacterPrompt(
|
|
154
|
+
prompt="girl, red hair, red dress",
|
|
155
|
+
uc="bad hands, bad anatomy",
|
|
156
|
+
center=PositionCoords(x=0.3, y=0.3),
|
|
157
|
+
),
|
|
158
|
+
CharacterPrompt(
|
|
159
|
+
prompt="boy, blue hair, blue uniform",
|
|
160
|
+
uc="bad hands, bad anatomy",
|
|
161
|
+
center=PositionCoords(x=0.7, y=0.7),
|
|
162
|
+
)
|
|
163
|
+
]
|
|
164
|
+
|
|
165
|
+
# Generate image with multiple characters
|
|
166
|
+
images = await client.generate_image(
|
|
167
|
+
prompt="two people standing together, park background",
|
|
168
|
+
model=Model.V4,
|
|
169
|
+
res_preset=Resolution.NORMAL_LANDSCAPE,
|
|
170
|
+
characterPrompts=character_prompts,
|
|
171
|
+
verbose=True
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
for image in images:
|
|
175
|
+
image.save("output")
|
|
176
|
+
|
|
177
|
+
asyncio.run(main())
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Image to Image
|
|
181
|
+
|
|
182
|
+
To perform `img2img` action, set `action` parameter to `Action.IMG2IMG`, and provide a base64-encoded image.
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
import base64
|
|
186
|
+
from nekoai import NovelAI
|
|
187
|
+
from nekoai.constant import Action
|
|
188
|
+
from nekoai.utils import parse_image
|
|
189
|
+
|
|
190
|
+
async def main():
|
|
191
|
+
client = NovelAI(token="your_access_token")
|
|
192
|
+
await client.init()
|
|
193
|
+
|
|
194
|
+
width, height, base64_image = parse_image('image.png')
|
|
195
|
+
|
|
196
|
+
images = await client.generate_image(
|
|
197
|
+
prompt="1girl, fantasy outfit",
|
|
198
|
+
action=Action.IMG2IMG,
|
|
199
|
+
width=width,
|
|
200
|
+
height=height,
|
|
201
|
+
image=base64_image ,
|
|
202
|
+
strength=0.5, # Lower = more similar to original
|
|
203
|
+
noise=0.1,
|
|
204
|
+
verbose=True
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
for image in images:
|
|
208
|
+
image.save("output")
|
|
209
|
+
|
|
210
|
+
asyncio.run(main())
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Inpainting
|
|
214
|
+
|
|
215
|
+
To perform inpainting, set `action` to `Action.INPAINT`, and provide both a base image and a mask.
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
import base64
|
|
219
|
+
from nekoai import NovelAI
|
|
220
|
+
from nekoai.constant import Model, Action, Resolution
|
|
221
|
+
|
|
222
|
+
async def main():
|
|
223
|
+
client = NovelAI(token="your_access_token")
|
|
224
|
+
await client.init()
|
|
225
|
+
|
|
226
|
+
with open("input/portrait.jpg", "rb") as f:
|
|
227
|
+
base_image = base64.b64encode(f.read()).decode("utf-8")
|
|
228
|
+
|
|
229
|
+
with open("input/mask.jpg", "rb") as f:
|
|
230
|
+
mask = base64.b64encode(f.read()).decode("utf-8")
|
|
231
|
+
|
|
232
|
+
images = await client.generate_image(
|
|
233
|
+
prompt="1girl, detailed background",
|
|
234
|
+
model=Model.V3INP, # Use inpainting model
|
|
235
|
+
action=Action.INPAINT,
|
|
236
|
+
res_preset=Resolution.NORMAL_PORTRAIT,
|
|
237
|
+
image=base_image,
|
|
238
|
+
mask=mask,
|
|
239
|
+
add_original_image=True, # Overlay original image
|
|
240
|
+
verbose=True
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
for image in images:
|
|
244
|
+
image.save("output")
|
|
245
|
+
|
|
246
|
+
asyncio.run(main())
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Vibe Transfer
|
|
250
|
+
|
|
251
|
+
Vibe transfer allows using a reference image's style or mood in your generated image.
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
import base64
|
|
255
|
+
from nekoai import NovelAI
|
|
256
|
+
from nekoai.constant import Model, Resolution
|
|
257
|
+
|
|
258
|
+
async def main():
|
|
259
|
+
client = NovelAI(token="your_access_token")
|
|
260
|
+
await client.init()
|
|
261
|
+
|
|
262
|
+
with open("input/style_reference.jpg", "rb") as f:
|
|
263
|
+
ref_image = base64.b64encode(f.read()).decode("utf-8")
|
|
264
|
+
|
|
265
|
+
images = await client.generate_image(
|
|
266
|
+
prompt="landscape, mountains, sunset",
|
|
267
|
+
model=Model.V4,
|
|
268
|
+
res_preset=Resolution.NORMAL_LANDSCAPE,
|
|
269
|
+
reference_image_multiple=[ref_image],
|
|
270
|
+
reference_information_extracted_multiple=[1], # Max information extracted
|
|
271
|
+
reference_strength_multiple=[0.7], # Strong style transfer
|
|
272
|
+
verbose=True
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
for image in images:
|
|
276
|
+
image.save("output")
|
|
277
|
+
|
|
278
|
+
asyncio.run(main())
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Director Tools
|
|
282
|
+
|
|
283
|
+
NovelAI offers several Director tools for image manipulation, all accessible through dedicated methods.
|
|
284
|
+
|
|
285
|
+
#### Line Art
|
|
286
|
+
|
|
287
|
+
Convert an image to line art:
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
import base64
|
|
291
|
+
import asyncio
|
|
292
|
+
from nekoai import NovelAI
|
|
293
|
+
|
|
294
|
+
async def main():
|
|
295
|
+
client = NovelAI(token="your_access_token")
|
|
296
|
+
await client.init()
|
|
297
|
+
|
|
298
|
+
result = await client.line_art('image.png')
|
|
299
|
+
result.save("output")
|
|
300
|
+
|
|
301
|
+
print(f"Line art saved as {result.filename}")
|
|
302
|
+
|
|
303
|
+
asyncio.run(main())
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
#### Background Removal
|
|
307
|
+
|
|
308
|
+
Remove the background from an image:
|
|
309
|
+
|
|
310
|
+
```python
|
|
311
|
+
import base64
|
|
312
|
+
import asyncio
|
|
313
|
+
from nekoai import NovelAI
|
|
314
|
+
|
|
315
|
+
async def main():
|
|
316
|
+
client = NovelAI(token="your_access_token")
|
|
317
|
+
await client.init()
|
|
318
|
+
|
|
319
|
+
result = await client.background_removal('image.png')
|
|
320
|
+
result.save("output")
|
|
321
|
+
|
|
322
|
+
print(f"Background has been removed and saved as {result.filename}")
|
|
323
|
+
|
|
324
|
+
asyncio.run(main())
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### Change Emotion
|
|
328
|
+
|
|
329
|
+
Change the emotion of a character in an image:
|
|
330
|
+
|
|
331
|
+
```python
|
|
332
|
+
import base64
|
|
333
|
+
import asyncio
|
|
334
|
+
from nekoai import NovelAI
|
|
335
|
+
from nekoai.constant import EmotionOptions, EmotionLevel
|
|
336
|
+
|
|
337
|
+
async def main():
|
|
338
|
+
client = NovelAI(token="your_access_token")
|
|
339
|
+
await client.init()
|
|
340
|
+
|
|
341
|
+
result = await client.change_emotion(
|
|
342
|
+
image="image.png"
|
|
343
|
+
target_emotion=EmotionOptions.HAPPY,
|
|
344
|
+
original_emotion=EmotionOptions.NEUTRAL,
|
|
345
|
+
emotion_level=EmotionLevel.NORMAL
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
result.save("output")
|
|
349
|
+
|
|
350
|
+
asyncio.run(main())
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### Other Director Tools
|
|
354
|
+
|
|
355
|
+
Additional tools include:
|
|
356
|
+
|
|
357
|
+
```python
|
|
358
|
+
# Declutter an image
|
|
359
|
+
result = await client.declutter(image='image.png')
|
|
360
|
+
|
|
361
|
+
# Colorize a sketch or line art
|
|
362
|
+
result = await client.colorize(image='image.png')
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Custom Hosts
|
|
366
|
+
|
|
367
|
+
You can specify custom API hosts for flexibility:
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
from nekoai import NovelAI
|
|
371
|
+
from nekoai.constant import Host
|
|
372
|
+
from nekoai.types.host import HostInstance
|
|
373
|
+
|
|
374
|
+
async def main():
|
|
375
|
+
client = NovelAI(token="your_access_token")
|
|
376
|
+
await client.init()
|
|
377
|
+
|
|
378
|
+
# Use predefined hosts
|
|
379
|
+
images1 = await client.generate_image(
|
|
380
|
+
prompt="1girl",
|
|
381
|
+
host=Host.API # Use API host instead of default WEB host
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
# Use custom host
|
|
385
|
+
custom_host = Host.custom(
|
|
386
|
+
url="https://your-custom-host.com",
|
|
387
|
+
accept="binary/octet-stream",
|
|
388
|
+
name="custom-host"
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
images2 = await client.generate_image(
|
|
392
|
+
prompt="1girl",
|
|
393
|
+
host=custom_host
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
# Or create HostInstance directly
|
|
397
|
+
custom_host2 = HostInstance(
|
|
398
|
+
url="https://another-custom-host.com",
|
|
399
|
+
accept="binary/octet-stream",
|
|
400
|
+
name="another-custom"
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
images3 = await client.generate_image(
|
|
404
|
+
prompt="1girl",
|
|
405
|
+
host=custom_host2
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
asyncio.run(main())
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### CLI Token Generation
|
|
412
|
+
|
|
413
|
+
You can generate an access token from the command line:
|
|
414
|
+
|
|
415
|
+
```sh
|
|
416
|
+
# Replace with your actual account credentials
|
|
417
|
+
nekoai login <username> <password>
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Example Scripts
|
|
421
|
+
|
|
422
|
+
The package includes several example scripts in the `examples/requests/` directory:
|
|
423
|
+
|
|
424
|
+
- Generation with different models (V3, V4, V4.5)
|
|
425
|
+
- Multi-character generation
|
|
426
|
+
- All director tools (line art, background removal, emotion change, etc.)
|
|
427
|
+
|
|
428
|
+
## References
|
|
429
|
+
|
|
430
|
+
[NovelAI Documentation](https://docs.novelai.net/)
|
|
431
|
+
|
|
432
|
+
[NovelAI Backend API](https://api.novelai.net/docs)
|
|
433
|
+
|
|
434
|
+
[NovelAI Unofficial Knowledgebase](https://naidb.miraheze.org/wiki/Using_the_API)
|
|
435
|
+
|
|
436
|
+
[Aedial/novelai-api](https://github.com/Aedial/novelai-api)
|
|
437
|
+
|
|
438
|
+
[NovelAI-API](https://github.com/HanaokaYuzu/NovelAI-API)
|