API reference

API reference · Account

Metered spend over a window, by model, key, project or day

GET/api/account/spend-analysisSigned in session

What each request was billed, however it was paid, summed over a window of UTC days and grouped. The personal account counts its requests with no key and with its personal keys, as its statement does; a team (orgId) counts its keys, every one for a role that reads the team's billing and the reader's own for anyone else (own: true). With format=csv, the same rows and total as a download.

Parameters

Path and query parameters
FieldTypeWhat it is
from (query)stringThe first UTC day, YYYY-MM-DD. Default: 30 days ending on to.
to (query)stringThe last UTC day, YYYY-MM-DD, included; never after today. Default: today.
by (query)stringHow the rows are grouped; project only with orgId. Default: model. One of "model", "key", "project", "day".
orgId (query)integer
format (query)stringOne of "json", "csv".

Answer 200

The rows, at most 366 days of them.

Fields of the 200 answer
FieldTypeWhat it is
scopestringOne of "account", "organization".
orgIdinteger or null
ownboolean
fromstring
tostring
bystringOne of "model", "key", "project", "day".
rowsarray of object
rows[].idstring or integer or nullA model id, a key's id (null: requests with no key), a project's id (null: keys in no project), or a UTC day's start in unix milliseconds.
rows[].labelstring or null
rows[].prefixstring or nullA key's public prefix.
rows[].requestsinteger
rows[].promptTokensinteger
rows[].completionTokensinteger
rows[].costMicrosintegerMetered: what the requests were billed.
totalobject
total.idstring or integer or nullA model id, a key's id (null: requests with no key), a project's id (null: keys in no project), or a UTC day's start in unix milliseconds.
total.labelstring or null
total.prefixstring or nullA key's public prefix.
total.requestsinteger
total.promptTokensinteger
total.completionTokensinteger
total.costMicrosintegerMetered: what the requests were billed.

Errors

  • 400OpenAI shaped error.
  • 401OpenAI shaped error.
  • 404OpenAI 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