Skip to content

Chat Interface

Chat is a user interface that allows you to interact with the system in a conversational manner

ChatInterfaceScreenshot

Note

Chat supports image generation and post-processing workflows; video support is partial

Chat Messages

Chat messages represent individual interactions within a chat session:

  • Messages are stored in the chat database and associated with their respective session
  • Chat interface is a rich-media interface
    You can upload, drag&drop or paste images directly into the chat messages
  • Chat messages can also read a text file as a script
    Same commands work when scripted or entered interactively

Chat Session

Chat session represents a single conversation with the system: - You can list, activate, create, delete, rename chat sessions - Chat sessions are persistent and stored in the chat database - All chat parameters are stored and activated per-session

Tip

You can have separate sessions for different projects that have different model parameters switching between them will activate the corresponding parameters for each session

Tip

Although Chat is primarily designed for interactive use,
it also supports scripting for fully automated workflows
or monitoring and inspecting server state

Session Persistence

Things that are stored per chat session include:

  • Active context
  • Server settings
  • Model selection
  • Process parameters
  • Uploaded images
  • Chat history

Warning

Uploaded images are stored as references
If you clear your chat storage location, the uploaded images may no longer be available

Additionally, each chat session can have multiple snapshots (or bookmarks or versions)
What is a snapshot? A point-in-time capture of all params and settings at specific point in time

For example, you can set parameters of your choice, save a snapshot, run experiments with some different parameters and restore a snapshot

Session Context

Session context refers to main areas of SD.Next. Setting context impacts all subsequent commands and operations

Available contexts: - context image: used for all image generation tasks - context process: used for all image post-processing tasks - context video: used for all video generation tasks - context caption: used for all caption generation tasks

Note that commands such as list, get, set will operate within the currently active context and have different set of params to manage depending on the context.

UI vs Chat and Import

Parameters and settings in chat session are independent of the UI state and are maintained separately for each session
But you can import settings from the UI into a chat session or export chat session settings to the UI as needed

For example, use UI to change params in Control interface, then switch to Chat and click the Import button to bring those settings into the active chat session

Note

Import will only import settings that are set to non-default values in the UI

Run set to see exact values of all parameters that were imported from the UI

For example:

    context=image
    model=mine/tempestByVlad_hyperV01 [4104fc6601]
    image.cfg_scale=2.0
    image.steps=6
    image.styles=['Fixed Astronaut']
    image.nvidia_dlss:dlss_enabled=['NeuralRender']

Commands

Run help for a list of available chat commands and their usage
Prefix a command with / to show composer suggestions, for example / or /help or /set
After get, set or clear, type a parameter prefix to complete a name available in the active context

All commands that expect a <value> support multiple input formats:
- key value, key to value, key=value, and key: value

When value is a choice, it accepts a unique partial match as long as the choice value can be uniquely identified
For example, "model klein-9b" will load Flux.2-Klein-9B-sdnq-uint4 if that is the only model that matches the string

Session

  • session/list: List existing sessions
  • session <number> or <name>: Activate a session by its list number or exact name
  • session del/rm: Delete the current session
  • session create/add [name]: Create a session and switch to it
  • title [name]: Read or set the current session name
  • snapshot (alias: snap): List saved settings snapshots
  • snapshot save: Save the current settings as a snapshot and list saved snapshots
  • snapshot <id>: Restore a saved settings snapshot by ID

Context

Choose a context and control active work

  • context <value>: Select the active context
  • clear: Clear displayed messages without changing session history
  • run [count]: Run the current context; image generation accepts a count from 1-10
  • generate/start: Start the current context once
  • schedule: Add the current image or video generation to the scheduler
  • cancel/abort/stop/interrupt: Stop the current process
  • pause: Pause the current process
  • resume: Resume a paused process
  • skip: Skip the current item
  • history [limit]: Show recent process history

Settings import and revisions are currently implemented only for the image context. In other contexts, these actions report that they are not yet implemented. - last/details: Show active parameters from the last processing run

Params

Set, inspect, and reset context parameters

  • prompt <value>: Set the prompt
  • negative <value>: Set the negative prompt
  • prefix `, ', " or > to set the prompt directly; the leading marker is removed
  • set [key] [value]: Set a value or list session values
  • get [key]: Get a value or list session values
  • clear <key>: Reset one parameter or setting to its default
  • params/args: List valid parameter keys for the current context
  • import: Import non-default settings from current UI controls
  • reset: Restore parameter defaults

References

Upload and manage reference images and command text

  • use/file <path>: Import a server-local text or image file
  • image list: List available session images
  • image save: Save all images from the latest result batch
  • image <number[,number...]>: Select one or more images as active inputs
  • image reuse: Select results image as next input image
  • image clear: Clear active image inputs
  • meta/exif/metadata: Inspect metadata for the last image

Helpers

List available options

  • list key: Show valid choices

Extras and Scripts

Extras appear in params as <script>:<field> keys.

For example, list nvidia_dlss:dlss_enabled shows valid choices for the dlss_enabled field of the nvidia_dlss script
And set nvidia_dlss:dlss_enabled=NeuralRender, SuperRes sets it to NeuralRender and SuperRes

The main and refine upscalers are also available as upscale:upscaler and upscale:refiner in process context. For example, use list upscale:upscaler to see valid choices and set upscale:upscaler <value> to choose one.

Process

Enabled with context: process

In process context, bare list shows available post-processing scripts. Use list <script> to show that script's arguments, defaults, and choices.
Script names match case-insensitively; spaces and underscores are interchangeable, for example list nvidia_dlss.
Use set <script>:<argument> <value>, get <script>:<argument>, and clear <script>:<argument> to manage script options.

Commands run, generate, and again post-process selected images.
If no image is selected, process uses the latest available result image.
Uploaded images are selected when imported.
Use image <number[,number...]> to select one or more session images.

Prompt Writing

Chat composer includes syntax highlighting to improve readability and organization of prompts Normally, prompt should be set using set prompt ..., but to quickly provide a prompt inline, you can prefix it with `, ', " or >; the leading marker will be removed when processing the prompt

