You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Routstr v0.1.3 — 2025-09-15
### Highlights
- **DB-backed settings with live updates**: Env vars seed on first run; DB is the source of truth (except `DATABASE_URL`). Manage via Admin UI or `PATCH /admin/api/settings`.
- **Models moved to database** with background sats-pricing computation and optional periodic refresh.
- **Smarter max-cost reservation**: Discount based on prompt tokens and `max_tokens` using `TOLERANCE_PERCENTAGE`, with a `MIN_REQUEST_MSAT` floor.
- **Faster startup and provider discovery**; `.onion` endpoints use Tor proxy by default.
### Breaking changes
- **Configuration is DB-first** after bootstrap. Env changes won’t auto-apply (besides `DATABASE_URL`).
- **Models endpoint**: Use `/v1/models` for canonical model info; `/v1/info` keeps an empty `models` field for back-compat.
- **Legacy pricing envs** are auto-mapped but deprecated:
- `MODEL_BASED_PRICING` → `!FIXED_PRICING`
- `COST_PER_REQUEST` → `FIXED_COST_PER_REQUEST`
- `COST_PER_1K_*` → `FIXED_PER_1K_*`
### Added
- **SettingsService** with env→computed→DB merge; runtime edits; app metadata (name/description) applied to OpenAPI.
- **Automatic migrations** on startup; new tables: `settings`, `models`.
- **Per-model sats pricing** and per-request maximums computed in the background.
- **Pricing controls**: `FIXED_PRICING`, `FIXED_COST_PER_REQUEST`, optional per-1k token overrides, `MIN_REQUEST_MSAT`.
- **Azure chat support**: Optional `CHAT_COMPLETIONS_API_VERSION` adds `api-version` to `/chat/completions`.
- **Derive `NPUB` from `NSEC`** during bootstrap if not provided.
### Changed / Improvements
- **Proxy header hardening**: Strip sensitive headers; replace Authorization with upstream key when configured.
- **Discovery**: Read `RELAYS` from settings; Tor proxy defaults for `.onion` via `TOR_PROXY_URL`; faster announcement fetching.
- **Admin**: Improved auth/log UX; fixed log search; show mint balances in dashboard.
- **Performance**: Optimized startup; lazy DB info loading.
### Fixed
- **Refunds**: Correct msat→sat conversion; configurable refund cache TTL via `REFUND_CACHE_TTL_SECONDS`; better error mapping for mint outages.
- **Balances**: Reserved balance reporting and negative-reserved edge cases.
- **Tests**: Updated to patch settings and use fixed-pricing flags.
### Upgrade notes (from v0.1.2)
1. Ensure `DATABASE_URL`, `UPSTREAM_BASE_URL`, and `ADMIN_PASSWORD` are set. Optionally set `UPSTREAM_API_KEY`, `RELAYS`, `CASHU_MINTS`, `TOR_PROXY_URL`.
2. Start the service; automatic Alembic migrations will run (`settings`, `models` tables).
3. Configure settings via Admin UI (`/admin`) or `PATCH /admin/api/settings`. Env changes after first run won’t apply automatically.
4. Prefer new pricing envs or a `models.json` at `MODELS_PATH`. Legacy envs are mapped but will be removed in a future release.
5. Optional tuning: `TOLERANCE_PERCENTAGE`, `MIN_REQUEST_MSAT`, `PRICING_REFRESH_INTERVAL_SECONDS`, `MODELS_REFRESH_INTERVAL_SECONDS`, `ENABLE_*_REFRESH`.
6. For Azure, set `CHAT_COMPLETIONS_API_VERSION`.
### References
- Configuration: `docs/getting-started/configuration.md`
- API: `docs/api/endpoints.md`
- Custom pricing: `docs/advanced/custom-pricing.md`
### Stats and credits
- 42 files changed, +1819/−832 lines.
- Merges: #170 token-discount-max-cost, #171 move-models-to-db.
- Contributors: Shroominic.
Copy file name to clipboardExpand all lines: docs/getting-started/configuration.md
+20-33Lines changed: 20 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Configuration
2
2
3
-
Routstr Core is configured through environment variables. This guide covers all available options.
3
+
Routstr Core is configured via a single settings row in the database. Environment variables are only used on first run to seed that row (with a few computed defaults like `ONION_URL`). After that, the database is the source of truth. You can update settings at runtime via the admin API. `DATABASE_URL` is always env-only.
4
4
5
5
## Environment Variables
6
6
@@ -33,19 +33,21 @@ Routstr Core is configured through environment variables. This guide covers all
33
33
34
34
| Variable | Description | Default | Required |
35
35
|----------|-------------|---------|----------|
36
-
|`MODEL_BASED_PRICING`|Enable model-specific pricing from models.json|`false`| ❌ |
37
-
|`COST_PER_REQUEST`| Fixed cost per API request in sats |`1`| ❌ |
38
-
|`COST_PER_1K_INPUT_TOKENS`|Cost per 1000 input tokens in sats|`0`| ❌ |
39
-
|`COST_PER_1K_OUTPUT_TOKENS`|Cost per 1000 output tokens in sats|`0`| ❌ |
36
+
|`FIXED_PRICING`|Force fixed per-request pricing (ignore model token pricing)|`false`| ❌ |
37
+
|`FIXED_COST_PER_REQUEST`| Fixed cost per API request in sats |`1`| ❌ |
38
+
|`FIXED_PER_1K_INPUT_TOKENS`|Optional override: sats per 1000 input tokens |`0`| ❌ |
39
+
|`FIXED_PER_1K_OUTPUT_TOKENS`|Optional override: sats per 1000 output tokens |`0`| ❌ |
0 commit comments