DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to export OpenAI models, files and usage as JSON for your scripts with OpenAI CLI

List models and files as JSON or JSONL, extract fields, and pull organization usage with an admin key.

Short answer: Run openai models list --format jsonl | jq '.id' to list model IDs; then run openai files list --format json > files.json to export your files; use --transform with GJSON syntax to pull single fields, for example openai files get file-example --transform filename --raw-output. All steps.

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

  1. Run openai models list --format jsonl | jq '.id' to list model IDs
  2. Run openai files list --format json > files.json to export your files
  3. Use --transform with GJSON syntax to pull single fields, for example openai files get file-example --transform filename --raw-output
  4. Set OPENAI_ADMIN_KEY and run openai admin organization usage completions with --start-time, --end-time and --bucket-width 1d
  5. 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

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer