pub struct LlmSection {
pub backend: Option<String>,
pub model: Option<String>,
pub base_url: Option<String>,
pub api_key_env: Option<String>,
pub api_key_file: Option<String>,
pub api_key: Option<String>,
pub auto_tag: Option<LlmAutoTagSection>,
}Expand description
v0.7.x (#1146) — [llm] sectioned LLM configuration.
Wire format:
[llm]
backend = "xai" # ollama | openai | xai | anthropic | gemini | …
model = "grok-4.3" # vendor-specific identifier
base_url = "https://api.x.ai/v1" # optional; vendor-default if unset
api_key_env = "XAI_API_KEY" # env var name (mutually exclusive
# with api_key_file)
# api_key_file = "/etc/ai-memory/keys/xai.key" # mode 0400 enforced
[llm.auto_tag]
# Fast structured-output sibling (auto_tag, query expansion,
# contradiction detection). Fields fall back to parent [llm]
# field-by-field when unset; commonly only `model` is overridden.
model = "gemma3:4b"Secret handling discipline. Inline api_key = "<literal>" is
REJECTED at parse time — operators MUST use either
api_key_env = "<ENV_VAR_NAME>" (resolved at runtime) or
api_key_file = "/path/to/key" (mode 0400 enforced, override via
AI_MEMORY_PASSPHRASE_FILE_ALLOW_LAX_PERMS=1). Both unset selects
the per-vendor-alias env-var fallback chain (see src/llm.rs
alias_api_key_env_vars).
Precedence. Resolved via AppConfig::resolve_llm through the
uniform precedence ladder: CLI flag > AI_MEMORY_LLM_* env vars >
[llm] section > legacy flat fields (llm_model, ollama_url) >
compiled default (warn-logged once on the resolver’s CompiledDefault
arm).
Fields§
§backend: Option<String>Backend selector. One of: ollama (native /api/chat +
/api/embed, no auth), openai-compatible (generic; requires
explicit base_url), or an alias that pre-fills base_url
(openai, xai, anthropic, gemini, deepseek, kimi,
qwen, mistral, groq, together, cerebras, openrouter,
fireworks, lmstudio). Unset = inherit legacy resolution
(treated as ollama).
model: Option<String>Model identifier passed verbatim to the chat endpoint.
Vendor-specific (e.g., grok-4.3, gpt-5, claude-opus-4.7).
Unset = backend-specific default (see OllamaClient::from_env).
base_url: Option<String>Optional base-URL override. Required when backend = "openai-compatible"; ignored otherwise (vendor-default
applies). For backend = "ollama", defaults to
http://localhost:11434.
api_key_env: Option<String>Name of the environment variable to read at runtime for the
API-key Bearer auth secret. Mutually exclusive with
api_key_file. Example: api_key_env = "XAI_API_KEY". The
AI_MEMORY_LLM_API_KEY process-env override (and the
per-vendor fallback chain at src/llm.rs
alias_api_key_env_vars) take precedence over this field per
the uniform precedence ladder.
api_key_file: Option<String>Path to a file whose first line is the API-key Bearer secret.
Mutually exclusive with api_key_env. File must be mode 0400
or stricter (overridable via
AI_MEMORY_PASSPHRASE_FILE_ALLOW_LAX_PERMS=1 per #1055). Tilde
expansion applies.
api_key: Option<String>REJECTED AT PARSE TIME. Accepting the field name here lets the validator emit a clear “use api_key_env or api_key_file” error instead of serde’s generic “unknown field”. Operators inlining secrets in the config file see the security-rationale message at load time.
auto_tag: Option<LlmAutoTagSection>[llm.auto_tag] sub-table for the fast structured-output
sibling (auto_tag, query expansion, contradiction detection).
Unset = inherit every field from the parent LlmSection.
When set, only the explicitly-provided fields override; unset
fields fall back to the parent.
Trait Implementations§
Source§impl Clone for LlmSection
impl Clone for LlmSection
Source§fn clone(&self) -> LlmSection
fn clone(&self) -> LlmSection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LlmSection
impl Debug for LlmSection
Source§impl Default for LlmSection
impl Default for LlmSection
Source§fn default() -> LlmSection
fn default() -> LlmSection
Source§impl<'de> Deserialize<'de> for LlmSection
impl<'de> Deserialize<'de> for LlmSection
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for LlmSection
Source§impl PartialEq for LlmSection
impl PartialEq for LlmSection
Source§fn eq(&self, other: &LlmSection) -> bool
fn eq(&self, other: &LlmSection) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for LlmSection
impl Serialize for LlmSection
impl StructuralPartialEq for LlmSection
Auto Trait Implementations§
impl Freeze for LlmSection
impl RefUnwindSafe for LlmSection
impl Send for LlmSection
impl Sync for LlmSection
impl Unpin for LlmSection
impl UnsafeUnpin for LlmSection
impl UnwindSafe for LlmSection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more