sigoden/aichat · error
Unknown model
Error message
Unknown {model_type} model '{model_id}' What it means
`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.
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.
Example fix
// before
let m = retrieve_model(config, Some("llama3.1"), ModelType::Chat)?; // not configured
// after: add llama3.1 to client models in config, or use a configured model
let m = retrieve_model(config, Some("llama3.3"), ModelType::Chat)?; Defensive patterns
Strategy: validation
Validate before calling
// confirm the model exists before retrieve_model
let exists = config.clients.iter().any(|c| c.models.iter().any(|m| m.name == model_id));
if !exists { anyhow::bail!("model '{}' not configured; add it to config", model_id); } Type guard
fn model_exists(model_id: &str, config: &Config) -> bool {
config.clients.iter().any(|c| c.models.iter().any(|m| m.name == model_id))
} Try / catch
match retrieve_model(config, Some(id), ModelType::Chat, ...) {
Err(e) if e.to_string().starts_with("Unknown") => add_model_to_config(id).await?,
other => other,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
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
AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09).
Data as JSON: /api/errors/85f20e53bd0d634d.
Report an issue: GitHub.
Appendix: source
Thrown at src/client/model.rs:88
.into_iter()
.any(|v| *v == client_name)
&& model_type.can_create_from_name()
{
let mut new_model = Self::new(client_name, model_name);
new_model.data.model_type = model_type.to_string();
return Ok(new_model);
}
}
None => {
if let Some(found) = models
.iter()
.find(|v| v.client_name == client_name && v.model_type() == model_type)
{
return Ok((*found).clone());
}
}
};
bail!("Unknown {model_type} model '{model_id}'")
}
pub fn id(&self) -> String {
if self.data.name.is_empty() {
self.client_name.to_string()
} else {
format!("{}:{}", self.client_name, self.data.name)
}
}
pub fn client_name(&self) -> &str {
&self.client_name
}
pub fn name(&self) -> &str {
&self.data.name
}
View on GitHub (pinned to 82976d349a)