### Install Frontend Dependencies Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/README.md Navigates to the frontend directory and installs project dependencies using pnpm. This is a prerequisite for building the frontend. ```bash cd examples/server/frontend pnpm install ``` -------------------------------- ### Start Default RPC Server (Second Machine) Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/rpc.md Starts a default RPC server instance on a separate machine. ```bash cd ./build/bin/Release ./rpc-server --host 0.0.0.0 ``` -------------------------------- ### Installing Library and Headers Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/CMakeLists.txt Installs the library target (${SD_LIB}) along with its public headers. This makes the library and its API available for use by other projects after installation. ```cmake install(TARGETS ${SD_LIB} LIBRARY PUBLIC_HEADER) ``` -------------------------------- ### Install Executable Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/cli/CMakeLists.txt Installs the built 'sd-cli' target, making it available for runtime execution. ```cmake install(TARGETS ${TARGET} RUNTIME) ``` -------------------------------- ### LTX-2.3 Frame-to-Frame Video Generation Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/ltx2.md This example demonstrates frame-to-frame video generation, using both an initial and a final image to guide the transformation. The `--init-img` and `--end-img` flags are crucial for this mode. ```bash .\bin\Release\sd-cli.exe -M vid_gen --diffusion-model ..\..\ComfyUI\models\diffusion_models\ltx-2.3-22b-dev-UD-Q4_K_M.gguf --vae ..\..\ComfyUI\models\vae\ltx-2.3-22b-dev_video_vae.safetensors --audio-vae ..\..\ComfyUI\models\vae\ltx-2.3-22b-dev_audio_vae.safetensors --llm ..\..\ComfyUI\models\text_encoders\gemma-3-12b-it-qat-UD-Q4_K_XL.gguf --embeddings-connectors ..\..\ComfyUI\models\text_encoders\ltx-2.3-22b-dev_embeddings_connectors.safetensors -p "glass flower blossom" --cfg-scale 6.0 --sampling-method euler -v -W 1280 -H 720 --diffusion-fa --offload-to-cpu --video-frames 33 --init-img ..\..\ComfyUI\input\start_image.png --end-img ..\..\ComfyUI\input\end_image.png -o flf2v.webm ``` -------------------------------- ### Run Chroma1-Radiance with sd-cli Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/chroma_radiance.md Example command to generate an image using the Chroma1-Radiance model and t5xxl text encoder with the sd-cli tool. Ensure the model paths are correct for your setup. ```bash .\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\Chroma1-Radiance-v0.4-Q8_0.gguf --t5xxl ..\..\ComfyUI\models\clip\t5xxl_fp16.safetensors -p "a lovely cat holding a sign says 'chroma radiance cpp'" --cfg-scale 4.0 --sampling-method euler -v ``` -------------------------------- ### Run RPC Server (Default Address) Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/rpc.md Start the RPC server on the default address, typically localhost:50052. Ensure the server machine has the necessary drivers installed. ```bash ./rpc-server ``` -------------------------------- ### Start Vulkan RPC Server Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/rpc.md Starts an RPC server instance configured for Vulkan, ignoring the first GPU if it's already in use. ```bash cd ./build_vulkan/bin/Release # ignore the first GPU (used by CUDA server) ./rpc-server --host 0.0.0.0 --port 50053 -d Vulkan1,Vulkan2 ``` -------------------------------- ### Run ERNIE-Image-Turbo Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/ernie_image.md Example command to run ERNIE-Image-Turbo using stable-diffusion.cpp. Ensure all model paths are correct for your setup. ```bash .\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\ernie-image-turbo.safetensors --vae ..\..\ComfyUI\models\vae\flux2_ae.safetensors --llm ..\..\ComfyUI\models\text_encoders\ministral-3-3b.safetensors -p "a lovely cat" --cfg-scale 1.0 --steps 8 -v --offload-to-cpu --diffusion-fa ``` -------------------------------- ### Run Z-Image-Turbo Example Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/z_image.md Command to generate an image using the Z-Image-Turbo model with specific GGUF weights and a detailed prompt. This example utilizes CPU offloading and specifies image dimensions and steps. ```command-line .\bin\Release\sd-cli.exe --diffusion-model z_image_turbo-Q3_K.gguf --vae ..\..\ComfyUI\models\vae\ae.sft --llm ..\..\ComfyUI\models\text_encoders\Qwen3-4B-Instruct-2507-Q4_K_M.gguf -p "A cinematic, melancholic photograph of a solitary hooded figure walking through a sprawling, rain-slicked metropolis at night. The city lights are a chaotic blur of neon orange and cool blue, reflecting on the wet asphalt. The scene evokes a sense of being a single component in a vast machine. Superimposed over the image in a sleek, modern, slightly glitched font is the philosophical quote: 'THE CITY IS A CIRCUIT BOARD, AND I AM A BROKEN TRANSISTOR.' -- moody, atmospheric, profound, dark academic" --cfg-scale 1.0 -v --offload-to-cpu --diffusion-fa -H 1024 -W 512 --steps 8 ``` -------------------------------- ### Conditional Examples Subdirectory Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/CMakeLists.txt Adds the 'examples' subdirectory to the build if the SD_BUILD_EXAMPLES variable is set to true. This allows for selective building of example applications. ```cmake if (SD_BUILD_EXAMPLES) add_subdirectory(examples) endif() ``` -------------------------------- ### Start CUDA RPC Server (Linux/WSL) Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/rpc.md Starts an RPC server instance on Linux or WSL, specifically configured to use the CUDA device. ```bash # Linux / WSL export CUDA_VISIBLE_DEVICES=0 cd ./build_cuda/bin/Release ./rpc-server --host 0.0.0.0 ``` -------------------------------- ### Install and Link Libraries Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/CMakeLists.txt Configures installation rules for the target executable and links necessary libraries. It also conditionally links libraries and defines compile flags based on WEBP and WEBM support, and includes platform-specific libraries. ```cmake install(TARGETS ${TARGET} RUNTIME) target_link_libraries(${TARGET} PRIVATE stable-diffusion ${CMAKE_THREAD_LIBS_INIT}) if(SD_WEBP) target_compile_definitions(${TARGET} PRIVATE SD_USE_WEBP) target_link_libraries(${TARGET} PRIVATE webp libwebpmux) endif() if(SD_WEBM) target_compile_definitions(${TARGET} PRIVATE SD_USE_WEBM) target_link_libraries(${TARGET} PRIVATE webm) endif() # due to httplib; it contains a pragma for MSVC, but other things need explicit flags if(WIN32 AND NOT MSVC) target_link_libraries(${TARGET} PRIVATE ws2_32) endif() target_compile_features(${TARGET} PUBLIC c_std_11 cxx_std_17) ``` -------------------------------- ### Run Z-Image-Base Example Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/z_image.md Command to generate an image using the Z-Image-Base model with safetensors weights and a detailed prompt. This example uses a different CFG scale and specifies image dimensions. ```command-line .\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\z_image_bf16.safetensors --vae ..\..\ComfyUI\models\vae\ae.sft --llm ..\..\ComfyUI\models\text_encoders\qwen_3_4b.safetensors -p "A cinematic, melancholic photograph of a solitary hooded figure walking through a sprawling, rain-slicked metropolis at night. The city lights are a chaotic blur of neon orange and cool blue, reflecting on the wet asphalt. The scene evokes a sense of being a single component in a vast machine. Superimposed over the image in a sleek, modern, slightly glitched font is the philosophical quote: 'THE CITY IS A CIRCUIT BOARD, AND I AM A BROKEN TRANSISTOR.' -- moody, atmospheric, profound, dark academic" --cfg-scale 5.0 -v --offload-to-cpu --diffusion-fa -H 1024 -W 512 ``` -------------------------------- ### Serve Custom HTML Frontend Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/README.md Starts the sd-server and serves a specified HTML file as the frontend. Useful for development, testing, or using a custom UI. ```bash sd-server --serve-html-path ./index.html ``` -------------------------------- ### Build with OpenBLAS Support Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md Build the project with OpenBLAS enabled for optimized CPU performance. Ensure OpenBLAS is installed on your system. ```bash mkdir build && cd build cmake .. -DGGML_OPENBLAS=ON cmake --build . --config Release ``` -------------------------------- ### Start CUDA RPC Server (Windows PowerShell) Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/rpc.md Starts an RPC server instance on Windows using PowerShell, configured for CUDA device usage. ```powershell # Windows PowerShell $env:CUDA_VISIBLE_DEVICES="0" cd .\build_cuda\bin\Release ./rpc-server --host 0.0.0.0 ``` -------------------------------- ### Basic PuLID Command-Line Execution Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/pulid.md Example of running the sd-cli with PuLID enabled. Ensure all three PuLID flags are set together. ```bash .\bin\Release\sd-cli.exe \ --diffusion-model models\flux1-schnell-Q4_K_S.gguf \ --vae models\ae.safetensors \ --clip_l models\clip_l.safetensors \ --t5xxl models\t5xxl_fp16.safetensors \ --pulid-weights models\pulid_flux_v0.9.1.safetensors \ --pulid-id-embedding source.pulidembd \ --pulid-id-weight 1.0 \ -p "candid photograph of a young woman on a beach at sunset" \ --cfg-scale 1.0 --sampling-method euler --steps 4 -W 512 -H 512 \ --seed 42 --clip-on-cpu \ -o out.png ``` -------------------------------- ### Run RPC Server (All Interfaces) Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/rpc.md Start the RPC server to listen on all available network interfaces (0.0.0.0), allowing connections from other machines. Only run on trusted networks due to lack of authentication/encryption. ```bash ./rpc-server --host 0.0.0.0 ``` -------------------------------- ### GET /sdapi/v1/options Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves the current server options. ```APIDOC ## GET /sdapi/v1/options ### Description Retrieves the current server options. ### Method GET ### Endpoint /sdapi/v1/options ### Response #### Success Response (200) - **options** (object) - An object containing the server options. #### Response Example ```json { "options": { "sd_model_checkpoint": "sd-v1-5", "sampler_name": "Euler a" } } ``` ``` -------------------------------- ### CPU Offload Flag Example Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/backend.md Demonstrates the usage of the `--offload-to-cpu` flag to set a CPU default for parameter backends. Later explicit assignments can override this default. ```shell --params-backend "*=cpu" ``` -------------------------------- ### Build with WebP/WebM Disabled Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md Configure and build the project disabling WebP and WebM support. This is useful if you do not need image or video I/O support in the examples. ```bash mkdir build && cd build cmake .. -DSD_WEBP=OFF -DSD_WEBM=OFF cmake --build . --config Release ``` -------------------------------- ### Verifying Clang++ Version Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/hipBLAS_on_Windows.md Verify the installed version of clang++ to confirm it matches the clang version and is correctly set up. ```command-line clang++ --version ``` -------------------------------- ### Build stable-diffusion.cpp with RPC Client Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/rpc.md Build the client application with the RPC backend enabled. Ensure to include other necessary build flags for your setup. ```bash mkdir build cd build cmake .. \ -DSD_RPC=ON \ # Add other build flags here (e.g., -DSD_VULKAN=ON) cmake --build . --config Release -j $(nproc) ``` -------------------------------- ### Build with CUDA GPU Acceleration Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md Build the project with CUDA support for NVIDIA GPU acceleration. Requires the CUDA toolkit to be installed and sufficient VRAM (recommended 4 GB). ```bash mkdir build && cd build cmake .. -DSD_CUDA=ON cmake --build . --config Release ``` -------------------------------- ### Run sd-server with Standalone Models Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/README.md Starts the sd-server with a specified diffusion model, VAE, and LLM text encoder. Useful for running a self-contained diffusion pipeline. ```bash .\bin\Release\sd-server.exe --diffusion-model ..\models\diffusion_models\z_image_turbo_bf16.safetensors --vae ..\models\vae\ae.sft --llm ..\models\text_encoders\qwen_3_4b.safetensors --diffusion-fa --offload-to-cpu -v --cfg-scale 1.0 ``` -------------------------------- ### Qwen Image Edit CLI Example Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/qwen_image_edit.md Use this command to perform image editing with the base Qwen Image Edit model. Ensure all specified model paths are correct. ```bash .\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\Qwen_Image_Edit-Q8_0.gguf --vae ..\..\ComfyUI\models\vae\qwen_image_vae.safetensors --llm ..\..\ComfyUI\models\text_encoders\qwen_2.5_vl_7b.safetensors --cfg-scale 2.5 --sampling-method euler -v --offload-to-cpu --diffusion-fa --flow-shift 3 -r ..\assets\flux\flux1-dev-q8_0.png -p "change 'flux.cpp' to 'edit.cpp'" --seed 1118877715456453 ``` -------------------------------- ### Display Server Help Information Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/README.md Prints detailed command-line arguments and usage information for the sd-server. Use this to understand all available options. ```bash ./bin/sd-server -h ``` -------------------------------- ### Display CLI Help Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/cli/README.md Run this command to see all available command-line arguments and options for the sd-cli tool. ```bash ./bin/sd-cli -h ``` -------------------------------- ### Build Using System WebP/WebM Libraries Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md Configure and build the project using system-installed WebP and WebM libraries instead of submodules. This is an alternative if submodules are unavailable or problematic. ```bash mkdir build && cd build cmake .. -DSD_USE_SYSTEM_WEBP=ON -DSD_USE_SYSTEM_WEBM=ON cmake --build . --config Release ``` -------------------------------- ### Example Command for Image Generation Source: https://github.com/leejet/stable-diffusion.cpp/wiki/How-to-Use-Z‐Image-on-a-GPU-with-Only-4GB-VRAM This command demonstrates how to generate an image using Z-Image Turbo and Qwen3-4B models with specific optimization flags for low VRAM usage. Ensure the model and VAE paths are correct. ```bash .\bin\Release\sd-cli.exe --diffusion-model z_image_turbo-Q3_K.gguf --vae ae.safetensors --llm Qwen3-4B-Instruct-2507-Q4_K_M.gguf -p "A cinematic, melancholic photograph of a solitary hooded figure walking through a sprawling, rain-slicked metropolis at night. The city lights are a chaotic blur of neon orange and cool blue, reflecting on the wet asphalt. The scene evokes a sense of being a single component in a vast machine. Superimposed over the image in a sleek, modern, slightly glitched font is the philosophical quote: 'THE CITY IS A CIRCUIT BOARD, AND I AM A BROKEN TRANSISTOR.' -- moody, atmospheric, profound, dark academic" --cfg-scale 1.0 -v --offload-to-cpu --diffusion-fa -H 1024 -W 512 ``` -------------------------------- ### Run Wan2.1 T2V 1.3B Model Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/wan.md Example command to generate video using the Wan2.1 T2V 1.3B model. Ensure all specified model files (diffusion, VAE, T5xxl) are correctly placed. ```bash .\bin\Release\sd-cli.exe -M vid_gen --diffusion-model ..\..\ComfyUI\models\diffusion_models\wan2.1_t2v_1.3B_fp16.safetensors --vae ..\..\ComfyUI\models\vae\wan_2.1_vae.safetensors --t5xxl ..\..\ComfyUI\models\text_encoders\umt5-xxl-encoder-Q8_0.gguf -p "a lovely cat" --cfg-scale 6.0 --sampling-method euler -v -n "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部, 畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走" -W 832 -H 480 --diffusion-fa --video-frames 33 --flow-shift 3.0 ``` -------------------------------- ### Verify Node.js and pnpm Installation Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/README.md Checks the installed versions of Node.js and pnpm. Ensures that the required versions are met for frontend development. ```bash node -v pnpm -v ``` -------------------------------- ### Install pnpm Package Manager Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/README.md Installs the pnpm package manager globally using npm. pnpm is required for building the web frontend. ```bash npm install -g pnpm ``` -------------------------------- ### Run Wan2.1 T2V 14B Model Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/wan.md Example command to generate video using the Wan2.1 T2V 14B model. This command includes an `--offload-to-cpu` flag, which may be useful for systems with limited VRAM. ```bash .\bin\Release\sd-cli.exe -M vid_gen --diffusion-model ..\..\ComfyUI\models\diffusion_models\wan2.1-t2v-14b-Q8_0.gguf --vae ..\..\ComfyUI\models\vae\wan_2.1_vae.safetensors --t5xxl ..\..\ComfyUI\models\text_encoders\umt5-xxl-encoder-Q8_0.gguf -p "a lovely cat" --cfg-scale 6.0 --sampling-method euler -v -n "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走" -W 832 -H 480 --diffusion-fa --offload-to-cpu --video-frames 33 --flow-shift 3.0 ``` -------------------------------- ### Install Vulkan Dependencies on Ubuntu Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md Installs essential build tools, Vulkan development packages, and SPIR-V headers required for Vulkan builds on Ubuntu systems. ```shell sudo apt-get install build-essential libvulkan-dev glslc spirv-headers ``` -------------------------------- ### Configure Frontend Build Options Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/CMakeLists.txt Sets up options and variables related to building the server's frontend. It checks for the existence of pnpm and the frontend directory to determine if the frontend build should be enabled. ```cmake set(TARGET sd-server) option(SD_SERVER_BUILD_FRONTEND "Build server frontend with pnpm" ON) set(FRONTEND_DIR "${CMAKE_CURRENT_SOURCE_DIR}/frontend") set(GENERATED_HTML_HEADER "${FRONTEND_DIR}/dist/gen_index_html.h") set(HAVE_FRONTEND_BUILD OFF) if(SD_SERVER_BUILD_FRONTEND AND EXISTS "${FRONTEND_DIR}") if(WIN32) find_program(PNPM_EXECUTABLE NAMES pnpm.cmd pnpm) else() find_program(PNPM_EXECUTABLE NAMES pnpm) endif() if(PNPM_EXECUTABLE) message(STATUS "Frontend dir found: ${FRONTEND_DIR}") message(STATUS "pnpm found: ${PNPM_EXECUTABLE}") set(HAVE_FRONTEND_BUILD ON) add_custom_target(${TARGET}_frontend_install COMMAND "${PNPM_EXECUTABLE}" -C "${FRONTEND_DIR}" install WORKING_DIRECTORY "${FRONTEND_DIR}" COMMENT "Installing frontend dependencies" VERBATIM ) add_custom_target(${TARGET}_frontend_build COMMAND "${PNPM_EXECUTABLE}" -C "${FRONTEND_DIR}" run build WORKING_DIRECTORY "${FRONTEND_DIR}" COMMENT "Building frontend" VERBATIM ) add_custom_target(${TARGET}_frontend_header COMMAND "${PNPM_EXECUTABLE}" -C "${FRONTEND_DIR}" run build:header WORKING_DIRECTORY "${FRONTEND_DIR}" COMMENT "Generating gen_index_html.h" VERBATIM ) add_dependencies(${TARGET}_frontend_build ${TARGET}_frontend_install) add_dependencies(${TARGET}_frontend_header ${TARGET}_frontend_build) add_custom_target(${TARGET}_frontend DEPENDS ${TARGET}_frontend_header ) set_source_files_properties("${GENERATED_HTML_HEADER}" PROPERTIES GENERATED TRUE) else() if(EXISTS "${GENERATED_HTML_HEADER}") message(STATUS "pnpm not found; using pre-built frontend header detected at ${GENERATED_HTML_HEADER}") set(HAVE_FRONTEND_BUILD ON) add_custom_target(${TARGET}_frontend) else() message(WARNING "pnpm not found; frontend build disabled.") endif() endif() else() message(STATUS "Frontend disabled or directory not found: ${FRONTEND_DIR}") endif() ``` -------------------------------- ### Clone and Install OpenCL Headers for Android NDK Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md Clones the OpenCL-Headers repository and copies the necessary CL headers into the Android NDK sysroot. Replace with your NDK installation directory. ```bash # In a temporary working directory git clone https://github.com/KhronosGroup/OpenCL-Headers cd OpenCL-Headers # Replace with your actual NDK installation path # e.g., cp -r CL /path/to/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include sudo cp -r CL /toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include cd .. ``` -------------------------------- ### GET /sdcpp/v1/capabilities Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves the capabilities of the sdcpp API. ```APIDOC ## GET /sdcpp/v1/capabilities ### Description Retrieves the capabilities of the sdcpp API. ### Method GET ### Endpoint /sdcpp/v1/capabilities ### Response #### Success Response (200) - **capabilities** (object) - An object detailing the supported features and parameters. #### Response Example ```json { "capabilities": { "img_gen": true, "vid_gen": false, "max_img_width": 1024, "max_img_height": 1024 } } ``` ``` -------------------------------- ### GET /sdapi/v1/schedulers Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available schedulers. ```APIDOC ## GET /sdapi/v1/schedulers ### Description Retrieves a list of available schedulers. ### Method GET ### Endpoint /sdapi/v1/schedulers ### Response #### Success Response (200) - **schedulers** (array) - An array of scheduler strings. #### Response Example ```json { "schedulers": [ "k_euler_a", "k_euler" ] } ``` ``` -------------------------------- ### GET /sdapi/v1/samplers Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available samplers. ```APIDOC ## GET /sdapi/v1/samplers ### Description Retrieves a list of available samplers. ### Method GET ### Endpoint /sdapi/v1/samplers ### Response #### Success Response (200) - **samplers** (array) - An array of sampler objects. - **name** (string) - The name of the sampler. #### Response Example ```json { "samplers": [ "Euler a", "Euler" ] } ``` ``` -------------------------------- ### Build with Metal (Apple GPU) Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md Builds the project with Metal support for Apple GPU acceleration. Note that Metal performance may be inefficient for large matrices currently. ```shell mkdir build && cd build cmake .. -DSD_METAL=ON cmake --build . --config Release ``` -------------------------------- ### GET /sdapi/v1/upscalers Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available upscalers. ```APIDOC ## GET /sdapi/v1/upscalers ### Description Retrieves a list of available upscalers. ### Method GET ### Endpoint /sdapi/v1/upscalers ### Response #### Success Response (200) - **upscalers** (array) - An array of upscaler objects. - **name** (string) - The name of the upscaler. #### Response Example ```json { "upscalers": [ "ESRGAN_4x", "R-ESRGAN 4x+ " ] } ``` ``` -------------------------------- ### GET /sdapi/v1/loras Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available LoRAs. ```APIDOC ## GET /sdapi/v1/loras ### Description Retrieves a list of available LoRAs. ### Method GET ### Endpoint /sdapi/v1/loras ### Response #### Success Response (200) - **loras** (array) - An array of LoRA objects. - **name** (string) - The name of the LoRA. - **path** (string) - The file path of the LoRA. #### Response Example ```json { "loras": [ { "name": "my-lora", "path": "/path/to/my-lora.safetensors" } ] } ``` ``` -------------------------------- ### Select NVIDIA Vulkan Backend Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/pulid.md Use this flag to specify the NVIDIA Vulkan backend for diffusion and CPU for VAE. ```bash --backend "diffusion=vulkan1,vae=cpu" ``` -------------------------------- ### GET /sdapi/v1/sd-models Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available Stable Diffusion models. ```APIDOC ## GET /sdapi/v1/sd-models ### Description Retrieves a list of available Stable Diffusion models. ### Method GET ### Endpoint /sdapi/v1/sd-models ### Response #### Success Response (200) - **sd_models** (array) - An array of Stable Diffusion model objects. - **name** (string) - The name of the model. - **path** (string) - The file path of the model. #### Response Example ```json { "sd_models": [ { "name": "sd-v1-5", "path": "/path/to/sd-v1-5.safetensors" } ] } ``` ``` -------------------------------- ### PhotoMaker v1 Command Line Example Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/photo_maker.md Use this command to generate images personalized with PhotoMaker v1. Ensure you have the correct model paths and prompt structure. Adjust --pm-style-strength for desired faithfulness to input ID. ```bash bin/sd-cli -m ../models/sdxlUnstableDiffusers_v11.safetensors --vae ../models/sdxl_vae.safetensors --photo-maker ../models/photomaker-v1.safetensors --pm-id-images-dir ../assets/photomaker_examples/scarletthead_woman -p "a girl img, retro futurism, retro game art style but extremely beautiful, intricate details, masterpiece, best quality, space-themed, cosmic, celestial, stars, galaxies, nebulas, planets, science fiction, highly detailed" -n "realistic, photo-realistic, worst quality, greyscale, bad anatomy, bad hands, error, text" --cfg-scale 5.0 --sampling-method euler -H 1024 -W 1024 --pm-style-strength 10 --vae-on-cpu --steps 50 ``` -------------------------------- ### GET /sdapi/v1/latent-upscale-modes Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available latent upscaler modes. ```APIDOC ## GET /sdapi/v1/latent-upscale-modes ### Description Retrieves a list of available latent upscaler modes. ### Method GET ### Endpoint /sdapi/v1/latent-upscale-modes ### Response #### Success Response (200) - **latent_upscale_modes** (array) - An array of latent upscaler mode strings. #### Response Example ```json { "latent_upscale_modes": [ "Latent", "None" ] } ``` ``` -------------------------------- ### Boogu Image Base Generation Example Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/boogu_image.md Command to generate a base image using Boogu Image Base model, Qwen3-VL LLM, and FLUX VAE. Use this for standard image creation tasks. ```bash .\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\boogu_image_base_bf16.safetensors --llm ..\..\llm\Qwen3VL-8B-Instruct-Q4_K_M.gguf --vae ..\..\ComfyUI\models\vae\ae.sft -p "a lovely cat" --diffusion-fa -v --offload-to-cpu ``` -------------------------------- ### GET /v1/models Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available local models. Currently, only `sd-cpp-local` is supported. ```APIDOC ## GET /v1/models ### Description Retrieves a list of available local models. Currently, only `sd-cpp-local` is supported. ### Method GET ### Endpoint /v1/models ### Parameters None ### Request Example ```json (No request body for GET requests) ``` ### Response #### Success Response (200) - **data** (array) - A list of available local models. - **data[].id** (string) - Currently fixed to `sd-cpp-local`. - **data[].object** (string) - Currently fixed to `model`. - **data[].owned_by** (string) - Currently fixed to `local`. #### Response Example ```json { "data": [ { "id": "sd-cpp-local", "object": "model", "owned_by": "local" } ] } ``` ``` -------------------------------- ### GET /sdcpp/v1/jobs/{id} Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves the status and result of an image generation job by its ID. ```APIDOC ## GET /sdcpp/v1/jobs/{id} ### Description Retrieves the status and result of an image generation job by its ID. ### Method GET ### Endpoint /sdcpp/v1/jobs/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the job. ### Response #### Success Response (200) - **status** (string) - The status of the job (e.g., "pending", "processing", "completed", "failed"). - **result_image** (string) - Optional - The generated image (base64 encoded) if the job is completed. - **error** (string) - Optional - An error message if the job failed. #### Response Example ```json { "status": "completed", "result_image": "base64_encoded_image_string" } ``` ``` -------------------------------- ### GET /v1/models Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves a list of available models, compatible with OpenAI model listing endpoints. ```APIDOC ## GET /v1/models ### Description Retrieves a list of available models, compatible with OpenAI model listing endpoints. ### Method GET ### Endpoint /v1/models ### Response #### Success Response (200) - **data** (array) - An array of model objects. - **id** (string) - The ID of the model. - **object** (string) - The object type (e.g., "model"). #### Response Example ```json { "data": [ { "id": "sd-model-v1", "object": "model" } ] } ``` ``` -------------------------------- ### Cancelled Job Result Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Example of an image generation job that was cancelled, including the cancellation error details. ```json { "id": "job_01HTXYZABC", "kind": "img_gen", "status": "cancelled", "created": 1775401200, "started": null, "completed": 1775401202, "queue_position": 0, "result": null, "error": { "code": "cancelled", "message": "job cancelled by client" } } ``` -------------------------------- ### Failed Job Result Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Example of an image generation job that failed, including the error code and message. ```json { "id": "job_01HTXYZABC", "kind": "img_gen", "status": "failed", "created": 1775401200, "started": 1775401203, "completed": 1775401204, "queue_position": 0, "result": null, "error": { "code": "generation_failed", "message": "generate_image returned empty results" } } ``` -------------------------------- ### Run Kontext Inference Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/kontext.md Example command to run Kontext inference. Specify the output image path, model files, prompt, and inference parameters. The `--cfg-scale` is recommended to be set to 1.0. ```bash .\bin\Release\sd-cli.exe -r .\flux1-dev-q8_0.png --diffusion-model ..\models\flux1-kontext-dev-q8_0.gguf --vae ..\models\ae.sft --clip_l ..\models\clip_l.safetensors --t5xxl ..\models\t5xxl_fp16.safetensors -p "change 'flux.cpp' to 'kontext.cpp'" --cfg-scale 1.0 --sampling-method euler -v --clip-on-cpu ``` -------------------------------- ### Get Job Status Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Retrieves the current status of a previously submitted job using its unique ID. ```APIDOC ## GET /sdcpp/v1/jobs/{id} ### Description Returns the current status of a job. ### Method GET ### Endpoint /sdcpp/v1/jobs/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the job. ### Response #### Success Response (200 OK) - **status** (string) - The current status of the job (e.g., "processing", "completed", "failed"). #### Error Response - **404 Not Found** - Job with the specified ID not found. - **410 Gone** - Job data is no longer available. ``` -------------------------------- ### WAN V2V Generation with 2.1 VACE 1.3B Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/wan.md Use this command for video-to-video generation with the WAN 2.1 VACE 1.3B model. Ensure the 'post+depth' directory is populated with frames from the input video. ```bash mkdir post+depth ffmpeg -i ..\..\ComfyUI\input\post+depth.mp4 -qscale:v 1 -vf fps=8 post+depth\frame_%04d.jpg .\bin\Release\sd-cli.exe -M vid_gen --diffusion-model ..\..\ComfyUI\models\diffusion_models\wan2.1-vace-1.3b-q8_0.gguf --vae ..\..\ComfyUI\models\vae\wan_2.1_vae.safetensors --t5xxl ..\..\ComfyUI\models\text_encoders\umt5-xxl-encoder-Q8_0.gguf -p "The girl is dancing in a sea of flowers, slowly moving her hands. There is a close - up shot of her upper body. The character is surrounded by other transparent glass flowers in the style of Nicoletta Ceccoli, creating a beautiful, surreal, and emotionally expressive movie scene with a white. transparent feel and a dreamyl atmosphere." --cfg-scale 6.0 --sampling-method euler -v -n "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部, 畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走" -W 480 -H 832 --diffusion-fa -i ..\..\ComfyUI\input\dance_girl.jpg --control-video ./post+depth --video-frames 33 --offload-to-cpu ``` -------------------------------- ### Job Model Example Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/examples/server/api.md Illustrates the common shape of a job object returned by the API. Jobs are used for asynchronous generation requests. ```json { "id": "job_01HTXYZABC", "kind": "img_gen", "status": "queued", "created": 1775401200, "started": null, "completed": null, "queue_position": 2, "result": null, "error": null } ``` -------------------------------- ### Select CUDA Backend Source: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/pulid.md Use this flag to specify the CUDA backend for diffusion and CPU for VAE. ```bash --backend "diffusion=cuda0,vae=cpu" ```