Tokenomics includes an embedded admin SPA for local operations.
- Provide operator visibility for usage, keys, sessions, and memory.
- Keep all assets embedded in the binary.
- Keep admin access local-only by default, with optional basic auth.
- Start persistent proxy:
tokenomics start
- Open:
https://localhost:8443(default)http://localhost:8080(if HTTP enabled)
Admin routing and security:
- Admin UI and API are local-only.
- Optional basic auth is controlled by:
admin.auth.usernameadmin.auth.password
Analytics- realtime counters and rollups.Keys- wrapper token list and policy editor modal.Sessions- session-level totals and drill-down.Memory- memory file browser and viewer.Docs- embedded operator instructions loaded fromcmd/web/admin/assets/docs.json.
The Keys tab supports:
New Key-> opens policy editor modal.View-> loads existing key into editor modal.Save-> creates or updates key.Delete-> deletes selected key.
When a key is created:
- A one-time modal shows the raw token value.
- Operator can copy the value.
- This is the only time the raw key is shown.
The policy editor supports:
- Global fields:
base_key_env,upstream_url,default_providermax_tokens,timeoutmodel(exact),model_regex(pattern)
- Prompt rows with role and multiline content.
- Rule rows (
regex,keyword,pii,jailbreak). - Rate limit and retry/fallback fields.
- Metadata key-value rows.
- Provider policy rows (provider name + provider policy JSON object).
- Advanced JSON sync:
Generate JSON From FormLoad JSON Into Form
Notes:
modelis exact match.model_regexis pattern match.Test regexvalidates current regex against a model input.- Memory settings are not edited in token policy UI. Memory is treated as tool-level configuration in this workflow.
Core endpoints:
GET /admin/api/healthGET /admin/api/analytics/summaryGET /admin/api/keysPOST /admin/api/keysPUT /admin/api/keys/{hash}DELETE /admin/api/keys/{hash}GET /admin/api/env-varsGET /admin/api/sessionsGET /admin/api/sessions/{id}GET /admin/api/memory/filesGET /admin/api/memory/files/{path}
Compatibility aliases:
GET /admin/api/tokensGET /admin/api/tokens/{hash}GET /admin/api/usage/summaryGET /admin/api/usage/tokens/{hash}
Admin assets are embedded via go:embed in cmd/admin_ui.go:
cmd/web/admin/index.htmlcmd/web/admin/assets/*
Embedded docs source:
cmd/web/admin/assets/docs.json
When admin behavior changes:
- Update this file:
docs/ADMIN_UI.md. - Update route and behavior summary:
docs/WEB.md. - Update in-app docs payload:
cmd/web/admin/assets/docs.json. - If config behavior changed, update
docs/CONFIGURATION.md. - If policy behavior changed, update
docs/POLICIES.md.