The two endpoints and the admin key
Both endpoints live at the organization level and reject normal project keys. Create an Admin API key in the OpenAI platform under organization settings, then:
# token usage, grouped by model, daily buckets
curl "https://api.openai.com/v1/organization/usage/completions?\
start_time=1754006400&bucket_width=1d&group_by=model" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"
# billed dollars per day
curl "https://api.openai.com/v1/organization/costs?\
start_time=1754006400&bucket_width=1d" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"Usage buckets go down to the minute and group by project, API key, model, and the optional user field. Costs currently buckets by day only. Full parameters are in OpenAI’s Usage API cookbook. Timestamps are Unix seconds.
What these endpoints answer well
- Which model the money goes to, per day: the model mix question that explains most bill surprises.
- Which project or key spent what, if you split keys per service or environment.
- Token counts per user field value, if you already pass a user id on every request.
- Invoice reconciliation: the costs endpoint is what finance closes the month against.
A useful monthly ritual: multiply the usage endpoint’s token counts by current prices from the LLM pricing JSON feed and compare against the costs endpoint. A persistent gap means unattributed traffic or a stale price table, and both are worth finding.
The gap: tokens per user is not margin per user
Even with the userfield on every call, the Usage API hands you token counts per user, not dollars, and never margin. Turning that into “is this customer profitable” requires three things the endpoints do not have: current per model prices applied per request, your feature context, and what each user pays you. The moment you want the question answered continuously, with per user spending caps enforced before the call rather than reported after the day closes, you are building the request time layer described in OpenAI cost per user.
That layer is what Weckr ships as two lines around your existing client: every call logged with user, feature, recomputed cost, and margin against the user’s plan, with caps that block or downgrade runaways in real time. The Usage API then becomes your monthly cross check instead of your only view.
FAQ
How do I get OpenAI usage and cost data programmatically?
Use the organization endpoints: /v1/organization/usage/completions returns token usage over time, and /v1/organization/costs returns daily spend in USD. Both require an Admin API key created at platform.openai.com under organization settings, a regular sk- project key is not enough. Usage can be bucketed by minute, hour, or day; the costs endpoint currently buckets by day only.
Can the OpenAI Usage API break down cost by end user?
Only partially, and only in tokens. The usage endpoint can group by project, API key, model, and the optional user field you pass on requests, so if you send a user id on every call you can see token counts per user. The costs endpoint does not go to that grain, and neither endpoint knows what a user pays you, so per user dollar cost and margin still have to be computed in your own stack.
What is the difference between the OpenAI Usage API and the Costs API?
Usage counts tokens and requests with flexible grouping and time buckets down to the minute. Costs reports billed dollars per day, the number that reconciles with your invoice. Token counts times your own price table should approximate the costs endpoint, and a persistent gap usually means unattributed traffic or a stale price table.
How fresh is the OpenAI cost data?
It is reporting data, not a live meter. Daily cost buckets settle after the day closes, which is fine for finance and useless for catching a runaway user mid burst. Real time control, per user caps, loop detection, blocking before the call, has to happen at request time in your own request path.
Should I build my dashboard on the Usage API or track per request?
Both, for different jobs. The Usage and Costs APIs are the authoritative record of what OpenAI bills your organization, ideal for monthly reconciliation. Per request tracking in your app is the only place user identity, feature, and plan price exist together, which is what answers whether a customer is profitable. Weckr does the per request half in two lines and you can cross check it monthly against the costs endpoint.
Keep reading
Reporting tells you what happened. Weckr tells you who.
Wire the two line integration, keep the Usage API as your auditor, and the unprofitable accounts stop hiding in daily buckets. See the per user view on the live demo, free for 50,000 requests a month, or start with the AI cost and margin guide.