> ## Documentation Index
> Fetch the complete documentation index at: https://docs.square1.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate an illustration (NovelAI-compatible)

> A synchronous, NovelAI-protocol image endpoint — point any client
that speaks NovelAI's `/ai/generate-image` (e.g. RisuAI's
Lightboard) at this path with your Square1 key as the Bearer token.

Checkpoint, LoRAs, sampler, and quality settings come from your
**active illustration preset** (dashboard → Images →
ILLUSTRATION), not from the request — the NAI `model` field is
accepted and ignored. See the Illustration API guide for the full
parameter-precedence rules.

The response is a ZIP archive containing one PNG (exactly what a
NovelAI client expects). Errors use NovelAI's
`{statusCode, message}` shape, **not** the OpenAI envelope used by
the rest of this API. Generated images are private — they never
enter the public gallery.

Members-only: requires an active account (and a registered email
when email enforcement is on). Image generation draws from the
image queue capacity, not from your LLM token quota.




## OpenAPI

````yaml /openapi.yaml post /v1/images/nai/generate-image
openapi: 3.1.0
info:
  title: Square1 API
  version: 1.0.0
  description: |
    OpenAI-compatible LLM gateway API.

    All endpoints live on `https://inference.square1.dev` and require a
    Square1 API key (`sq-arca-...`, or a legacy `ws-...` key) sent as a
    Bearer token.

    The wire format follows the OpenAI Chat Completions / Embeddings /
    Models conventions, with a small set of documented vendor extensions:
    the `reasoning_effort` request field, the `reasoning` delta/message
    field, and the `wellspring` quota-receipt block on chat responses.
servers:
  - url: https://inference.square1.dev
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: OpenAI-compatible chat completions.
  - name: Embeddings
    description: OpenAI-compatible embeddings.
  - name: Models
    description: The model catalog as visible to your key.
  - name: Account
    description: Read-only introspection for the authenticated key.
  - name: Illustration
    description: NovelAI-compatible synchronous image generation.
paths:
  /v1/images/nai/generate-image:
    post:
      tags:
        - Illustration
      summary: Generate an illustration (NovelAI-compatible)
      description: |
        A synchronous, NovelAI-protocol image endpoint — point any client
        that speaks NovelAI's `/ai/generate-image` (e.g. RisuAI's
        Lightboard) at this path with your Square1 key as the Bearer token.

        Checkpoint, LoRAs, sampler, and quality settings come from your
        **active illustration preset** (dashboard → Images →
        ILLUSTRATION), not from the request — the NAI `model` field is
        accepted and ignored. See the Illustration API guide for the full
        parameter-precedence rules.

        The response is a ZIP archive containing one PNG (exactly what a
        NovelAI client expects). Errors use NovelAI's
        `{statusCode, message}` shape, **not** the OpenAI envelope used by
        the rest of this API. Generated images are private — they never
        enter the public gallery.

        Members-only: requires an active account (and a registered email
        when email enforcement is on). Image generation draws from the
        image queue capacity, not from your LLM token quota.
      operationId: naiGenerateImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NaiGenerateRequest'
            examples:
              basic:
                value:
                  input: 1girl, silver hair, looking at viewer, masterpiece
                  action: generate
                  parameters:
                    negative_prompt: lowres, bad anatomy
                    width: 832
                    height: 1216
                    steps: 28
                    seed: 1234567890
                    scale: 5
      responses:
        '200':
          description: A ZIP archive containing the generated PNG.
          content:
            application/x-zip-compressed:
              schema:
                type: string
                format: binary
        '400':
          description: >
            Invalid request, unsupported `action`, or blocked content (the
            message lists the blocked category).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NaiError'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NaiError'
        '403':
          description: Admin-only mode, or account not eligible.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NaiError'
        '429':
          description: >
            Your pending illustration queue is full (up to 2 queued requests per
            account) — wait for the current generation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NaiError'
        '500':
          description: Generation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NaiError'
        '503':
          description: >
            Feature disabled, maintenance, server queue congested, or no GPU
            worker currently available.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NaiError'
        '504':
          description: The generation did not finish within 180 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NaiError'
components:
  schemas:
    NaiGenerateRequest:
      type: object
      required:
        - input
      properties:
        input:
          type: string
          maxLength: 8000
          description: The prompt, in NovelAI syntax (converted server-side).
        model:
          type: string
          maxLength: 128
          description: >-
            Accepted for protocol compatibility and ignored — the checkpoint
            comes from your active illustration preset.
        action:
          type: string
          description: If present, must be `generate`.
        parameters:
          type: object
          properties:
            negative_prompt:
              type: string
              maxLength: 8000
            width:
              type: integer
              maximum: 4096
              description: >
                Snapped (with `height`) to the nearest allowed resolution by
                aspect ratio (e.g. 832×1216, 1024×1024, 1216×832). Both must be
                present to take effect.
            height:
              type: integer
              maximum: 4096
            steps:
              type: integer
              minimum: 1
              maximum: 60
              description: >
                Clamped to the preset's step bounds. Precedence: request >
                profile default > preset default.
            seed:
              type: integer
              minimum: 0
            scale:
              type: number
              description: >
                NAI guidance scale (CFG). If your illustration preset sets a CFG
                default, the preset value wins over this field.
    NaiError:
      type: object
      description: NovelAI-shaped error — used ONLY by the illustration endpoint.
      required:
        - statusCode
        - message
      properties:
        statusCode:
          type: integer
        message:
          type: string
          description: Human-readable, in Korean.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        A Square1 API key: `Authorization: Bearer sq-arca-...` (legacy `ws-...`
        keys remain valid). Create and rotate keys from the dashboard.

````