API reference

API reference · Account

The month's spend forecast for the account and each key

GET/api/account/spend-forecastSigned in session

The signed in account's spend this UTC month and where the recent trend takes it, the month to date plus the mean of the last 7 full UTC days times what is left of the month, against its monthly cap, and the same for each of its live personal keys against the key's monthly budget. The figures are the usage rows the ceilings themselves count. Under 3 full days there is no projection. Once a month per scope, before the cap is reached, a forecast that passes it sends the webhook event spend.forecast_over_cap and an email where one is set up.

Answer 200

The forecasts.

Fields of the 200 answer
FieldTypeWhat it is
monthstringThe UTC month, YYYY-MM.
accountobject
account.scopestringOne of "account", "key".
account.idintegerThe account's user id, or the key's id.
account.namestringThe key's name.
account.forecastobjectok false, with only monthToDateMicros and windowDays, under 3 full days of data: no figure is projected from fewer.
account.forecast.okboolean
account.forecast.monthToDateMicrosintegerSpent this UTC month so far.
account.forecast.meanDailyMicrosintegerThe mean of the last full UTC days, up to 7.
account.forecast.windowDaysintegerHow many full days the mean rests on.
account.forecast.daysLeftnumberWhat is left of the month, today included.
account.forecast.projectedMicrosintegerThe month to date plus the mean times the days left.
account.capobject or nullThe forecast against the account's monthly cap or the key's monthly budget.
account.cap.capMicrosinteger
account.cap.overbooleanThe projection passes the cap.
account.cap.reachedbooleanThe month to date has reached it.
account.cap.reachesAtinteger or nullAbout when the trend reaches it, in this month, in unix milliseconds.
account.alertedAtinteger or nullWhen this month's warning went, if it did.
keysarray of object
keys[].scopestringOne of "account", "key".
keys[].idintegerThe account's user id, or the key's id.
keys[].namestringThe key's name.
keys[].forecastobjectok false, with only monthToDateMicros and windowDays, under 3 full days of data: no figure is projected from fewer.
keys[].forecast.okboolean
keys[].forecast.monthToDateMicrosintegerSpent this UTC month so far.
keys[].forecast.meanDailyMicrosintegerThe mean of the last full UTC days, up to 7.
keys[].forecast.windowDaysintegerHow many full days the mean rests on.
keys[].forecast.daysLeftnumberWhat is left of the month, today included.
keys[].forecast.projectedMicrosintegerThe month to date plus the mean times the days left.
keys[].capobject or nullThe forecast against the account's monthly cap or the key's monthly budget.
keys[].cap.capMicrosinteger
keys[].cap.overbooleanThe projection passes the cap.
keys[].cap.reachedbooleanThe month to date has reached it.
keys[].cap.reachesAtinteger or nullAbout when the trend reaches it, in this month, in unix milliseconds.
keys[].alertedAtinteger or nullWhen this month's warning went, if it did.
windowDaysinteger
minDaysinteger

Errors

  • 401OpenAI shaped error.
  • 429OpenAI shaped error.

Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.

Antimatter