invoke-ai/InvokeAI · error · ValueError
Model '{model_key}' is not a TextLLM model (got {model_confi
Error message
Model '{model_key}' is not a TextLLM model (got {model_config.type}) What it means
ValueError raised by _run_expand_prompt when the model identified by model_key exists in the model store but its configured type is not ModelType.TextLLM. It is surfaced by expand_prompt as HTTP 422 with the same message. This is a caller-supplied model_key mismatch against the type-strict inference path.
Source
Thrown at invokeai/app/api/routers/utilities.py:152
return progress_callback
def _run_expand_prompt(
prompt: str,
model_key: str,
max_tokens: int,
system_prompt: str | None,
seed: int | None,
task_id: str | None,
user_id: str,
) -> tuple[str, int]:
"""Run text LLM inference synchronously (called from thread)."""
model_manager = ApiDependencies.invoker.services.model_manager
events = ApiDependencies.invoker.services.events
model_config = model_manager.store.get_model(model_key)
if model_config.type != ModelType.TextLLM:
raise ValueError(f"Model '{model_key}' is not a TextLLM model (got {model_config.type})")
if task_id is not None:
events.emit_llm_task_progress(task_id=task_id, user_id=user_id, phase="loading_model", message="Loading model")
with _model_load_lock:
loaded_model = model_manager.load.load_model(model_config, user_id=user_id)
with torch.no_grad(), loaded_model.model_on_device() as (_, model):
model_abs_path = _resolve_model_path(model_config.path)
tokenizer = AutoTokenizer.from_pretrained(model_abs_path, local_files_only=True)
pipeline = TextLLMPipeline(model, tokenizer)
model_device = next(model.parameters()).device
progress_callback = _make_progress_callback(events, task_id, user_id)
effective_seed = seed if seed is not None else get_random_seed()
output = pipeline.run(View on GitHub (pinned to 0b6a024f2f)
Solutions
- Pass a model_key whose model type is TextLLM (check via the model manager store or /api/v1/models listing)
- Fix the default model_key in configuration used by the prompt-expansion feature
- Install/convert a TextLLM model if none is present
- Upgrade InvokeAI if your model's type string isn't recognized as TextLLM
Example fix
// before expand_prompt(model_key="main:stablediffusion-xl") // after expand_prompt(model_key="text_llm:my-llm-model")
Defensive patterns
Strategy: type-guard
Validate before calling
const models = await api.listModels();
const cfg = models.find(m => m.key === modelKey);
if (!cfg || cfg.type !== 'text_llm') {
throw new Error(`model_key must reference a TextLLM model (got ${cfg ? cfg.type : 'unknown'})`);
} Type guard
function isTextLlmModel(config) {
return config != null && config.type === 'text_llm' && typeof config.key === 'string';
} Try / catch
try {
await api.expandPrompt({ modelKey, prompt });
} catch (e) {
if (e.status === 422 && /not a TextLLM model/.test(e.detail)) {
console.error('Wrong model type; pick a TextLLM model');
} else throw e;
} Prevention
- Filter model dropdowns to type text_llm for prompt expansion
- Store the model key from an API listing, never hand-written
- Validate model type at startup if the key comes from config/env
When it happens
Trigger: POST expand_prompt (or the test path test_expand_prompt_uses_fresh_seed) with a model_key whose model_config.type is e.g. Main, LlavaOnevision, or Embedding instead of TextLLM.
Common situations: Selecting a diffusion/LLaVA model in a UI dropdown that doesn't filter by TextLLM; config/env pointing prompt expansion at the wrong model key; older installers/models predating the TextLLM type.
Related errors
- Model '{model_key}' is not a LLaVA OneVision model (got {mod
- Model '{main_config.name}' is not a Krea-2 main model. Selec
- Encoder '{encoder_config.name}' is not a Qwen3-VL encoder co
- Qwen-Image PiD decode expected a single temporal frame, got
- Qwen-Image PiD decode expected a 16-channel latent, got shap
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/93769b91ca3b8c86.
Report an issue: GitHub.