update

Signed-off-by: Vladimir Mandic <mandic00@live.com>
Vladimir Mandic
2025-08-02 15:25:41 -04:00
parent 79b18f2c5e
commit a6e3a70d17
+47
@@ -54,3 +54,50 @@ And once you have the filename, you can download it using `/file={filename}` end
> If you want to allow access to other folders, use `--allowed-paths` command line flag
![Image](https://github.com/user-attachments/assets/6be67eb3-df90-4da0-9c51-58b40a3086c5)
## Progress Reporting
While you have a task running, you can query the `/sdapi/v1/progress` endpoint using a `GET` request to see what the server is doing (since endpoints like `txt2img` block the call until the generation is completed). Optionally you can specify the paramerer `skip_current_image=true`: if not set, the server will send the preview image for the step of the generation it is at.
You will get back a JSON dictionary with these keys:
- `progress`: a number ranging from 0 (idle / generation not started) to 1 (generation completed)
- `eta_relative`: an indication of time remaining relative to the current step of the generation
- `images`: A list of base64-encoded images, one or more depending how many you generate in a single batch (if `skip_current_image` is `true`, this list is empty)
- `state`: A JSON dictionary with the following keys.
- `job_count`: The number of jobs running, if 0, the server is idle; if > 1, the server is running one or more job
- `sampling_step`: The current sampling step of the current job
- `sampling_steps`: The number of sampling steps in the current job
- `skipped`: A boolean value, `true` if the current generation was skipped
- `interrupted`: A boolean value, `true` if the current generation was interrupted
- `job`: A string with the current job ID
- `job_no`: The current job number
A typical use of this API would be to poll the progress endpoint while a generation is running, collecting information, and stopping while `progress` is 1. You may want also to check that `job_count` is 0, but you must be aware that it might be 0 right before a task starts.
## Examples
### T2I with ControlNet
The `/sdapi/v1/control` endpoint supports doing the same operations as `txt2img` and `img2img` (with slightly different parameters), but in addition to that it supports specific operations like using ControlNet. ControlNet can be used in many different ways, but a very common usage is to generate an image with txt2img and have the ControlNet units and their specific images (called `override images` in SD.Next parlance) condition the generation.
To do so with the API, you will first need:
- The number of ControlNet units to use (minimum 1)
- For each unit, the naeme of the specific ControlNet model to use (you can obtain a list by querying the `/sdapi/v1/controlnets` endpoint)
- The override image to use for each unit
- For each unit, the name of the specific preprocessor to apply to the image (a list can be obtained by querying the `/sdapi/v1/preprocessors` endpoint), or `None` if no preprocessing is required
Then you need to prepare your payload to be sent via POST to the `/sdapi/v1/control` endpoint. You can refer to the documentation of the `/sdapi/v1/txt2img` endpoint for most of the parameters like sampler, steps, hires, and so on. Here are the ones that are specific of this one:
- `width_before`: The width of the generated image (use instead of `width`)
- `height_before`: The height of the generated image (use instead of `height`)
- `input_type`: The type of input you are supplying, set it to 0, which corresponds to "Control only" (aka txt2img + ControlNet)
- `control`: This is a list of your ControlNet units, each one as follows:
- `process`: The ControlNet preprocessor to use, or `None`
- `model`: The name of the ControlNet model to use
- `strength`: The strength of the conditioning, ranging from 0 to 1
- `start`: A value ranging from 0 (generation start) to 1 (generation end), indicating when conditioning will be applied
- `end`: A value from ranging from 0 (generation start) to 1 (generation end), indicating when conditioning will be stopped
- `override`: A base64-encoded string of the image to be used as override image
After that, submit the entire request as POST to the server, and generation will start.