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.
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
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)
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)
MCP
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
Authorization: Bearer your-key
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
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:
https://novelai.api.aniworldai.org/sillyimages Python: OpenAI SDK
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
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
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.
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,styleandmoderationare 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.
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 theRetry-Afterheader says in how many seconds to retry.- Remaining quota:
GET /v1/accountreturnsdaily_images(daily limit),daily_used,daily_leftandnext_free_at, the time the whole limit comes back (Unix time;nullmeans 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: theimage_generationtool; the image is inoutput[]as base64.stream=truein Chat and Responses: the stream reports the finished result. Images and Edits are used without streaming./v1/images/variationsis retired by OpenAI and returns 410.
Every parameter is in the API documentation (Swagger); the reference for AI agents is the API llms.txt.
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.
Every use case, step by step
NovelAI in SillyTavern: setup with screenshots
Standard method and sillyimages: separate instructions, screenshots and copyable settings.
NovelAI in TAVO
TAVO’s built-in generator: API URL, key, models, your own style, image by link for presets and Smart expand.
NovelAI over MCP: Claude Code, Cursor and VS Code
Claude Code, Cursor and VS Code: the /mcp URL, the key in a header, ready-made configs.
NovelAI API pricing
Plus, Duke and Emperor for 30 days: how many NovelAI, Qwen-Image and FLUX images each includes, renewal and plan changes.
NovelAI from Russia: pay by SBP, no VPN
Pay by SBP, crypto or Telegram Stars, works without a VPN, no NovelAI account needed.
Characters’ look from avatars
The “Images by Not_Found” plugin for TAVO: how to take the characters’ look from avatars, one model and five steps.
Images in TAVO: the fastest way
The fastest way: NovelAI images in TAVO in nine steps, with screenshots and arrows.
Setup help
Answer one to three questions and get the guide for your case.
TAVO preset: an image in every reply
A preset in one click: the text model inserts an image into every reply itself, with no plugins.
NovelAI images in your roleplay chats
TAVO and SillyTavern. No VPN and no NovelAI account. Three images are free.