The user asked for usage to be monitored closely, and measuring it turned up that most of the spend was avoidable. Metering: every model call is appended to usage.jsonl with BILLED tokens (modelUsage -- the visible `usage` turn undercounted by half) and the CLI's list-price cost. `usage` reports 5h/24h/7d. Each call's cost is estimated first and refused if it would cross the per-run or rolling 24h budget, so budgets cannot be overshot. Removed --max-budget-usd: it aborts after spending and discards the result ($0.26 lost in one call). Cost, measured on one session ($0.057 -> $0.010, same summary content): - alwaysThinkingEnabled=false: extended thinking was ~85% of output. - DISABLE_PROMPT_CACHING=1: one-shot prompts were being written to the 1h cache at 2x input price. - CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1: a hidden side request re-read the whole prompt, doubling billed input (9,638 vs 4,663). Summaries are cached until their note is written, so a vault failure never re-pays; --prefetch summarizes while the vault is unreachable. Offline tests (fake claude binary): budget refusal pre-flight, cache reuse with zero calls, map-reduce, env/argv levers, billed-token ledger. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KF322NzozeaFjpgWvh4F4g
26 lines
1.1 KiB
Bash
26 lines
1.1 KiB
Bash
# ~/.config/claude-obsidian/config.env (chmod 600; never commit the real one)
|
|
# Every key can also be set as an environment variable, which wins.
|
|
|
|
# Obsidian Local REST API plugin -- the plain-HTTP server (Settings -> Local REST API ->
|
|
# Enable HTTP server). Point this at wherever that port is reachable from this machine.
|
|
OBSIDIAN_API_URL=http://obsidian.example.internal:27123
|
|
OBSIDIAN_API_KEY_FILE=~/.config/claude-obsidian/api-key
|
|
|
|
# Summarizer. claude-cli = headless `claude -p` on your own Claude plan (no API key needed).
|
|
LLM_BACKEND=claude-cli
|
|
LLM_MODEL=haiku
|
|
# CLAUDE_BIN=claude
|
|
|
|
# Or any OpenAI-compatible endpoint (LiteLLM, a local model):
|
|
# LLM_BACKEND=openai
|
|
# LLM_BASE_URL=https://litellm.example/v1
|
|
# LLM_MODEL=some-model
|
|
# LLM_API_KEY_FILE=~/.config/claude-obsidian/llm-key # or LLM_API_KEY_ENV=LITELLM_KEY
|
|
|
|
VAULT_FOLDER=Claude
|
|
SETTLE_MINUTES=30 # leave sessions alone until they have been idle this long
|
|
JOBS=1
|
|
MAX_PER_RUN=10 # summaries share your plan's usage limits; the timer drips a backlog
|
|
BUDGET_USD_PER_RUN=0.50 # list-price USD, refused pre-flight; see `claude-obsidian-sync usage`
|
|
BUDGET_USD_PER_DAY=2.00
|