Track Ollama usage
txtop’s experimental HTTP proxy records Ollama token usage in the local database. It forwards requests to Ollama; the dashboard then shows local usage beside provider and subscription data.
Experimental. The proxy has seen less production use than the API providers.
Configure txtop
Enable the provider in the active config.toml (see
configuration for platform paths):
[providers.ollama]
enabled = true
base_url = "http://127.0.0.1:11434"
The proxy listens on 127.0.0.1:11434; Ollama must move to 127.0.0.1:11435.
Move Ollama
If systemd manages Ollama, run:
sudo systemctl edit ollama.service
Add:
[Service]
Environment="OLLAMA_HOST=127.0.0.1:11435"
Then reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart ollama
For another process manager, set OLLAMA_HOST=127.0.0.1:11435 in its environment.
Start the proxy
txtop ollama up
This checks the upstream, starts the proxy in the background, and takes over port 11434.
Manage it directly when needed:
txtop ollama status
txtop ollama stop
txtop ollama start \
--listen 127.0.0.1:11434 \
--upstream http://127.0.0.1:11435
Run it in the foreground for debugging:
txtop ollama run \
--listen 127.0.0.1:11434 \
--upstream http://127.0.0.1:11435
The proxy only accepts loopback listen addresses by default. --allow-remote permits other interfaces; use it only on trusted networks. Request bodies are buffered in memory up to 100 MB.
Check connectivity
txtop ollama doctor
txtop ollama print-env --listen 127.0.0.1:11434
The second command prints the OLLAMA_HOST value for shell clients.
Add cost estimates
Local models have no price by default. Map a local name to a model in the OpenRouter catalog:
txtop ollama refresh-catalog --base-url https://openrouter.ai
txtop ollama map-model \
--local-model llama3 \
--reference-model meta-llama/llama-3-8b-instruct
Mapped costs are estimates; they use the reference model’s catalog price.
Start the proxy with systemd (Linux)
Create /etc/systemd/system/txtop-ollama@.service:
[Unit]
Description=txtop Ollama proxy
After=network-online.target ollama.service
Wants=network-online.target
[Service]
Type=simple
User=%i
ExecStart=/usr/bin/txtop ollama run --listen 127.0.0.1:11434 --upstream http://127.0.0.1:11435 --pid-file /home/%i/.local/share/txtop/proxy.pid
Restart=on-failure
RestartSec=2
[Install]
WantedBy=multi-user.target
Enable it for the current user:
sudo systemctl daemon-reload
sudo systemctl enable --now txtop-ollama@${USER}.service
Confirm the installed binary path with command -v txtop; update ExecStart if needed.