OperationsCost control

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_usd gauge, and the log says llm.daily_budget_reached the 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/llm are 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.

VariableWhat it selects
MNEMO_LLM_PROVIDERopenai, anthropic, google, cohere, mistral, voyage, bedrock or ollama.
MNEMO_LLM_API_KEYThe provider key. Ollama needs none.
MNEMO_LLM_MODELThe completion model. Unset, the provider’s default.
MNEMO_LLM_BASE_URLThe provider endpoint, for a proxy or a local Ollama.
MNEMO_EMBED_PROVIDERA separate provider for embeddings, with MNEMO_EMBED_API_KEY and MNEMO_EMBED_BASE_URL.
MNEMO_EMBED_MODELThe 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:

TaskWhat uses itVariables
judgeConflict classification, recall rerank, reminder conditionsMNEMO_LLM_JUDGE_PROVIDER, MNEMO_LLM_JUDGE_MODEL, MNEMO_LLM_JUDGE_API_KEY
summarySession collapse, POST /capture extraction, compressionMNEMO_LLM_SUMMARY_PROVIDER, _MODEL, _API_KEY
prefilterHyDE and anticipation queries, before retrievalMNEMO_LLM_PREFILTER_PROVIDER, _MODEL, _API_KEY
defaultReplay query generation, warm-up, health checksMNEMO_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 (_PROVIDER unset or the same name) inherits its key, MNEMO_LLM_BASE_URL and MNEMO_LLM_MODEL, unless it sets its own.
  • Another vendor inherits nothing. It needs its own _API_KEY (Ollama needs none), and with _MODEL unset 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 says llm.task_routing_enabled.
  • MNEMO_LLM_DAILY_BUDGET_USD counts every task’s provider.
  • MNEMO_SENSITIVE_TEXT_TO_PROVIDERS decides 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 on localhost or a private IP) gets it in every case, so a judge on 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_MODEL re-embeds existing memories in the background, which is itself a cost. Pick it early.
  • Recall token budget. POST /recall accepts tokenBudget, and MNEMO_RECALL_DEFAULT_TOKEN_BUDGET sets 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.