Fix: handle steps in /v1/images/generations endpoint#1550
Conversation
…he request body. The parameter was parsed from the JSON but never applied to sample_params.sample_steps, so all requests fell back to the server default regardless of what the client sent.
wbruna
left a comment
There was a problem hiding this comment.
/v1/images/generations is supposed to implement the OpenAI API, which does not support a steps field:
https://developers.openai.com/api/reference/resources/images/methods/generate
The number of steps should be specified through the sd_cpp_extra_args prompt extension.
|
Thanks for the PR. I don’t think we should support This endpoint is intended to stay compatible with the OpenAI-style image API. For stable-diffusion.cpp-specific controls, please use the existing extension mechanism: {
"prompt": "test <sd_cpp_extra_args>{\"sample_params\":{\"sample_steps\":5}}</sd_cpp_extra_args>",
"n": 1
}See the documented extension mechanism here: So I’m going to close this PR as not planned. Thanks again for taking the time to investigate and submit the fix. |
|
ah hah! Got it. Ty for the explanation guys |
Summary
The /v1/images/generations endpoint was ignoring the steps field in the request body. The parameter was parsed from the JSON but never applied to sample_params.sample_steps, so all requests fell back to the server default regardless of what the client sent.
Since the field is already parsed, this is a one-line fix — the client's value just wasn't being used. Resolves the steps issue reported in #1159.
Related Issue / Discussion
#1159
#1050
Additional Information
Before: always uses server default regardless of steps value
curl -X POST http://localhost:8080/v1/images/generations
-H "Content-Type: application/json"
-d '{"prompt":"test","steps":5,"n":1}'
Would produce the same output as steps=20
After: respects the steps value
curl -X POST http://localhost:8080/v1/images/generations
-H "Content-Type: application/json"
-d '{"prompt":"test","steps":5,"n":1}'
Obeys steps instruction, 5 inference steps
Checklist