mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-07-30 15:26:14 +00:00
docs: update configuration/pricing docs and compose with FIXED_* vars
This commit is contained in:
+4
-4
@@ -19,10 +19,10 @@ services:
|
|||||||
- "ONION_URL=http://test.onion"
|
- "ONION_URL=http://test.onion"
|
||||||
- "CORS_ORIGINS=*"
|
- "CORS_ORIGINS=*"
|
||||||
- "RECEIVE_LN_ADDRESS=test@routstr.com"
|
- "RECEIVE_LN_ADDRESS=test@routstr.com"
|
||||||
- "COST_PER_REQUEST=10"
|
- "FIXED_COST_PER_REQUEST=10"
|
||||||
- "COST_PER_1K_INPUT_TOKENS=0"
|
- "FIXED_PER_1K_INPUT_TOKENS=0"
|
||||||
- "COST_PER_1K_OUTPUT_TOKENS=0"
|
- "FIXED_PER_1K_OUTPUT_TOKENS=0"
|
||||||
- "MODEL_BASED_PRICING=true"
|
- "FIXED_PRICING=false"
|
||||||
- "NSEC=nsec1testkey1234567890abcdef"
|
- "NSEC=nsec1testkey1234567890abcdef"
|
||||||
- "REFUND_PROCESSING_INTERVAL=3600"
|
- "REFUND_PROCESSING_INTERVAL=3600"
|
||||||
- "MINIMUM_PAYOUT=1000"
|
- "MINIMUM_PAYOUT=1000"
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ Routstr supports three pricing models:
|
|||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
Enable model-based pricing:
|
Enable model-based pricing (default behavior):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# .env
|
# .env
|
||||||
MODEL_BASED_PRICING=true
|
FIXED_PRICING=false
|
||||||
MODELS_PATH=/app/config/models.json
|
MODELS_PATH=/app/config/models.json
|
||||||
EXCHANGE_FEE=1.005 # 0.5% exchange fee
|
EXCHANGE_FEE=1.005 # 0.5% exchange fee
|
||||||
UPSTREAM_PROVIDER_FEE=1.05 # 5% provider margin
|
UPSTREAM_PROVIDER_FEE=1.05 # 5% provider margin
|
||||||
@@ -118,14 +118,14 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
Set up token-based pricing:
|
Set up token-based pricing overrides:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# .env
|
# .env
|
||||||
MODEL_BASED_PRICING=false
|
FIXED_PRICING=false # use model pricing
|
||||||
COST_PER_REQUEST=1 # 1 sat base fee
|
FIXED_COST_PER_REQUEST=1 # optional base fee
|
||||||
COST_PER_1K_INPUT_TOKENS=5 # 5 sats per 1K input
|
FIXED_PER_1K_INPUT_TOKENS=5 # optional override
|
||||||
COST_PER_1K_OUTPUT_TOKENS=15 # 15 sats per 1K output
|
FIXED_PER_1K_OUTPUT_TOKENS=15 # optional override
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom Token Counting
|
### Custom Token Counting
|
||||||
|
|||||||
@@ -436,6 +436,27 @@ Authorization: Bearer sk-...
|
|||||||
|
|
||||||
## Provider Discovery
|
## Provider Discovery
|
||||||
|
|
||||||
|
## Admin Settings
|
||||||
|
|
||||||
|
These endpoints are protected by the Admin cookie (`admin_password` set to your configured admin password).
|
||||||
|
|
||||||
|
### Get Settings
|
||||||
|
|
||||||
|
```http
|
||||||
|
GET /admin/api/settings
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the current application settings (sensitive values may be redacted).
|
||||||
|
|
||||||
|
### Update Settings
|
||||||
|
|
||||||
|
```http
|
||||||
|
PATCH /admin/api/settings
|
||||||
|
Content-Type: application/json
|
||||||
|
```
|
||||||
|
|
||||||
|
Body is a partial JSON of settings fields to update. Validated and persisted to the database.
|
||||||
|
|
||||||
### List Providers
|
### List Providers
|
||||||
|
|
||||||
Get available upstream providers.
|
Get available upstream providers.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
Routstr Core is configured through environment variables. This guide covers all available options.
|
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.
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
@@ -33,10 +33,10 @@ Routstr Core is configured through environment variables. This guide covers all
|
|||||||
|
|
||||||
| Variable | Description | Default | Required |
|
| Variable | Description | Default | Required |
|
||||||
|----------|-------------|---------|----------|
|
|----------|-------------|---------|----------|
|
||||||
| `MODEL_BASED_PRICING` | Enable model-specific pricing from models.json | `false` | ❌ |
|
| `FIXED_PRICING` | Force fixed per-request pricing (ignore model token pricing) | `false` | ❌ |
|
||||||
| `COST_PER_REQUEST` | Fixed cost per API request in sats | `1` | ❌ |
|
| `FIXED_COST_PER_REQUEST` | Fixed cost per API request in sats | `1` | ❌ |
|
||||||
| `COST_PER_1K_INPUT_TOKENS` | Cost per 1000 input tokens in sats | `0` | ❌ |
|
| `FIXED_PER_1K_INPUT_TOKENS` | Optional override: sats per 1000 input tokens | `0` | ❌ |
|
||||||
| `COST_PER_1K_OUTPUT_TOKENS` | Cost per 1000 output tokens in sats | `0` | ❌ |
|
| `FIXED_PER_1K_OUTPUT_TOKENS` | Optional override: sats per 1000 output tokens | `0` | ❌ |
|
||||||
| `EXCHANGE_FEE` | Exchange rate markup (1.005 = 0.5% fee) | `1.005` | ❌ |
|
| `EXCHANGE_FEE` | Exchange rate markup (1.005 = 0.5% fee) | `1.005` | ❌ |
|
||||||
| `UPSTREAM_PROVIDER_FEE` | Provider fee markup (1.05 = 5% fee) | `1.05` | ❌ |
|
| `UPSTREAM_PROVIDER_FEE` | Provider fee markup (1.05 = 5% fee) | `1.05` | ❌ |
|
||||||
|
|
||||||
@@ -46,6 +46,8 @@ Routstr Core is configured through environment variables. This guide covers all
|
|||||||
|----------|-------------|---------|----------|
|
|----------|-------------|---------|----------|
|
||||||
| `CORS_ORIGINS` | Comma-separated list of allowed CORS origins | `*` | ❌ |
|
| `CORS_ORIGINS` | Comma-separated list of allowed CORS origins | `*` | ❌ |
|
||||||
| `TOR_PROXY_URL` | SOCKS5 proxy URL for Tor connections | `socks5://127.0.0.1:9050` | ❌ |
|
| `TOR_PROXY_URL` | SOCKS5 proxy URL for Tor connections | `socks5://127.0.0.1:9050` | ❌ |
|
||||||
|
| `RELAYS` | Comma-separated nostr relays for NIP-91 | defaults applied | ❌ |
|
||||||
|
| `PROVIDERS_REFRESH_INTERVAL_SECONDS` | Provider cache refresh interval | `300` | ❌ |
|
||||||
|
|
||||||
### Logging Configuration
|
### Logging Configuration
|
||||||
|
|
||||||
@@ -60,6 +62,7 @@ Routstr Core is configured through environment variables. This guide covers all
|
|||||||
|----------|-------------|---------|----------|
|
|----------|-------------|---------|----------|
|
||||||
| `CHAT_COMPLETIONS_API_VERSION` | Append `api-version` to `/chat/completions` (Azure OpenAI) | - | ❌ |
|
| `CHAT_COMPLETIONS_API_VERSION` | Append `api-version` to `/chat/completions` (Azure OpenAI) | - | ❌ |
|
||||||
| `DATABASE_URL` | SQLite database connection string | `sqlite+aiosqlite:///keys.db` | ❌ |
|
| `DATABASE_URL` | SQLite database connection string | `sqlite+aiosqlite:///keys.db` | ❌ |
|
||||||
|
| `REFUND_CACHE_TTL_SECONDS` | Cache TTL for refund responses (seconds) | `3600` | ❌ |
|
||||||
|
|
||||||
## Configuration Examples
|
## Configuration Examples
|
||||||
|
|
||||||
@@ -78,7 +81,6 @@ ADMIN_PASSWORD=my-secure-password
|
|||||||
# .env
|
# .env
|
||||||
UPSTREAM_BASE_URL=https://api.anthropic.com/v1
|
UPSTREAM_BASE_URL=https://api.anthropic.com/v1
|
||||||
UPSTREAM_API_KEY=your-anthropic-key
|
UPSTREAM_API_KEY=your-anthropic-key
|
||||||
MODEL_BASED_PRICING=true
|
|
||||||
MODELS_PATH=/app/config/anthropic-models.json
|
MODELS_PATH=/app/config/anthropic-models.json
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -115,36 +117,21 @@ ONION_URL=http://lightningai.onion
|
|||||||
CASHU_MINTS=https://mint1.com,https://mint2.com
|
CASHU_MINTS=https://mint1.com,https://mint2.com
|
||||||
```
|
```
|
||||||
|
|
||||||
## Pricing Models
|
## Pricing
|
||||||
|
|
||||||
### Fixed Pricing
|
- Default: pricing comes from your `models.json`.
|
||||||
|
- Force fixed per-request pricing: set `FIXED_PRICING=true` and `FIXED_COST_PER_REQUEST`.
|
||||||
|
- Optional token overrides when using model pricing: set
|
||||||
|
`FIXED_PER_1K_INPUT_TOKENS` and/or `FIXED_PER_1K_OUTPUT_TOKENS`.
|
||||||
|
- Legacy envs are still accepted and mapped automatically:
|
||||||
|
`MODEL_BASED_PRICING` → `!FIXED_PRICING`, `COST_PER_REQUEST` → `FIXED_COST_PER_REQUEST`,
|
||||||
|
`COST_PER_1K_*` → `FIXED_PER_1K_*`.
|
||||||
|
|
||||||
Simple per-request pricing:
|
Example fixed pricing:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
MODEL_BASED_PRICING=false
|
FIXED_PRICING=true
|
||||||
COST_PER_REQUEST=10 # 10 sats per request
|
FIXED_COST_PER_REQUEST=10
|
||||||
```
|
|
||||||
|
|
||||||
### Token-Based Pricing
|
|
||||||
|
|
||||||
Charge based on token usage:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MODEL_BASED_PRICING=false
|
|
||||||
COST_PER_REQUEST=1 # 1 sat base fee
|
|
||||||
COST_PER_1K_INPUT_TOKENS=5 # 5 sats per 1k input
|
|
||||||
COST_PER_1K_OUTPUT_TOKENS=15 # 15 sats per 1k output
|
|
||||||
```
|
|
||||||
|
|
||||||
### Model-Based Pricing
|
|
||||||
|
|
||||||
Use dynamic pricing from models.json:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MODEL_BASED_PRICING=true
|
|
||||||
EXCHANGE_FEE=1.01 # 1% exchange fee
|
|
||||||
UPSTREAM_PROVIDER_FEE=1.00 # No additional markup
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Custom Models Configuration
|
## Custom Models Configuration
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ NPUB=npub1...
|
|||||||
HTTP_URL=https://api.mynode.com
|
HTTP_URL=https://api.mynode.com
|
||||||
ONION_URL=http://mynode.onion
|
ONION_URL=http://mynode.onion
|
||||||
|
|
||||||
# Pricing
|
# Pricing (optional)
|
||||||
MODEL_BASED_PRICING=true
|
FIXED_PRICING=false
|
||||||
EXCHANGE_FEE=1.005
|
EXCHANGE_FEE=1.005
|
||||||
UPSTREAM_PROVIDER_FEE=1.05
|
UPSTREAM_PROVIDER_FEE=1.05
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ Routstr supports three pricing models:
|
|||||||
Simple per-request charging:
|
Simple per-request charging:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
MODEL_BASED_PRICING=false
|
FIXED_PRICING=true
|
||||||
COST_PER_REQUEST=10 # 10 sats per request
|
FIXED_COST_PER_REQUEST=10 # 10 sats per request
|
||||||
```
|
```
|
||||||
|
|
||||||
**Best for:**
|
**Best for:**
|
||||||
@@ -26,10 +26,10 @@ COST_PER_REQUEST=10 # 10 sats per request
|
|||||||
Charge based on actual token usage:
|
Charge based on actual token usage:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
MODEL_BASED_PRICING=false
|
FIXED_PRICING=false # use model pricing
|
||||||
COST_PER_REQUEST=1 # 1 sat base fee
|
FIXED_COST_PER_REQUEST=1 # optional base fee
|
||||||
COST_PER_1K_INPUT_TOKENS=5 # 5 sats per 1K input
|
FIXED_PER_1K_INPUT_TOKENS=5 # optional override
|
||||||
COST_PER_1K_OUTPUT_TOKENS=15 # 15 sats per 1K output
|
FIXED_PER_1K_OUTPUT_TOKENS=15 # optional override
|
||||||
```
|
```
|
||||||
|
|
||||||
**Best for:**
|
**Best for:**
|
||||||
@@ -43,7 +43,7 @@ COST_PER_1K_OUTPUT_TOKENS=15 # 15 sats per 1K output
|
|||||||
Dynamic pricing based on model costs:
|
Dynamic pricing based on model costs:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
MODEL_BASED_PRICING=true
|
FIXED_PRICING=false
|
||||||
EXCHANGE_FEE=1.005 # 0.5% exchange fee
|
EXCHANGE_FEE=1.005 # 0.5% exchange fee
|
||||||
UPSTREAM_PROVIDER_FEE=1.05 # 5% provider fee
|
UPSTREAM_PROVIDER_FEE=1.05 # 5% provider fee
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user