Openai Usage
@dougschaefer/openai-usagev2026.06.08.1
01README
OpenAI platform usage and cost reporting via the Organization Usage API — daily and total completion token counts and USD spend, month-to-date by default. Vault-based Admin API key (the api.usage.read scope is required; a standard project key cannot read usage).
02Models
@dougschaefer/openai-usagev2026.06.08.1openai-usage/usage.ts
Global Arguments
| Argument | Type | Description |
|---|---|---|
| apiKey | string | OpenAI Admin API key (sk-admin-...) carrying the api.usage.read scope. Store it in a vault and pass via a CEL expression; a standard project key cannot read usage. |
fn usage(startDate?: string, days?: number)
Fetch OpenAI completion token usage (input/output tokens and request counts) by day for the period. Defaults to month-to-date. Requires an Admin key with the api.usage.read scope.
| Argument | Type | Description |
|---|---|---|
| startDate? | string | Inclusive start date YYYY-MM-DD (UTC). Defaults to the first of the current month. |
| days? | number | Alternative to startDate: look back this many days from now. |
fn costs(startDate?: string, days?: number)
Fetch OpenAI spend in USD by day for the period. Defaults to month-to-date. Requires an Admin key with the api.usage.read scope.
| Argument | Type | Description |
|---|---|---|
| startDate? | string | Inclusive start date YYYY-MM-DD (UTC). Defaults to the first of the current month. |
| days? | number | Alternative to startDate: look back this many days from now. |
Resources
usage(infinite)— Completion token usage totals and daily breakdown
costs(infinite)— Spend totals and daily breakdown in USD
03Previous Versions
2026.05.27.1May 27, 2026
Initial release. Query the OpenAI Organization Usage and Cost API for month-to-date completion token usage and USD spend, with daily breakdowns; vault-based Admin key (api.usage.read scope). Fills a gap no community extension covers: the OpenAI platform usage API (not Azure/Bedrock/Vertex).
04Stats
A
92 / 100
Downloads
0
Archive size
6.0 KB
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive0/1missing
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License declared1/1earned
- Verified public repository2/2earned
05Platforms
06Labels