---
title: "POST /ai/generate-image"
method: POST
path: "/ai/generate-image"
tags: ["/ai/"]
---

# POST /ai/generate-image

`POST /ai/generate-image`

## Request body

- AiGenerateImageRequest
  - `input` string, required — Input for the text generation model
  - `model` 'nai-diffusion' | 'safe-diffusion' | 'nai-diffusion-furry' | 'custom' | 'nai-diffusion-inpainting' | 'nai-diffusion-3-inpainting' | 'safe-diffusion-inpainting' | 'furry-diffusion-inpainting' | 'kandinsky-vanilla' | 'nai-diffusion-2' | 'nai-diffusion-3', required — Used image generation model
  - `action` 'generate' | 'img2img' | 'infill' — Action to use, default is generate
  - `parameters` object, required — Generation parameters (model specific)
  - `url` string — Custom image generation URL

## Response `201`

The request has been accepted and the output is generating (SSE / ZIP attachment).

- AiGenerateImageResponse
  - `ptr` number — Incrementing version pointer
  - `image` string — Generated image in base64
  - `final` boolean — Set to true if the image is final and the generation ended
  - `error` string — Error from the generation node, if defined. Usually means the end of stream

## Other responses

- `400` — A validation error occured.
- `401` — Access Token is incorrect.
- `402` — An active subscription is required to access this endpoint.
- `409` — A conflict error occured.
- `500` — An unknown error occured.

---

[API](https://skmtc.net/novelai/apis/novelai-primary-api.md) · [All operations](https://skmtc.net/novelai/apis/novelai-primary-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/novelai/novelai-primary-api/revisions/327b3674db26/schema)
