LiumBudgetExceededError
from lium.sdk import LiumBudgetExceededError
Defined in lium.sdk.exceptions.
The API key's budget refused the request (402, error.code API_KEY_BUDGET_EXCEEDED).
A per-key daily, monthly or lifetime budget (lium keys create --daily-budget / --monthly-budget / --max-budget, lium keys budget) is reached: the billing tick deletes the key's pods (data outside
a volume is lost), and a rent, a pod extend / schedule change or a key-initiated top-up (lium fund,
lium topup, lium topup card) through that key is refused with this one error. The message
names the window hit.
budget_usd, spent_usd, window (daily, monthly or max) and api_key_id are filled when the
server's error body carried them, else None. A LiumPermissionError handler keeps working; this
class is for callers that want the numbers.
LiumBudgetExceededError(
message: str,
*,
budget_usd: float | None = None,
spent_usd: float | None = None,
window: str | None = None,
api_key_id: str | None = None,
code: str | None = None,
hint: str | None = None,
request_id: str | None = None
)
Catching it
LiumBudgetExceededError subclasses LiumPermissionError → LiumError → Exception, so a handler for any of those also catches it.
from lium.sdk import LiumBudgetExceededError
try:
... # any SDK call
except LiumBudgetExceededError as e:
print(e, e.code, e.hint, e.request_id)
| Field | Meaning |
|---|---|
code | machine-readable error code from the API, when it sent one |
hint | what to try next, when the API suggested something |
request_id | the API request id; quote it when you contact support |
Attributes
| Name | Type | Description |
|---|---|---|
budget_usd | ||
spent_usd | ||
window | ||
api_key_id |