Skip to content

Instantly share code, notes, and snippets.

@johnknott
Created June 18, 2026 12:20
Show Gist options
  • Select an option

  • Save johnknott/946546f803686872f2ca4dc822bb0eeb to your computer and use it in GitHub Desktop.

Select an option

Save johnknott/946546f803686872f2ca4dc822bb0eeb to your computer and use it in GitHub Desktop.
Codex Rate Limits Resets from the terminal

Codex rate-limit list / reset script

Small script for checking and consuming Codex rate-limit reset credits from the CLI.

This is mainly useful if you use Codex from the terminal, especially on Linux, where the Codex desktop app/reset UI may not be available or convenient.

Requirements

You need:

  • curl
  • jq
  • a logged-in Codex CLI session with credentials at:
~/.codex/auth.json

Script

#!/bin/sh

auth_file="${CODEX_AUTH_JSON:-$HOME/.codex/auth.json}"
base_url="https://chatgpt.com/backend-api/wham"

access_token="$(jq -r .tokens.access_token "$auth_file")"
account_id="$(jq -r .tokens.account_id "$auth_file")"

curl_auth() {
  curl -sS \
    -H "Authorization: Bearer $access_token" \
    -H "ChatGPT-Account-ID: $account_id" \
    "$@"
}

available_count="$(
  curl_auth "$base_url/usage" |
    jq -r .rate_limit_reset_credits.available_count
)"

printf "resets: %s\nconsume one? [y/N] " "$available_count"
read answer

case "$answer" in
  y|Y)
    curl_auth \
      -X POST \
      -H "Content-Type: application/json" \
      -d "{\"redeem_request_id\":\"$(cat /proc/sys/kernel/random/uuid)\"}" \
      "$base_url/rate-limit-reset-credits/consume" |
      jq
    ;;
  *)
    echo "cancelled"
    ;;
esac

Optional install

Save the readable version as:

codex-reset-credit

Then run:

chmod +x codex-reset-credit
./codex-reset-credit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment