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.
You need:
curljq- a logged-in Codex CLI session with credentials at:
~/.codex/auth.json#!/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"
;;
esacSave the readable version as:
codex-reset-creditThen run:
chmod +x codex-reset-credit
./codex-reset-credit