Director Tools
Director Tools provide image augmentation and tag suggestion features.
Augment Image
Use the augmentImage method to augment images:
typescript
import { NovelAI } from 'novelai-sdk-unofficial';
import { readFileSync, writeFileSync } from 'fs';
const client = new NovelAI({ apiKey: 'your-api-key' });
// Background removal
const images = await client.image.augmentImage({
image: readFileSync('input.png'),
type: 'bg-removal',
width: 1024,
height: 1024,
});
writeFileSync('output.png', images[0]);Supported Augmentation Types
| type | Description |
|---|---|
bg-removal | Background removal |
lineart | Line art extraction |
sketch | Sketch style |
colorize | Colorization |
emotion | Emotion transformation |
declutter | Declutter |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
image | Buffer | string | ArrayBuffer | Yes | Input image |
type | AugmentType | Yes | Augmentation type |
width | number | Yes | Output width (must match input image width) |
height | number | Yes | Output height (must match input image height) |
prompt | string | No | Prompt (for types like colorize) |
defry | number | No | Defry level (0-5) |
Note
width and height must match the actual dimensions of the input image, otherwise the API will return a 500 error.
Colorization Example
typescript
const colorized = await client.image.augmentImage({
image: readFileSync('sketch.png'),
type: 'colorize',
width: 1024,
height: 1024,
prompt: 'vibrant colors, detailed shading',
});Suggest Tags
Use the suggestTags method to get tag suggestions:
typescript
import { NovelAI } from 'novelai-sdk-unofficial';
const client = new NovelAI({ apiKey: 'your-api-key' });
// Get tag suggestions
const tags = await client.image.suggestTags({
prompt: '1girl, blue',
});
for (const tag of tags) {
console.log(`${tag.tag}: ${tag.confidence} (${tag.count})`);
}Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt | string | required | Incomplete tag query |
model | ImageModel | 'nai-diffusion-4-5-full' | Image model |
lang | 'en' | 'jp' | 'en' | Language |
Return Value
typescript
interface TagSuggestion {
tag: string; // Suggested tag
confidence: number; // Confidence score
count: number; // Usage count
}Japanese Tag Suggestions
typescript
const tags = await client.image.suggestTags({
prompt: '女の子',
lang: 'jp',
});Low-Level API
For more fine-grained control, use the Low-Level API:
typescript
import { APIClient } from 'novelai-sdk-unofficial/api';
const client = new APIClient({ apiKey: 'your-api-key' });
// Augment image
const images = await client.image.augmentImage({
image: base64String,
req_type: 'bg-removal',
width: 1024,
height: 1024,
});
// Suggest tags
const response = await client.image.suggestTags(
'nai-diffusion-4-5-full',
'1girl, blue',
'en'
);