diff --git a/core/http/endpoints/openai/image.go b/core/http/endpoints/openai/image.go index 4009e923e..9d64e8e72 100644 --- a/core/http/endpoints/openai/image.go +++ b/core/http/endpoints/openai/image.go @@ -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 diff --git a/core/schema/openai.go b/core/schema/openai.go index 95deb9dd3..e6394a602 100644 --- a/core/schema/openai.go +++ b/core/schema/openai.go @@ -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"` diff --git a/docs/content/features/image-generation.md b/docs/content/features/image-generation.md index e690486b6..065e3ce4c 100644 --- a/docs/content/features/image-generation.md +++ b/docs/content/features/image-generation.md @@ -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 '{