Balance
Configure token credit balances for users in LibreChat
Overview
The balance object allows administrators to configure how token credit balances are managed for users within LibreChat. Settings include enabling balance tracking, initializing user balances, and configuring automatic token refill behavior.
Fields under balance:
enabledstartBalanceautoRefillEnabledrefillIntervalValuerefillIntervalUnitrefillAmountrefillModereservationTtlMsdisplay
Notes:
balanceconfigurations apply globally across the application.- Defaults are provided but can be customized based on requirements.
- Conditional logic can dynamically modify these settings based on other configurations.
Example
balance:
enabled: false
startBalance: 20000
autoRefillEnabled: false
refillIntervalValue: 30
refillIntervalUnit: "days"
refillAmount: 10000
refillMode: "add"
reservationTtlMs: 1800000
display: "credits"enabled
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| enabled | Boolean | Enables token credit tracking and balance management for users. | Set to true to activate balance tracking for token usage. |
Default: false
Example:
balance:
enabled: truestartBalance
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| startBalance | Integer | Specifies the initial number of tokens credited to a user upon registration. | Tokens credited to a new user account. |
Default: 20000
Example:
balance:
startBalance: 20000autoRefillEnabled
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| autoRefillEnabled | Boolean | Determines whether automatic refilling of token credits is enabled. | Set to true to enable automatic token refills. |
Default: false
Example:
balance:
autoRefillEnabled: truerefillIntervalValue
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| refillIntervalValue | Integer | Specifies the numerical value for the interval at which token credits are automatically refilled. | For example, 30 represents a 30-day interval. |
Default: 30
Example:
balance:
refillIntervalValue: 30refillIntervalUnit
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| refillIntervalUnit | String | Specifies the time unit for the refill interval. One of "seconds", "minutes", "hours", "days", "weeks", or "months". | Indicates the unit of time for refillIntervalValue. |
Default: "days"
Example:
balance:
refillIntervalUnit: "days"refillAmount
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| refillAmount | Integer | Specifies the number of tokens to be added to the user's balance during each automatic refill. | The amount added to a user’s token credits at each refill interval. |
Default: 10000
Example:
balance:
refillAmount: 10000refillMode
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| refillMode | String | Controls what a refill does. "add" adds refillAmount to the current balance; "reset" replaces the balance with refillAmount once the interval is due. | "reset" requires refillIntervalValue to be a positive integer. |
Default: "add"
Example:
balance:
autoRefillEnabled: true
refillMode: "reset"
refillIntervalValue: 1
refillIntervalUnit: "months"
refillAmount: 500000reservationTtlMs
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| reservationTtlMs | Integer | How long, in milliseconds, an unreleased in-flight balance reservation keeps counting against the balance. | Minimum: 10000. Live reservations are renewed every half interval. |
Default: 1800000 (30 minutes)
Example:
balance:
reservationTtlMs: 1800000display
Key:
| Key | Type | Description | Example |
|---|---|---|---|
| display | String | How the UI presents the balance. "credits" shows the raw figure, "currency" shows its currency value, and "percent" shows the share of the period's allotment already spent. | One of "credits", "currency", or "percent". |
Default: "credits"
Example:
balance:
display: "currency"How is this guide?