Skip to content

Fix: handle steps in /v1/images/generations endpoint#1550

Closed
aurorianus wants to merge 2 commits into
leejet:masterfrom
aurorianus:fix/server-steps-param
Closed

Fix: handle steps in /v1/images/generations endpoint#1550
aurorianus wants to merge 2 commits into
leejet:masterfrom
aurorianus:fix/server-steps-param

Conversation

@aurorianus

@aurorianus aurorianus commented May 22, 2026

Copy link
Copy Markdown

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

James and others added 2 commits May 22, 2026 17:20
…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.
@aurorianus aurorianus changed the title Handle steps in /v1/images/generations endpoint Fix: handle steps in /v1/images/generations endpoint May 22, 2026

@wbruna wbruna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/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.

@leejet

leejet commented May 22, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR.

I don’t think we should support steps as a top-level field in /v1/images/generations.

This endpoint is intended to stay compatible with the OpenAI-style image API. steps is not an official OpenAI Images API request field, so accepting it at the top level would expand the compatibility API with non-OpenAI parameters.

For stable-diffusion.cpp-specific controls, please use the existing extension mechanism: sd_cpp_extra_args. For example:

{
  "prompt": "test <sd_cpp_extra_args>{\"sample_params\":{\"sample_steps\":5}}</sd_cpp_extra_args>",
  "n": 1
}

See the documented extension mechanism here:
examples/server/api.md#sd_cpp_extra_args

So I’m going to close this PR as not planned. Thanks again for taking the time to investigate and submit the fix.

@leejet leejet closed this May 22, 2026
@aurorianus

Copy link
Copy Markdown
Author

ah hah! Got it. Ty for the explanation guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants