sigoden/aichat · error
No available embedding model
Error message
No available embedding model
What it means
`Rag::create_config` needs an embedding model; when none was selected/known it lists configured embedding models, and if that list is empty there is no valid choice, so it bails with 'No available embedding model'.
Solutions
- Add an embedding model to the config (e.g. an OpenAI/other provider embedding entry) and verify its API key
- Select an embedding model interactively so the None branch isn't hit
- Confirm the model is registered with ModelType::Embedding, not Chat
- Run `list_models`/model listing command to verify discovery works
Example fix
// before: only a chat model configured
models = [{ name = "gpt-4o", type = "chat" }]
// after
models = [
{ name = "gpt-4o", type = "chat" },
{ name = "text-embedding-3-small", type = "embedding", max_chunk_size = 1000 }
] Defensive patterns
Strategy: validation
Validate before calling
let models = list_models(&config.read(), ModelType::Embedding);
if models.is_empty() {
eprintln!("configure an embedding model before creating a RAG");
} Try / catch
match Rag::create_config(&config).await {
Err(e) if e.to_string() == "No available embedding model" => {
eprintln!("Add an embedding model (and API key) to your config");
}
other => other?,
} Prevention
- Define at least one embedding-type model in config with a valid API key
- Run a model-listing command to verify discovery before RAG init
- Ensure provider credentials are set so embedding models are enumerated
When it happens
Trigger: `create_config` reaches the `None` branch of the interactive selection (no pre-selected embedding model) and `list_models(config, ModelType::Embedding)` returns empty.
Common situations: Config has no embedding-capable models defined (e.g. only chat models configured); provider credentials missing so model discovery returns nothing; typo in model type in the config.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09).
Data as JSON: /api/errors/5c7e0a7a95b07196.
Report an issue: GitHub.
Appendix: source
Thrown at src/rag/mod.rs:169
pub fn create_config(config: &GlobalConfig) -> Result<(Model, usize, usize)> {
let (embedding_model_id, chunk_size, chunk_overlap) = {
let config = config.read();
(
config.rag_embedding_model.clone(),
config.rag_chunk_size,
config.rag_chunk_overlap,
)
};
let embedding_model_id = match embedding_model_id {
Some(value) => {
println!("Select embedding model: {value}");
value
}
None => {
let models = list_models(&config.read(), ModelType::Embedding);
if models.is_empty() {
bail!("No available embedding model");
}
select_embedding_model(&models)?
}
};
let embedding_model =
Model::retrieve_model(&config.read(), &embedding_model_id, ModelType::Embedding)?;
let chunk_size = match chunk_size {
Some(value) => {
println!("Set chunk size: {value}");
value
}
None => set_chunk_size(&embedding_model)?,
};
let chunk_overlap = match chunk_overlap {
Some(value) => {
println!("Set chunk overlay: {value}");
valueView on GitHub (pinned to 82976d349a)