Created
February 19, 2026 23:17
-
-
Save dguerizec/7f34f5c7895cafb08699870c45f30485 to your computer and use it in GitHub Desktop.
claude-usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| CREDENTIALS_FILE="${HOME}/.claude/.credentials.json" | |
| if [[ ! -f "$CREDENTIALS_FILE" ]]; then | |
| echo "Error: credentials file not found: $CREDENTIALS_FILE" >&2 | |
| exit 1 | |
| fi | |
| ACCESS_TOKEN=$(jq -r '.claudeAiOauth.accessToken // empty' "$CREDENTIALS_FILE") | |
| if [[ -z "$ACCESS_TOKEN" ]]; then | |
| echo "Error: no OAuth access token found in $CREDENTIALS_FILE" >&2 | |
| exit 1 | |
| fi | |
| curl -sf \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer ${ACCESS_TOKEN}" \ | |
| -H "anthropic-beta: oauth-2025-04-20" \ | |
| -H "User-Agent: claude-code/2.1.34" \ | |
| "https://api.anthropic.com/api/oauth/usage" | jq . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment