Credentials. Admin keys see the whole organization; use them only in trusted scripts, and sanitize --debug logs before sharing.
Who it is forA platform engineer who audits API usage and stored files across an organization.
The problemThe default readable output is not something a script can parse reliably.
The outcomeClean JSON or JSONL exports you can feed into jq, a spreadsheet or a monitoring job.
What you need first
- An OpenAI API key (OPENAI_API_KEY); admin endpoints need OPENAI_ADMIN_KEY
- Homebrew, Go 1.26 or later, or a prebuilt binary from GitHub Releases
- Optional: jq for parsing JSON output
Steps
- Run
openai models list --format jsonl | jq '.id'to list model IDs - Run
openai files list --format json > files.jsonto export your files - Use
--transformwith GJSON syntax to pull single fields, for exampleopenai files get file-example --transform filename --raw-output - Set OPENAI_ADMIN_KEY and run
openai admin organization usage completionswith--start-time,--end-timeand--bucket-width 1d - Check each command's exit status before trusting a redirected file
Prompt for your agent
With openai/openai-cli, export my models and files as JSON, then pull completions usage for <date range> with the admin usage command and summarize it per day. Check exit codes before using any output file.
Caveat.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for openai/openai-cli and "Export OpenAI models, files and usage as JSON for your scripts"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer