1. Choose one protocol (never mix fields)
| Scenario | Full Endpoint | Model & Prompt Fields |
|---|---|---|
| Native NovelAI protocol (Recommended) | POST https://noveadream.com/ai/generate-image | model: nai-diffusion-5-full / nai-diffusion-4-5-full; input; action; parameters |
| OpenAI-compatible image client (V4.5) | POST https://noveadream.com/v1/images/generations | model: nai-v4.5; prompt |
| Async workbench tasks, quotes, Vibe & SSE | POST /v1/nai/estimate → POST /v1/nai/generations | model: nai-v4.5; model_variant: exact version; prompt; quote_id |
Critical rules for AI coding agents: POST /ai/generate-image does NOT use /v1, requires an exact version ID in model (never nai-v4.5 or nai-v5), puts the prompt in input (not prompt), and returns HTTP 201 Created on success (check 200 <= status < 300, never hardcode status == 200). Machine-readable schema: NAI OpenAPI 3.1 JSON Schema.
2. Configure your API key & Idempotency-Key
Create an API key (sk-...) on NoveaDream and send Authorization: Bearer <API_KEY>. If model restrictions are enabled on the key, allow nai-v4.5 (which unlocks all V3 / V4 / V4.5 / V5 variants on the native endpoint). Never send an official NovelAI pst-... token.
$env:NOVEA_API_KEY = "sk-your-noveadream-key"
$env:NOVEA_REQUEST_ID = [guid]::NewGuid().ToString()
$env:REQUEST_ID = $env:NOVEA_REQUEST_IDexport NOVEA_API_KEY="sk-your-noveadream-key"
export REQUEST_ID="$(python3 -c 'import uuid; print(uuid.uuid4())')"
export NOVEA_REQUEST_ID="$REQUEST_ID"3. Exact model IDs & capabilities
| Display Name | model (for /ai/generate-image) | Character Limit | Precise Reference |
|---|---|---|---|
| NAI V5 Full | nai-diffusion-5-full | 32 | Supported (up to 8, incl. outfit modes) |
| NAI V5 Curated | nai-diffusion-5-curated | 32 | Supported (up to 8, incl. outfit modes) |
| NAI V4.5 Full | nai-diffusion-4-5-full | 6 | Supported (up to 4) |
| NAI V4.5 Curated | nai-diffusion-4-5-curated | 6 | Supported (up to 4) |
| NAI V4 Full | nai-diffusion-4-full | 6 | Unsupported |
| NAI V4 Curated | nai-diffusion-4-curated-preview | 6 | Unsupported |
| NAI Anime V3 | nai-diffusion-3 | 0 | Unsupported |
| NAI Furry V3 | nai-diffusion-furry-3 | 0 | Unsupported |
For masked inpainting (action: "infill"), append -inpainting to the model ID (e.g. nai-diffusion-5-full-inpainting). V5 Economy (Medium) is web-workspace-only.
4. Interactive runnable examples (Python / Node.js / JSON)
Select a model and operation to generate zero-dependency scripts for text-to-image, img2img, inpainting, Precise Reference (V5 & V4.5), and multi-character prompts.
Download default Python script · Full parameter dictionary, v4_prompt characters & V5/V4.5 Precise Reference JSON
5. Submit with cURL
Save the JSON below as request.json. Strict JSON validation is enforced: do NOT send unknown fields or null values (omit seed for a random seed; never pass seed: null or -1).
{
"input": "watercolor, a blue ceramic teapot on a wooden table, soft daylight",
"model": "nai-diffusion-5-full",
"action": "generate",
"parameters": {
"width": 832,
"height": 1216,
"steps": 23,
"n_samples": 1,
"scale": 5,
"seed": 42,
"sampler": "k_euler_ancestral",
"negative_prompt": "lowres, blurry"
}
}curl --fail-with-body 'https://noveadream.com/ai/generate-image' \
-H "Authorization: Bearer $NOVEA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H "Idempotency-Key: $REQUEST_ID" \
--data-binary @request.json6. Parse responses (JSON & official ZIP) and handle retries
| Header / Case | HTTP Status & Payload |
|---|---|
Accept: application/json (Recommended) | 201 Created; returns {"images": [{"image": "RAW_BASE64_PNG", "index": 0, "seed": 42}]} (not OpenAI data[].url). |
No Accept header, or application/zip | 201 Created; binary application/zip archive containing image_0.png, image_1.png… matching official image.novelai.net. |
Header X-Generation-ID | Server generation ID for diagnostics. |
| Error body (400 / 401 / 402 / 403 / 409 / 502 / 504) | Controller returns {"statusCode": 400, "message": "..."} (402 = insufficient balance, 403 = key scope / access restriction, 409 = Idempotency-Key mismatch or concurrency conflict); auth/rate-limit middleware (401/429) may return {"error": {"message": "..."}}. On 504, check header X-Retry-Same-Key: retry with the SAME Idempotency-Key ONLY when true; when false, the task terminally timed out & refunded (use a NEW UUID for a new generation). |
{
"images": [
{
"image": "BASE64_PNG",
"index": 0,
"seed": 42
}
]
}import io, json, os, uuid, zipfile
from urllib.request import Request, urlopen
payload = {
"input": "1girl, solo, watercolor, soft daylight",
"model": "nai-diffusion-5-full",
"action": "generate",
"parameters": {
"width": 832, "height": 1216, "steps": 23, "n_samples": 1,
"scale": 5, "seed": 42, "sampler": "k_euler_ancestral", "negative_prompt": "lowres, blurry"
}
}
req = Request(
"https://noveadream.com/ai/generate-image",
data=json.dumps(payload).encode("utf-8"),
headers={
"Authorization": f"Bearer {os.environ['NOVEA_API_KEY']}",
"Content-Type": "application/json",
"Idempotency-Key": str(uuid.uuid4()),
},
method="POST",
)
with urlopen(req, timeout=660) as resp:
assert 200 <= resp.status < 300 # HTTP 201 Created
with zipfile.ZipFile(io.BytesIO(resp.read())) as zf:
zf.extractall("outputs") # Extracts image_0.png, image_1.png ...Need quotes, Vibe Transfer, or SSE streaming? See the /v1/nai/* extension API