Skip to content

Conversation

@JackBinary
Copy link

Problem

The sd-server ignores <lora:name:weight> tags in prompts sent via the /sdapi/v1/txt2img and /sdapi/v1/img2img API endpoints.

LoRA tags work correctly in the CLI (sd-cli) because it calls extract_and_remove_lora() on every generation. However, the server only calls this function once at startup when parsing command-line arguments. When handling API requests, the server copies default_gen_params, updates the prompt, but never re-parses the new prompt for LoRA tags.

Solution

This patch adds extract_and_remove_lora() to the sdapi_any2img handler function, which services both txt2img and img2img endpoints. The fix clears any pre-existing LoRA data and extracts LoRA tags from the incoming prompt, matching the behavior of the CLI.

Added functionality to extract and process LoRA tags from the prompt.
@wbruna
Copy link
Contributor

wbruna commented Jan 28, 2026

This is unsafe to enable as-is, since it'd allow loading arbitrary server files (see #1156 and #830 ).

@leejet
Copy link
Owner

leejet commented Feb 1, 2026

Thank you for your contribution. However, personally, I’m not inclined toward this approach. I’m planning to extend the SD API to provide an interface for retrieving supported LoRAs, and then allow specifying LoRAs via additional fields in txt2img / img2img.

@JackBinary
Copy link
Author

Understood, I'll continue maintaining my fork for local sd-server use then and await official implementation.

@JackBinary JackBinary closed this Feb 1, 2026
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