{
 "schema_version": 1,
 "generated": "2026-10-24",
 "id": "aafqaq-codex-lb-enhanced--read-api-key-quota-usage-for-automation",
 "repo": "aafqaq/codex-lb-enhanced",
 "repo_url": "https://github.com/aafqaq/codex-lb-enhanced",
 "repo_slug": "aafqaq-codex-lb-enhanced",
 "title": "Read API-key quota usage from /v1/usage in scripts",
 "page_title": "How to read API-key quota usage from /v1/usage in scripts with Codex LB Enhanced",
 "summary": "Query the usage endpoint to track remaining limits for each API key.",
 "who": "A developer or operations engineer who runs scripts or agents that need to check how much quota an API key has left before starting work.",
 "problem": "Clients cannot see how close an API key is to its window limits, so jobs fail mid-run when a limit is hit.",
 "outcome": "A script that reads /v1/usage and reports the same quota source the Codex headers use.",
 "steps": [
  "Configure 5h, daily, 7d, weekly, or monthly windows for an API key in the dashboard, using credits, tokens, or cost limits.",
  "Enable Codex quota emulation and choose API-key limits or pooled-account estimates as the display source.",
  "Send an authenticated GET request to the /v1/usage endpoint with your API key.",
  "Parse the JSON response and compare the remaining amounts with the window limits you set. (inferred, check the README)",
  "Make your script stop or wait when remaining usage falls below your threshold."
 ],
 "agent_prompt": "In the aafqaq/codex-lb-enhanced repo, write a small script that calls /v1/usage on <gateway URL> with the API key in <env var name>. Output the remaining usage per window as JSON. Verify that the output matches the usage limits shown in the dashboard for that key.",
 "agents": [
  "any"
 ],
 "difficulty": "Advanced",
 "time": "45 minutes",
 "basis": "readme",
 "caveat": "The README says model-specific limits do not become the default Codex window, so check model-level limits in the dashboard separately.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Docker installed and running, or uv installed for running from source",
  "Upstream ChatGPT accounts you are authorized to use, to add in the dashboard",
  "A browser to open the dashboard at localhost:2455",
  "Codex CLI, desktop, or IDE integration, or another OpenAI-compatible client, if you plan to connect one"
 ],
 "risk": "sensitive",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [
  {
   "tag": "credentials",
   "notice": "The script will need an API key, so load it from an environment variable and never hard-code it."
  }
 ],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/read-api-key-quota-usage-for-automation/",
 "md": "https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/read-api-key-quota-usage-for-automation/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/aafqaq-codex-lb-enhanced--read-api-key-quota-usage-for-automation.json",
 "api_version": "v1"
}
