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
| Field | Type | What it is |
|---|---|---|
| from (query) | string | The first UTC day, YYYY-MM-DD. Default: 30 days ending on to. |
| to (query) | string | The last UTC day, YYYY-MM-DD, included; never after today. Default: today. |
| by (query) | string | How the rows are grouped; project only with orgId. Default: model. One of "model", "key", "project", "day". |
| orgId (query) | integer | |
| format (query) | string | One of "json", "csv". |
Answer 200
The rows, at most 366 days of them.
| Field | Type | What it is |
|---|---|---|
| scope | string | One of "account", "organization". |
| orgId | integer or null | |
| own | boolean | |
| from | string | |
| to | string | |
| by | string | One of "model", "key", "project", "day". |
| rows | array of object | |
| rows[] | string or integer or null | A 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[] | string or null | |
| rows[] | string or null | A key's public prefix. |
| rows[] | integer | |
| rows[] | integer | |
| rows[] | integer | |
| rows[] | integer | Metered: what the requests were billed. |
| total | object | |
| total. | string or integer or null | A 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. | string or null | |
| total. | string or null | A key's public prefix. |
| total. | integer | |
| total. | integer | |
| total. | integer | |
| total. | integer | Metered: 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.