LykosAI/StabilityMatrix · error · InvalidOperationException
Flux Kontext UNET model not found
Error message
Flux Kontext UNET model not found
What it means
FluxKontextModelManager.SelectModels searches clientManager.UnetModels for a locally installed Flux Kontext checkpoint (filename containing 'flux1-dev-kontext' or 'flux-kontext'). If none is present with a Local file, it throws this InvalidOperationException because the Kontext workflow cannot be assembled.
Solutions
- Download a Flux Kontext UNET (e.g. flux1-dev-kontext_dev.safetensors) into the diffusion_models folder and refresh the index
- Rename/move the existing file so its name contains 'flux-kontext' in a scanned folder
- Catch InvalidOperationException and prompt the user with a one-click download of the Kontext UNET
Example fix
// before
var models = fluxKontextModelManager.SelectModels();
// after
if (!clientManager.UnetModels.Any(m => m.Local != null && m.FileName.Contains("flux-kontext", StringComparison.OrdinalIgnoreCase)))
{
throw new UserDownloadableError("Flux Kontext UNET is not installed. Download it first.");
}
var models = fluxKontextModelManager.SelectModels(); Defensive patterns
Strategy: validation
Validate before calling
var unet = clientManager.UnetModels.FirstOrDefault(m => m.Local != null
&& (m.FileName.Contains("flux1-dev-kontext", StringComparison.OrdinalIgnoreCase)
|| m.FileName.Contains("flux-kontext", StringComparison.OrdinalIgnoreCase)));
if (unet is null) throw new UserDownloadableError("Flux Kontext UNET is not installed."); Type guard
bool HasLocalKontextUnet(IEnumerable<HybridModelFile> models) => models.Any(m => m.Local != null && m.FileName.Contains("flux-kontext", StringComparison.OrdinalIgnoreCase)); Try / catch
try
{
var models = fluxKontextModelManager.SelectModels();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Kontext UNET model not found"))
{
// trigger Kontext UNET download flow
} Prevention
- Verify all four Kontext components (UNET, VAE, CLIP-L, T5) before SelectModels
- Avoid renaming downloaded model files
- Refresh the model index after downloads
When it happens
Trigger: Calling SelectModels when no UnetModels entry has Local != null and a filename containing 'flux1-dev-kontext' or 'flux-kontext' (case-insensitive) — the Kontext UNET was never downloaded or isn't indexed.
Common situations: User runs the Kontext workflow before downloading flux1-dev-kontext_dev.safetensors; model in a folder not scanned by ComfyUI; file renamed so the substring match fails.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Flux.2 Klein UNET model not found
- Flux.2 VAE model not found
- Klein 9B requires the qwen_3_8b text encoder, which isn't…
- Klein 4B requires the qwen_3_4b text encoder, which isn't…
- Flux VAE model not found
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/131cc330e2db80da.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/Services/FluxKontextModelManager.cs:173
_ => model.FileName,
};
yield return name;
}
}
/// <summary>
/// Select the best available models for Flux Kontext (only selects LOCAL models)
/// </summary>
internal FluxKontextWorkflowBuilder.SelectedModels SelectModels(IInferenceClientManager clientManager)
{
var unetModel =
clientManager.UnetModels.FirstOrDefault(m =>
m.Local != null
&& (
m.FileName.Contains("flux1-dev-kontext", StringComparison.OrdinalIgnoreCase)
|| m.FileName.Contains("flux-kontext", StringComparison.OrdinalIgnoreCase)
)
) ?? throw new InvalidOperationException("Flux Kontext UNET model not found");
var vaeModel =
clientManager.VaeModels.FirstOrDefault(m =>
m.Local != null && m.FileName.Equals("ae.safetensors", StringComparison.OrdinalIgnoreCase)
) ?? throw new InvalidOperationException("Flux VAE model not found");
var clip1Model =
clientManager.ClipModels.FirstOrDefault(m =>
m.Local != null && m.FileName.Contains("clip_l", StringComparison.OrdinalIgnoreCase)
) ?? throw new InvalidOperationException("CLIP-L model not found");
var clip2Model =
clientManager.ClipModels.FirstOrDefault(m =>
m.Local != null
&& (
m.FileName.Contains("t5xxl", StringComparison.OrdinalIgnoreCase)
|| m.FileName.Contains("t5-xxl", StringComparison.OrdinalIgnoreCase)
)View on GitHub (pinned to af93d6ef57)