For example:

    ` A quick inline prompt example
    ' Another inline prompt example
    " Yet another inline prompt example
    > And one more inline prompt example

Global

Read or change settings shared across sessions

  • model [model] [unet]: Show or change the model and optional finetune component
  • opts [key] [value]: Read or update global options

Server

Query runtime, device, memory, and storage details

  • info/ver/version: Show runtime version details
  • gpu/smi: Show GPU metrics
  • mem/memory: Show RAM, CUDA, and model usage
  • status: Show server status and progress
  • storage: Show storage usage
  • db: Compact the Chat database and show database statistics

Example

Example session commands

Upload it to chat using "Attach file", drag & drop, copy & paste
Or Refer to the file by path for example: file tmp/chat.txt
Or simply type those commands directly into the chat in a conversational manner

Example: Text-to-Image

    # check system
    info
    gpu
    mem

    # set session
    title test session
    model tempestByVlad_hyperV01
    context image

    # set globals
    opts samples_save false

    # set params
    reset
    image clear
    set steps 8
    set cfg_scale 1
    set sampler UniPC
    set detailer_enabled true
    set width 960
    set height 1280
    set styles "Cycle Style"
    set nvidia_dlss:dlss_enabled=NeuralRender, SuperRes

    # print active parameters
    set

    # set prompt
    prompt "cute android on a futuristic city rooftop at sunset"

    # run generate
    run

    # post generate
    image save
    details
    metadata

    # re-run with batch
    opts samples_save true
    run 5
    info

Example: Image Editing

    title edit session

    # load edit model as we can use multiple reference images
    # model will be matched based on string dont need to enter full name
    model klein-9b

    # upload images using path, you can also drag & drop or paste them directly into the chat
    file path/to/first_image.jpg
    file path/to/second_image.jpg

    # check if images are both present
    image list

    # select both
    image 1,2

    # set prompt
    prompt "change the background in the first image to match the second image"

    # run generate
    generate

    # set result image as input image for further edits
    image reuse
    prompt "change hair color to blonde"
    generate

Example: Image Post-processing

    context process
    image list
    image 1,2
    list
    list upscale:upscaler
    set upscale:upscaler "Spandrel 2x RealPLKSR AnimeSharpV2"
    set nvidia_dlss:dlss_enabled NeuralRender
    run

Settings

Chat has only the following settings:

  • Chat enabled: globally enable/disable chat feature
  • Chat upload directory: specify the folder for chat artifacts; leave empty for default temporary location
  • Chat database directory: specify the folder for chat database; leave empty for default location models/chat

Control Settings Snapshots

Use Import Control in the Control interface while an image Chat session is active to capture non-default generation parameters and always-on script Extras. Control-unit settings and input images are not included.

Each import creates an immutable snapshot. snapshot (or snap) lists snapshots newest first and marks the active snapshot; the listing is transient and is not added to chat history. snapshot <id> restores that snapshot and is recorded as a normal Chat exchange. Restore replaces the parameters and Extras owned by the active imported snapshot while preserving unrelated draft values. Chat edits take precedence until the next import or restore. snapshot save captures the current image draft as another immutable snapshot.

Technical

  • Uses SQLite as its underlying database for storing chat history and metadata
  • Stores chat artifacts such as uploaded files and generated images in the specified directory
  • Uses SD.Next API for all operations, no dependency on Gradio
  • Available in ModernUI or via API, not available in StandardUI

API

Chat endpoints use the /sdapi/v1/chat prefix and are grouped under the Chat tag in the generated OpenAPI documentation.

  • GET / POST /sessions: List or create sessions
  • GET / PATCH / DELETE /sessions/{session_id}: Read, update, or delete a session; POST /sessions/{session_id}/restore restores it
  • POST /sessions/{session_id}/messages: Submit a message or command; PATCH /sessions/{session_id}/messages/{message_id} edits a message
  • POST /sessions/{session_id}/files: Upload a file to a session
  • /sessions/{session_id}/artifacts/{artifact_id} routes provide artifact content (GET .../content), open-folder and save actions (POST), and deletion (DELETE)

Roadmap

  • Chat support for Video workflow (partially implemented)
  • Chat support for Caption workflow
  • Chat support for Inpainting workflow
  • Kanvas edit for images
  • Add OpenAI compatible API endpoints
  • Augment chat with LLM capabilities