Sample script to get Zero GPU balance using your credentials

import requests
import re
import logging
from datetime import datetime

# Any questions address to Telegram: Contact @Eugeny_Zaretskiy

def get_hf_gpu_balance(log_id=None):
“”"
Fetch Hugging Face billing page and extract current GPU balance.

```
Args:
** log_id (str): Optional identifier for logging**

Returns:
** float: Current GPU balance in seconds, or None if failed**
“”"
# Configure logging format
log_prefix = f"[HFQUOTA][{log_id}]" if log_id else “[HFQUOTA]”

# Your authentication tokens, find it using F12 in Google Chrome
cookies = {
** ‘token’: ‘your_token1’,**
** ‘_stripe_mid’: ‘your_token2’,**
** ‘_stripe_sid’: ‘your_token3’,**
** ‘aws-waf-token’: ‘your_token4’**
}

url = ‘Hugging Face – The AI community building the future.

try:
```

# logging.info(f"{log_prefix} Fetching billing page…")

```
** response = requests.get(url, cookies=cookies, timeout=30)**
** response.raise_for_status()**


** html_content = response.text**
```

# logging.info(f"{log_prefix} Page fetched successfully (size: {len(html_content)} bytes)")

```
** # Extract GPU balance using regex**
** pattern = r’current":([0-9]+(?:.[0-9]+)?)'**
** match = re.search(pattern, html_content)**


** if match:**
** gpu_balance = str(int(float(match.group(1))))**
```

# logging.info(f"{log_prefix} GPU balance extracted: {gpu_balance} seconds")

```
** return gpu_balance**
** else:**
** logging.warning(f"{log_prefix} GPU balance not found in HTML")**
** return None**


except requests.exceptions.RequestException as e:
** logging.error(f"{log_prefix} HTTP request failed: {e}“)**
** return None**
except ValueError as e:
** logging.error(f”{log_prefix} Failed to convert balance to float: {e}“)**
** return None**
except Exception as e:
** logging.error(f”{log_prefix} Unexpected error: {e}")**
** return None**
```

# Example usage

if name == “main”:

# Setup logging

logging.basicConfig(level=logging.INFO, format=‘%(asctime)s - %(levelname)s - %(message)s’)

** **# Get GPU balance with log ID** **balance = get_hf_gpu_balance("GPU-MONITOR-001")** **if balance is not None:** ** print(datetime.now().strftime("%d%m%y %H:%M:%S"), "Current GPU balance:", balance, "seconds")** **else:** ** print("Failed to retrieve GPU balance")** **

Example of output:

160925 12:45:02 Current GPU balance: 1500 seconds
160925 12:50:03 Current GPU balance: 1492 seconds