{
 "schema_version": 1,
 "generated": "2026-10-29",
 "id": "openai-openai-cli--export-openai-api-data-for-scripts",
 "repo": "openai/openai-cli",
 "repo_url": "https://github.com/openai/openai-cli",
 "repo_slug": "openai-openai-cli",
 "title": "Export OpenAI models, files and usage as JSON for your scripts",
 "page_title": "How to export OpenAI models, files and usage as JSON for your scripts with OpenAI CLI",
 "summary": "List models and files as JSON or JSONL, extract fields, and pull organization usage with an admin key.",
 "who": "A platform engineer who audits API usage and stored files across an organization.",
 "problem": "The default readable output is not something a script can parse reliably.",
 "outcome": "Clean JSON or JSONL exports you can feed into jq, a spreadsheet or a monitoring job.",
 "steps": [
  "Run `openai models list --format jsonl | jq '.id'` to list model IDs",
  "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`",
  "Set OPENAI_ADMIN_KEY and run `openai admin organization usage completions` with `--start-time`, `--end-time` and `--bucket-width 1d`",
  "Check each command's exit status before trusting a redirected file"
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "20 minutes",
 "basis": "readme",
 "caveat": "",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "go",
 "requirements": [
  "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"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [
  {
   "tag": "credentials",
   "notice": "Admin keys see the whole organization; use them only in trusted scripts, and sanitize --debug logs before sharing."
  }
 ],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/openai-openai-cli/export-openai-api-data-for-scripts/",
 "md": "https://dedupedai.com/use-cases/openai-openai-cli/export-openai-api-data-for-scripts/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/openai-openai-cli--export-openai-api-data-for-scripts.json",
 "api_version": "v1"
}
