feat(openai): add negative_prompt field to image generation request (#12031)

Expose a negative_prompt string parameter on the image endpoints,
matching Stable Diffusion WebUI / vLLM-Omni conventions. When both the
negative_prompt parameter and a '|'-suffixed negative prompt in the
main prompt are present, they are joined with a comma so callers can
keep a global negative prompt in negative_prompt and add per-image
negative tags after '|'.


Assisted-by: Pi: DeepSeek V4 Pro

Signed-off-by: Fedor Zuev <Fedor.Zuev@gmail.com>
This commit is contained in:
lqp authored and GitHub committed 2026-09-18 23:28:14 +02:00
1 parent d1ceeaa99a
commit dbee3db07f
3 files changed
+11 -4

No files matched your search

+5 -2
View File
@@ -160,9 +160,12 @@ func ImageEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, appConfi
for range n {
prompts := strings.Split(i, "|")
positive_prompt := prompts[0]
negative_prompt := ""
negative_prompt := strings.TrimSpace(input.NegativePrompt)
if len(prompts) > 1 {
negative_prompt = prompts[1]
if negative_prompt != "" {
negative_prompt += ", "
}
negative_prompt += strings.TrimSpace(prompts[1])
}
step := config.Step
+4
View File
@@ -210,6 +210,10 @@ type OpenAIRequest struct {
Size string `json:"size,omitempty"`
// Prompt is read only by completion/image API calls
Prompt any `json:"prompt,omitempty" yaml:"prompt"`
// NegativePrompt for image generation (matches Stable Diffusion WebUI /
// vLLM-Omni conventions). Combined, comma-separated, with any "|"-suffixed
// negative tags in Prompt.
NegativePrompt string `json:"negative_prompt,omitempty" yaml:"negative_prompt"`
// Edit endpoint
Instruction string `json:"instruction,omitempty" yaml:"instruction"`
+2 -2
View File
@@ -24,9 +24,9 @@ curl http://localhost:8080/v1/images/generations -H "Content-Type: application/j
}'
```
Available additional parameters: `mode`, `step`.
Available additional parameters: `mode`, `step`, `negative_prompt`.
Note: To set a negative prompt, you can split the prompt with `|`, for instance: `a cute baby sea otter|malformed`.
To set a negative prompt you can either pass a separate `negative_prompt` field or split the prompt with `|`, e.g. `a cute baby sea otter|malformed`. When both are present they are joined with a comma (`negative_prompt` first, then the `|`-suffixed tags), so a global negative prompt can live in `negative_prompt` while per-image negatives are appended after `|`.
```bash
curl http://localhost:8080/v1/images/generations -H "Content-Type: application/json" -d '{