API · for developers

NovelAI API: Python, JavaScript and curl examples

The AniworldAI API speaks the OpenAI format: NovelAI V5 Full Medium and V4.5 Full plug into the OpenAI SDK by changing base_url. One key works in every format, and you get it right after payment.

See plans

No card needed: 3 NovelAI images and 3 on Qwen-Image and FLUX, valid 7 days. The key appears here and in Telegram. API documentation (Swagger)

Connect the way you like

One key works in all three formats. Every endpoint and parameter is in the docs.

OpenAI-compatible

URL https://novelai.api.aniworldai.org/v1

base_url plus your key as api_key. Works with the OpenAI SDK and any client that lets you change the URL, including the sillyimages extension.

  • Images: /images/generations, /images/edits
  • Chat and responses: /chat/completions, /responses
  • Utility: /models, /files

Stable Diffusion WebUI (A1111)

URL https://novelai.api.aniworldai.org

The /sdapi/v1/* format for SillyTavern and any A1111 client. The key goes into the authentication field as api:KEY.

  • SillyTavern: Image Generation → Stable Diffusion Web UI
  • Endpoints /sdapi/v1/* (txt2img, options and more)
Learn more →

MCP

URL https://novelai.api.aniworldai.org/mcp

Streamable HTTP, the key in the Authorization: Bearer header. Works in clients that let you set a header: Claude Code, Cursor, VS Code.

  • 7 tools: draw, status, image, link, cancel, quota, models
Learn more →

Authorization: Bearer your-key

API documentation (Swagger) →

NovelAI, Qwen-Image and FLUX

Time from request to image on a normal day; longer when there is a queue.

NovelAI V5 Full Medium

The new NovelAI generation. nai-v5-medium

usually 4–6 s

NovelAI V4.5 Full

Full V4.5, the model tavern users know. nai-v4.5-full

about 14 s

Qwen-Image 2.1 and FLUX 3 Klein

Included in every plan and available with the same key, through the OpenAI-compatible API (/v1/images) and in the Naistera mode of the sillyimages extension for SillyTavern; they are not available via SD WebUI or MCP. We run them on our own GPU. The two models share one limit of 50, 75 or 120 images per day depending on the plan (3 images, once, on the trial key), separate from NovelAI; an edit counts as one image. While the service runs from the backup server these models are unavailable: the request returns an error and does not use up your limit.

Qwen-Image 2.1

The main one: generation and editing from a description, up to 3 source images. qwen-image-2.1

about 30 s

FLUX 3 Klein

The fastest: generation and editing, up to 10 source images. flux-3-klein-image

about 10 s

URL, key and models

base_url https://novelai.api.aniworldai.org/v1

The key is passed like a regular OpenAI key — in the Authorization: Bearer YOUR_KEY header. To get one, sign in with Telegram and pay for a plan.

  • nai-v5-medium: NovelAI V5 Full Medium, usually 4–6 seconds;
  • nai-v4.5-full: NovelAI V4.5 Full, about 14 seconds.

GET /v1/models returns the model list with what each model supports.

Qwen-Image 2.1 and FLUX 3 Klein

These models work with the same key through the OpenAI-compatible API and in the Naistera mode of the sillyimages extension (SillyTavern); they are not available via SD WebUI or MCP. Both share one allowance of 50, 75 or 120 images per day depending on the plan (Plus, Duke, Emperor): your day starts with the first image, and 24 hours later the allowance comes back in full. The trial key gets 3 images, once: generations and edits together, separately from the NovelAI allowance.

  • qwen-image-2.1: the main one, generation and editing, up to 3 source images;
  • flux-3-klein-image: the fastest, generation and editing, up to 10 source images.

Start with size="auto". In edits, the first image defines the canvas; the others are references. The server adapts your prompt for the model. To keep your original prompt, use extra_body={"prompt_adaptation": False}.

The shared allowance is shown by GET /v1/account: gpu_daily_images, gpu_daily_used, gpu_daily_left. In sillyimages the simplest option is Naistera mode: the URL is https://novelai.api.aniworldai.org with no suffix, and qwen-image-2.1 and flux-3-klein-image appear in the model list. For the OpenAI-compatible mode of sillyimages there is a dedicated compatibility URL:

sillyimages Endpoint URL https://novelai.api.aniworldai.org/sillyimages

Python: OpenAI SDK

Python
import base64
from openai import OpenAI

client = OpenAI(
    base_url="https://novelai.api.aniworldai.org/v1",
    api_key="YOUR_KEY",
)
image = client.images.generate(
    model="nai-v5-medium",
    prompt="1girl, silver hair, cafe, warm sunlight, best quality",
    size="832x1216",
)
with open("image.png", "wb") as f:
    f.write(base64.b64decode(image.data[0].b64_json))

The image comes in data[0].b64_json as base64, like gpt-image models.

JavaScript: openai for Node.js

JavaScript
import OpenAI from "openai";
import { writeFile } from "node:fs/promises";

const client = new OpenAI({
  baseURL: "https://novelai.api.aniworldai.org/v1",
  apiKey: process.env.NOVELAI_KEY,
});
const image = await client.images.generate({
  model: "nai-v5-medium",
  prompt: "1girl, silver hair, cafe, warm sunlight, best quality",
  size: "832x1216",
});
await writeFile("image.png", Buffer.from(image.data[0].b64_json, "base64"));

The key is read from the NOVELAI_KEY environment variable.

curl

bash
curl https://novelai.api.aniworldai.org/v1/images/generations \
  -H "Authorization: Bearer $NOVELAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "nai-v5-medium", "prompt": "1girl, silver hair, cafe, warm sunlight, best quality", "size": "832x1216"}' \
  | jq -r '.data[0].b64_json' | base64 --decode > image.png

Image to image

One source image plus a prompt: images.edit. strength from 0 to 1 sets how much the source changes.

Python
with open("image.png", "rb") as source:
    edited = client.images.edit(
        model="nai-v4.5-full",
        prompt="1girl, silver hair, cafe, evening lighting",
        image=source,
        extra_body={"strength": 0.35},
    )

NovelAI models accept one source image. Qwen and Flux support several references as described above. Masks are not supported.

Sizes and parameters

  • One image per request, up to one megapixel (1,048,576 pixels), sides are multiples of 64: for example 832×1216, 1216×832, 1024×1024.
  • gpt-image and DALL·E sizes (1024×1536, 1792×1024) do not fail: the image keeps the aspect ratio and is scaled down to a megapixel.
  • quality, style and moderation are accepted, but the model decides the quality.
  • Seed, negative prompt, CFG and transparent background are supported; output is PNG, JPEG or WebP.

Retries without double charges

If the connection drops, repeat the same request: you get the image that was already drawn, and it is not charged twice. This works while the image is being drawn and for 10 minutes after the drop.

For your own retries send an Idempotency-Key header: the same key with the same parameters returns the same job. Change the value for a new image.

Python
image = client.images.generate(
    model="nai-v5-medium",
    prompt="1girl, silver hair, cafe, warm sunlight, best quality",
    extra_headers={"Idempotency-Key": "portrait-001"},
)

Errors and remaining quota

  • Errors use the OpenAI format: {"error": {"code": …, "message": …}}, the message is human-readable.
  • 401 missing_api_key: no key was sent; 401 invalid_api_key: the key is wrong or the plan has ended.
  • 429 key_daily_limit: the daily limit is used up. The error message says when the whole limit comes back, and the Retry-After header says in how many seconds to retry.
  • Remaining quota: GET /v1/account returns daily_images (daily limit), daily_used, daily_left and next_free_at, the time the whole limit comes back (Unix time; null means your day has not started yet and the whole limit is available).

Other endpoints

  • POST /v1/chat/completions: the image comes as a Markdown link in the reply; the prompt is taken from the last user message.
  • POST /v1/responses: the image_generation tool; the image is in output[] as base64.
  • stream=true in Chat and Responses: the stream reports the finished result. Images and Edits are used without streaming.
  • /v1/images/variations is retired by OpenAI and returns 410.

Every parameter is in the API documentation (Swagger); the reference for AI agents is the API llms.txt.

Questions

FAQ

Will my OpenAI code work?

Yes, if it lets you change base_url: set https://novelai.api.aniworldai.org/v1, use our key instead of the OpenAI key and the nai-v5-medium or nai-v4.5-full model.

How much does one image cost?

You pay for a 30-day plan, not per image. Lite, without NovelAI V5: Starter 40 images per day for 249 ₽, Plus 140 for 440 ₽, Duke 220 for 700 ₽, Emperor 340 for 1,050 ₽. Pro, with V5: Plus 620 ₽, Duke 950 ₽, Emperor 1,400 ₽. A used image returns to the quota after 24 hours.

Do I need my own NovelAI account?

No. The key gives you access to our NovelAI API, so you don’t need an account or Anlas.

Can I pass the key in the URL?

No, a regular key is accepted only in the Authorization: Bearer header.

What does the API return when the daily limit is used up?

Error 429 with the key_daily_limit code: the message says when the whole limit comes back, and the Retry-After header says how many seconds to wait. GET /v1/account shows the remaining quota in advance.