budgets

Get a budget's balance

Changed on

Returns a limit budget's spend, remaining amount, and projected spend in the budget window that contains evaluated_at. derived adds the balances of the derived budgets with the highest spend.

A caller who sees only their own derived budget reads that one. Its amounts count that caller's usage alone, and derived holds the caller's value, or is empty without usage in the budget window.

The amounts count the usage stored when the request runs. latest_record_at shows when the newest counted usage reached the service. Only a limit budget has a balance, so if the budget is an exemption, the request fails with 400. If the organization has no budget with this identifier that the caller can see, or the identifier isn't a valid UUID, the request fails with 404.

get/v1/ai-cost-management/budgets/{budgetId}/balance

Request

  • Base URL
    https://global.api.konghq.com
  • Auth
    • HTTP bearer
    • or HTTP bearer
    • or HTTP bearer
    • or HTTP bearer

Path parameters

budgetId, string uuid required

The id of the budget.

Query parameters

size, integer

The maximum number of derived budgets in derived, which lists the highest spend first.

1 to 100. Defaults to 20.

evaluated_at, string date-time

The time to calculate the balances for, as an RFC 3339 timestamp in UTC. It selects the budget window. The amounts still count all usage stored when the request runs. A request that passes an earlier read's evaluated_at gets the same budget window, unless the budget's window changed in between.

A time in the future isn't accepted. Defaults to the time of the request.

Response

The budget's balance.

object required
budget, AICostBudgetReference required

The budget the balance belongs to.

window, AICostTimeWindow required

The budget window that contains evaluated_at.

limit, AICostMoney required

The limit that remaining is measured against.

consumed, AICostMoney required

The spend of all usage in the budget's scope during the budget window. With each, it's the total for the whole budget: each event counts once, including usage without a value for the each field.

remaining, AICostMoney required

The limit minus consumed. Negative once spend exceeds the limit.

projected, AICostMoney required

Where consumed ends the budget window at the current pace, rounded to the cent. The pace extrapolates consumed over the whole window from the share of the window that has elapsed at evaluated_at. That share counts as at least one twentieth, so a balance read at the very start of a window projects a bounded amount.

evaluated_at, string date-time required

The time the balance is calculated for, as an RFC 3339 timestamp in UTC. It selects the budget window.

latest_record_at, string date-time nullable required

When the newest usage counted in the balance reached the service, as an RFC 3339 timestamp in UTC. It doesn't show that all earlier usage has arrived.

null when no usage matches.

derived, object[] required

The balances of the derived budgets with the highest spend, highest first, at most as many as the size query parameter allows.

Empty for a budget without each.

derived_truncated, boolean required

true when more derived budgets exist than derived lists. It isn't a pagination cursor: GET /v1/ai-cost-management/budget-balances with filter[budget.id] lists the balance of every derived budget.

Changes