{"record":{"id":"85f20e53bd0d634d","repo":"sigoden/aichat","slug":"unknown-model-type-model-model-id","errorCode":null,"errorMessage":"Unknown {model_type} model '{model_id}'","messagePattern":"Unknown (.+?) model '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/client/model.rs","lineNumber":88,"sourceCode":"                    .into_iter()\n                    .any(|v| *v == client_name)\n                    && model_type.can_create_from_name()\n                {\n                    let mut new_model = Self::new(client_name, model_name);\n                    new_model.data.model_type = model_type.to_string();\n                    return Ok(new_model);\n                }\n            }\n            None => {\n                if let Some(found) = models\n                    .iter()\n                    .find(|v| v.client_name == client_name && v.model_type() == model_type)\n                {\n                    return Ok((*found).clone());\n                }\n            }\n        };\n        bail!(\"Unknown {model_type} model '{model_id}'\")\n    }\n\n    pub fn id(&self) -> String {\n        if self.data.name.is_empty() {\n            self.client_name.to_string()\n        } else {\n            format!(\"{}:{}\", self.client_name, self.data.name)\n        }\n    }\n\n    pub fn client_name(&self) -> &str {\n        &self.client_name\n    }\n\n    pub fn name(&self) -> &str {\n        &self.data.name\n    }\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/client/model.rs#L70-L106","documentation":"`retrieve_model` (src/client/model.rs:88) bails when no configured model matches the given model_id and model_type for any known client — including fallbacks by client name and by model-type match. The requested model simply is not configured in this library instance.","triggerScenarios":"Calling retrieve_model(config, Some(\"model-x\"), ModelType::Chat, ...) where model-x is absent from all clients' configured models and no client_name/model_type fallback matched.","commonSituations":"Model never added during client configuration; typo in model id; config file edited by hand and model entry removed; using a model from a different machine's config; provider catalog changed after upgrade.","solutions":["Add the model to the client configuration (re-run create_config or edit config to include the model entry).","Verify the exact model id with the provider's /v1/models and fix typos.","Use the fully qualified client:model form if supported.","If no model_id is needed, pass None so the default model is used instead."],"exampleFix":"// before\nlet m = retrieve_model(config, Some(\"llama3.1\"), ModelType::Chat)?; // not configured\n// after: add llama3.1 to client models in config, or use a configured model\nlet m = retrieve_model(config, Some(\"llama3.3\"), ModelType::Chat)?;","handlingStrategy":"validation","validationCode":"// confirm the model exists before retrieve_model\nlet exists = config.clients.iter().any(|c| c.models.iter().any(|m| m.name == model_id));\nif !exists { anyhow::bail!(\"model '{}' not configured; add it to config\", model_id); }","typeGuard":"fn model_exists(model_id: &str, config: &Config) -> bool {\n    config.clients.iter().any(|c| c.models.iter().any(|m| m.name == model_id))\n}","tryCatchPattern":"match retrieve_model(config, Some(id), ModelType::Chat, ...) {\n    Err(e) if e.to_string().starts_with(\"Unknown\") => add_model_to_config(id).await?,\n    other => other,\n}","preventionTips":["Add required models during client setup (set_client_models_config).","Pass None to use the default model when a specific id isn't required.","Copy exact ids from /v1/models; watch for typos.","Re-check config after hand edits or machine migrations."],"tags":["model-not-found","config","rust"],"backgroundTag":"resource-not-found","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}