Cost control
Mnemosyne ships no model and no key. The server calls the LLM provider you configure, with your key, for two things: embeddings on every write and recall, and completions for extraction and session collapse.
Cap daily spend
MNEMO_LLM_DAILY_BUDGET_USD caps, in US dollars per UTC day, what the
server’s own completion provider (MNEMO_LLM_*) spends:
MNEMO_LLM_DAILY_BUDGET_USD=5- The counter resets at 00:00 UTC. The running total is the
mnemo_llm_daily_spend_usdgauge, and the log saysllm.daily_budget_reachedthe first time the cap is hit each day. - Once the cap is reached, completions are refused until the reset, and each feature that uses them degrades as if the LLM were down: session collapse fails and stays retryable, rerank keeps the original order, HyDE searches with the raw query, and conflict checks wait.
- Embeddings are not capped, even on the same provider, so writes keep working.
- Only models in the price table are counted. For an unpriced model the boot
log says
llm.budget_unpriced_model, and the cap does not stop it. - A value that is not a positive number stops the server at boot.
- The counter lives in each server process, so each replica keeps its own.
- The per-task providers (
MNEMO_LLM_JUDGE_*,_SUMMARY_*,_PREFILTER_*, below) count toward the cap, and an unpriced per-task model gets the same warning. - The providers that workspaces set with
PUT /config/llmare not capped.
Without the variable there is no cap. Set a limit on the provider’s side as well.
Choose the provider
Eight providers are supported: OpenAI, Anthropic, Google, Cohere, Mistral, Voyage, AWS Bedrock and Ollama.
| Variable | What it selects |
|---|---|
MNEMO_LLM_PROVIDER | openai, anthropic, google, cohere, mistral, voyage, bedrock or ollama. |
MNEMO_LLM_API_KEY | The provider key. Ollama needs none. |
MNEMO_LLM_MODEL | The completion model. Unset, the provider’s default. |
MNEMO_LLM_BASE_URL | The provider endpoint, for a proxy or a local Ollama. |
MNEMO_EMBED_PROVIDER | A separate provider for embeddings, with MNEMO_EMBED_API_KEY and MNEMO_EMBED_BASE_URL. |
MNEMO_EMBED_MODEL | The embedding model. |
Splitting the two lets you embed with one vendor and run completions with another. Anthropic does not embed and Voyage only embeds, so each needs a partner.
An installation admin can also set the provider at runtime with PUT /admin/config/llm. With MNEMO_WORKSPACE_LLM_OVERRIDE=true, workspace
owners and admins can set their own with PUT /config/llm.
A provider per task
Every completion the server makes declares a task. Three of them can run on their own provider and model, so you can, for example, judge conflicts on one vendor and collapse sessions on a cheaper model:
| Task | What uses it | Variables |
|---|---|---|
judge | Conflict classification, recall rerank, reminder conditions | MNEMO_LLM_JUDGE_PROVIDER, MNEMO_LLM_JUDGE_MODEL, MNEMO_LLM_JUDGE_API_KEY |
summary | Session collapse, POST /capture extraction, compression | MNEMO_LLM_SUMMARY_PROVIDER, _MODEL, _API_KEY |
prefilter | HyDE and anticipation queries, before retrieval | MNEMO_LLM_PREFILTER_PROVIDER, _MODEL, _API_KEY |
| default | Replay query generation, warm-up, health checks | MNEMO_LLM_PROVIDER, MNEMO_LLM_MODEL, MNEMO_LLM_API_KEY |
MNEMO_LLM_PROVIDER=openai
MNEMO_LLM_API_KEY=sk-...
MNEMO_LLM_JUDGE_PROVIDER=anthropic
MNEMO_LLM_JUDGE_API_KEY=sk-ant-...
MNEMO_LLM_PREFILTER_MODEL=gpt-4o-mini- A task without its own variables runs on
MNEMO_LLM_PROVIDER. With none of them set, nothing changes. - A task on the default vendor (
_PROVIDERunset or the same name) inherits its key,MNEMO_LLM_BASE_URLandMNEMO_LLM_MODEL, unless it sets its own. - Another vendor inherits nothing. It needs its own
_API_KEY(Ollama needs none), and with_MODELunset it uses that vendor’s default model. - The server refuses to start when another vendor has no key, when the vendor
is unknown, or when a task is set without
MNEMO_LLM_PROVIDER, rather than quietly sending the task to the default. With routing on, the boot log saysllm.task_routing_enabled. MNEMO_LLM_DAILY_BUDGET_USDcounts every task’s provider.MNEMO_SENSITIVE_TEXT_TO_PROVIDERSdecides whether external providers may see the text of confidential and restricted memories. A task that runs on a local provider (Ollama with no base URL, or a base URL onlocalhostor a private IP) gets it in every case, so ajudgeon such an Ollama checks contradictions with those facts without sending them out. See Security & isolation.- Embeddings keep their own
MNEMO_EMBED_*. A workspace with its own configuration (PUT /config/llm) uses that one provider for every task.
Run locally for no API cost
The local Docker stack runs both completions and embeddings on the bundled
Ollama (qwen2.5:3b and bge-m3), so it makes no paid calls. You pay in
hardware instead.
Do not swap the completion model for a smaller one to save disk. Session collapse writes what the model returns into memory, and a model too small for extraction writes wrong facts without failing.
Spend less per call
- Embedding model. Changing
MNEMO_EMBED_MODELre-embeds existing memories in the background, which is itself a cost. Pick it early. - Recall token budget.
POST /recallacceptstokenBudget, andMNEMO_RECALL_DEFAULT_TOKEN_BUDGETsets a default. Below 500 the recall is skipped, below 2000 only the hot tier runs, below 8000 the hot and pointer tiers run, and from 8000 the full pipeline runs. - Rerank. The LLM rerank step on recall is off unless the request asks for it.
Measure it
Prometheus counters, labelled by model and operation:
mnemo_llm_tokens_used_total{model, operation}
mnemo_llm_cost_usd_total{model, operation}
mnemo_tokens_saved_estimated_total{mechanism}The cost figure comes from a static pricing table inside the server, and a
model missing from the table counts as zero. Treat it as an estimate and
reconcile it with the provider’s invoice. The
cost.json Grafana dashboard in docker/scripts/dashboards/ charts these
series. See Monitoring.
GET /cost returns the current month for the key’s workspace: recall count,
LLM and embedding tokens, estimatedCostUsd and costPerRecall.
curl http://localhost:3939/cost \
-H "Authorization: Bearer mns_live_..."What is not available
A workspace’s own LLM configuration (PUT /config/llm) is not split per
task: per-task providers apply only to the server’s MNEMO_LLM_* provider.