Skip to content

Getting Started

Installation

bash
npm install novelai-sdk-unofficial
bash
pnpm add novelai-sdk-unofficial
bash
yarn add novelai-sdk-unofficial

Requirements

  • Node.js 18+
  • NovelAI subscription with API access

Quick Example

typescript
import { NovelAI } from 'novelai-sdk-unofficial';
import { writeFileSync } from 'fs';

// Initialize client
const client = new NovelAI({ apiKey: 'your-api-key' });

// Generate an image
const images = await client.image.generate({
  prompt: '1girl, cat ears, masterpiece, best quality',
  model: 'nai-diffusion-4-5-full',
  size: 'portrait',
});

// Save the result
writeFileSync('output.png', images[0]);

Text Generation

typescript
import { NovelAI } from 'novelai-sdk-unofficial';

const client = new NovelAI({ apiKey: 'your-api-key' });

const text = await client.text.generate({
  input: 'Once upon a time',
  model: 'llama-3-erato-v1',
  maxLength: 80,
});

console.log(text);

Next Steps

Released under the MIT License.