AUTOMATIC1111/stable-diffusion-webui · error · ValueError

Unknown prompt type {prompt_type}

Error message

Unknown prompt type {prompt_type}

What it means

The built-in Prompt Matrix script validates its gradio inputs at run() time: prompt_type must be exactly 'positive' or 'negative' (matching the Radio choices defined in ui()). API callers or saved payloads that send anything else are rejected with this ValueError before prompt construction.

Source

Thrown at scripts/prompt_matrix.py:62

    def ui(self, is_img2img):
        gr.HTML('<br />')
        with gr.Row():
            with gr.Column():
                put_at_start = gr.Checkbox(label='Put variable parts at start of prompt', value=False, elem_id=self.elem_id("put_at_start"))
                different_seeds = gr.Checkbox(label='Use different seed for each picture', value=False, elem_id=self.elem_id("different_seeds"))
            with gr.Column():
                prompt_type = gr.Radio(["positive", "negative"], label="Select prompt", elem_id=self.elem_id("prompt_type"), value="positive")
                variations_delimiter = gr.Radio(["comma", "space"], label="Select joining char", elem_id=self.elem_id("variations_delimiter"), value="comma")
            with gr.Column():
                margin_size = gr.Slider(label="Grid margins (px)", minimum=0, maximum=500, value=0, step=2, elem_id=self.elem_id("margin_size"))

        return [put_at_start, different_seeds, prompt_type, variations_delimiter, margin_size]

    def run(self, p, put_at_start, different_seeds, prompt_type, variations_delimiter, margin_size):
        modules.processing.fix_seed(p)
        # Raise error if promp type is not positive or negative
        if prompt_type not in ["positive", "negative"]:
            raise ValueError(f"Unknown prompt type {prompt_type}")
        # Raise error if variations delimiter is not comma or space
        if variations_delimiter not in ["comma", "space"]:
            raise ValueError(f"Unknown variations delimiter {variations_delimiter}")

        prompt = p.prompt if prompt_type == "positive" else p.negative_prompt
        original_prompt = prompt[0] if type(prompt) == list else prompt
        positive_prompt = p.prompt[0] if type(p.prompt) == list else p.prompt

        delimiter = ", " if variations_delimiter == "comma" else " "

        all_prompts = []
        prompt_matrix_parts = original_prompt.split("|")
        combination_count = 2 ** (len(prompt_matrix_parts) - 1)
        for combination_num in range(combination_count):
            selected_prompts = [text.strip().strip(',') for n, text in enumerate(prompt_matrix_parts[1:]) if combination_num & (1 << n)]

            if put_at_start:
                selected_prompts = selected_prompts + [prompt_matrix_parts[0]]

View on GitHub (pinned to 82a973c043)

Solutions

  1. Set prompt_type to exactly 'positive' or 'negative'
  2. Re-check the argument order of the prompt_matrix script args: [put_at_start, different_seeds, prompt_type, variations_delimiter, margin_size]
  3. When building API payloads programmatically, validate the value against the allowed list before sending

Example fix

# before
args = [False, False, 'pos', 'comma', 0]
# after
args = [False, False, 'positive', 'comma', 0]
Defensive patterns

Strategy: type-guard

Validate before calling

ALLOWED_PROMPT_TYPES = {'positive', 'negative'}
def args_valid(args) -> bool:
    return len(args) == 5 and args[2] in ALLOWED_PROMPT_TYPES

Type guard

def is_prompt_type(v) -> bool:
    return v in ('positive', 'negative')

Prevention

When it happens

Trigger: Calling /sdapi/v1/txt2img with alwayson_scripts.prompt_matrix.args = [put_at_start, different_seeds, prompt_type, delimiter, margin] where prompt_type is e.g. 'Positive', None, or a language-changed value; gradio normally constrains the UI, so this is almost always an API/script caller.

Common situations: Programmatic API clients passing positional script args in the wrong order (prompt_type receiving the delimiter value); localized or hand-built payloads; typo'd enum strings.

Related errors


AI-assisted analysis of AUTOMATIC1111/stable-diffusion-webui@82a973c043 (2026-08-14). Data as JSON: /api/errors/90d245079976fa74. Report an issue: GitHub.