feat: ollama-proxy — multi-account Ollama Cloud reverse proxy

Go reverse proxy for ollama.com that balances requests across multiple
API keys with round-robin and failover on 429/5xx. Exposes both native
Ollama API (/api/*) and OpenAI-compatible (/v1/*) passthrough.

- Round-robin balancer with per-account cooldown (60s default)
- Pre-stream failover: 429 → cooldown + next account; 5xx → next account
- Streaming invariant: once 2xx starts streaming, no account switch
- SSE (text/event-stream) and NDJSON passthrough with http.Flusher
- CLI: accounts add/list/remove/set-base-url, serve, version
- Accounts stored in ~/.config/ollama-proxy/accounts.json (chmod 0600)
- systemd unit (User=dueattendant149, 127.0.0.1:11435, Restart=always)
- 43 tests (unit + integration with httptest upstream)
- opencode integration: custom provider 'ocp' with explicit model list
- Requires NO_PROXY=127.0.0.1,localhost when HTTP_PROXY is set
This commit is contained in:
Atte149 2026-06-19 13:58:13 +03:00
commit 3963eede70
23 changed files with 2534 additions and 0 deletions

View file

@ -0,0 +1,19 @@
[Unit]
Description=Ollama Cloud multi-account proxy
Documentation=https://git.dueattendant149.org/Atte149/ollama-proxy
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=dueattendant149
Group=dueattendant149
ExecStart=/usr/local/bin/ollama-proxy serve --addr 127.0.0.1:11435 --log-level info
Restart=always
RestartSec=3
Environment=OLLAMA_PROXY_LOG_LEVEL=info
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target