fix: don't bill self-hosted models reached by a container/service hostname #596
No reviewers
Labels
No labels
area:chat
area:core
area:llm
area:routes
area:tools
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sleepy/odysseus!596
Loading…
Reference in a new issue
No description provided.
Delete branch "nsgds/fix/local-endpoint-billing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
isLocalEndpoint()(static/js/chatRenderer.js) decides whether a model is local — and therefore free. It recognizes IPs,localhost, and.local, but not a bare single-label hostname like a Docker/Compose service name (nim-nano,llamaswap, …). BecausegetModelCost()matches the pricing table on a name substring, a self-hosted model whose id contains e.g.nemotronorllamathen gets billed at cloud rates — the cost badge and Message Stats show a phantom non-zero cost.Fix
Treat any hostname with no dot as local. A public API always needs an FQDN, so a single-label host can only be internal:
IPs (which contain dots) still fall through to the existing private-range checks, and real cloud FQDNs are unaffected.
Files
static/js/chatRenderer.js— one guard inisLocalEndpoint()(+6 lines).Testing
node --checkon a.mjscopy — the file is browser ESM, so the literalnode --check *.jsmisreads theimportas CommonJS).http://nim-nano:8000) whose id containsnemotron.Before — local model billed at cloud rates:
After — correctly free ($0):
Related
Complements #518 (cloud spend billing) — it reads the same cost path, so without this guard self-hosted models would also inflate its new spend graphs/budgets.
Merged via squash. Minimal 6-line fix.
isLocalEndpoint()now treats dotless hostnames (Docker/K8s service names) as local, consistent with existingadmin.jsimplementation.