{"record":{"id":"6b991192ce658af0","repo":"invoke-ai/InvokeAI","slug":"model-model-key-is-not-a-llava-onevision-model","errorCode":null,"errorMessage":"Model '{model_key}' is not a LLaVA OneVision model (got {model_config.type})","messagePattern":"Model '(.+?)' is not a LLaVA OneVision model \\(got (.+?)\\)","errorType":"http","errorClass":"ValueError","httpStatus":422,"severity":"error","filePath":"invokeai/app/api/routers/utilities.py","lineNumber":252,"sourceCode":"class ImageToPromptResponse(BaseModel):\n    prompt: str\n    error: str | None = None\n\n\ndef _run_image_to_prompt(\n    image_name: str,\n    model_key: str,\n    instruction: str,\n    task_id: str | None,\n    user_id: str,\n) -> str:\n    \"\"\"Run LLaVA OneVision inference synchronously (called from thread).\"\"\"\n    model_manager = ApiDependencies.invoker.services.model_manager\n    events = ApiDependencies.invoker.services.events\n    model_config = model_manager.store.get_model(model_key)\n\n    if model_config.type != ModelType.LlavaOnevision:\n        raise ValueError(f\"Model '{model_key}' is not a LLaVA OneVision model (got {model_config.type})\")\n\n    if task_id is not None:\n        events.emit_llm_task_progress(task_id=task_id, user_id=user_id, phase=\"loading_model\", message=\"Loading model\")\n\n    with _model_load_lock:\n        loaded_model = model_manager.load.load_model(model_config, user_id=user_id)\n\n    # Load the image from InvokeAI's image store\n    image = ApiDependencies.invoker.services.images.get_pil_image(image_name)\n    image = image.convert(\"RGB\")\n\n    with torch.no_grad(), loaded_model.model_on_device() as (_, model):\n        if not isinstance(model, LlavaOnevisionForConditionalGeneration):\n            raise TypeError(f\"Expected LlavaOnevisionForConditionalGeneration, got {type(model).__name__}\")\n\n        model_abs_path = _resolve_model_path(model_config.path)\n        processor = AutoProcessor.from_pretrained(model_abs_path, local_files_only=True)\n        if not isinstance(processor, LlavaOnevisionProcessor):","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/utilities.py#L234-L270","documentation":"ValueError raised by _run_image_to_prompt when the model for model_key exists but its type is not ModelType.LlavaOnevision — the image-to-prompt (captioning) path only accepts LLaVA OneVision models. Surfaced as HTTP 422 by the endpoint's ValueError handler.","triggerScenarios":"POST image-to-prompt with a model_key resolving to a Main, TextLLM, or other non-LlavaOnevision model config.","commonSituations":"Pointing the captioning feature at a text LLM thinking any LLM works; UI not filtering to LlavaOnevision models; installed model family differs (e.g. Llava 1.5 older variant) so the type string doesn't match.","solutions":["Select a model_key whose type is LlavaOnevision (check the models listing)","Install a LLaVA OneVision model if none is available","Fix the configured default model_key for the image-to-prompt feature","Upgrade InvokeAI if your LLaVA variant is not classified as LlavaOnevision"],"exampleFix":"// before\nimage_to_prompt(model_key=\"text_llm:my-llm-model\")\n// after\nimage_to_prompt(model_key=\"llava_onevision:llava-onevision-qwen2-7b\")","handlingStrategy":"type-guard","validationCode":"const models = await api.listModels();\nconst cfg = models.find(m => m.key === modelKey);\nif (!cfg || cfg.type !== 'llava_onevision') {\n  throw new Error(`image-to-prompt requires a LlavaOnevision model (got ${cfg ? cfg.type : 'unknown'})`);\n}","typeGuard":"function isLlavaOnevisionModel(config) {\n  return config != null && config.type === 'llava_onevision' && typeof config.key === 'string';\n}","tryCatchPattern":"try {\n  await api.imageToPrompt({ modelKey, image });\n} catch (e) {\n  if (e.status === 422 && /not a LLaVA OneVision model/.test(e.detail)) {\n    console.error('Pick a LlavaOnevision model for captioning');\n  } else throw e;\n}","preventionTips":["Filter captioning UI to models with type llava_onevision","Validate configured default captioning model type at startup","Install a LLaVA OneVision model before enabling the image-to-prompt feature"],"tags":["valueerror","model-type","llava-onevision","invokeai"],"backgroundTag":"model-type-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}