OpenAI admin usage and cleanup
How to report OpenAI Platform (developer API) usage by team member, list projects and API keys for cleanup, and use ChatGPT Team monthly exports to identify unused seats.
Prerequisites
- OpenAI org owner (or equivalent) API key — required for organization-level endpoints. Stored in 1Password as “Open AI Admin Key” and in repo root
.envasOPENAI_ADMIN_API_KEY(script loads from root when run from repo root).
1. Platform: usage by user and projects/keys report
Script: scripts/openai-usage-and-keys-report.ts
From repo root, with OPENAI_ADMIN_API_KEY set (e.g. in root .env):
npx tsx scripts/openai-usage-and-keys-report.ts [--days 30]- Usage by user: Calls
GET /v1/organization/usage/completionswithgroup_by=user_idfor the last N days. Outputsuser_id, input/output tokens, and request counts. User IDs are opaque; map to names via project members or Platform UI if needed. - Projects and API keys: Lists all org projects and, per project, API keys with
last_used_at. Highlights keys that are never used or stale. - Org admin keys: Lists organization-level admin API keys and their
last_used_at(if the endpoint is available for your org; some accounts may get 404).
Use the report to decide which project keys to delete or which projects to archive. Cleanup is manual (or via script flags in the future); see Platform API reference for DELETE /organization/projects/{project_id}/api_keys/{key_id} and POST /organization/projects/{project_id}/archive.
Ad-hoc dashboard: https://platform.openai.com/usage
2. ChatGPT Team: monthly CSV exports and seat cleanup
ChatGPT Team (chatgpt.com workspace) has no public API for per-user usage. Use the product UI and optional CSV analysis script.
Exporting monthly reports
- Go to https://chatgpt.com/admin/usage (workspace owners/admins).
- Export monthly user reports (e.g. “BrainforgeAI monthly user report YYYY-MM-01.csv”).
- Save exports anywhere (e.g.
~/Downloads/orknowledge/engineering/openai-team-exports/).
Analyzing exports with the script
Script: scripts/openai-team-csv-report.ts
From repo root:
npx tsx scripts/openai-team-csv-report.ts path/to/monthly-report-2026-01-01.csv path/to/2026-02-01.csv path/to/2026-03-01.csvExample with multiple files (adjust paths for your shell):
npx tsx scripts/openai-team-csv-report.ts ~/Downloads/BrainforgeAI\ monthly\ user\ report\ 2026-01-01.csv ~/Downloads/BrainforgeAI\ monthly\ user\ report\ 2026-02-01.csv ~/Downloads/BrainforgeAI\ monthly\ user\ report\ 2026-03-01.csvOutput:
- Zero usage (enabled) — users with
user_status=enabledand 0 messages across all supplied files. Prime candidates to remove from the seat count. - Low usage — enabled users with ≤30 total messages across files; review whether they still need a seat.
- Deleted users — list for confirming they are no longer billed as seats.
Reducing seats
- Add or remove seats in ChatGPT Business billing/settings: Add or remove seats.
- After removing zero-usage or departed users from the workspace, reduce the seat count in billing to match.
3. Summary
| Goal | Tool | Notes |
|---|---|---|
| Platform usage by user | scripts/openai-usage-and-keys-report.ts | Needs OPENAI_ADMIN_API_KEY in root .env |
| Platform projects/keys | Same script | Review last_used_at; delete/archive manually |
| ChatGPT Team seat usage | chatgpt.com/admin/usage + CSV export | No API |
| ChatGPT Team zero/low usage list | scripts/openai-team-csv-report.ts | Pass one or more monthly CSV paths |
| Reduce ChatGPT Team seats | ChatGPT Business billing | After removing users from workspace |