Remove unused balance check script for OpenRouter API

- Deleted the Python script that checked the balance of the OpenRouter API, as it is no longer needed in the project.
- This cleanup contributes to maintaining a streamlined codebase by removing obsolete files.
This commit is contained in:
666ghj 2025-12-09 18:37:03 +08:00
parent 5396b21a14
commit ed8bfec219

View file

@ -1,36 +0,0 @@
import requests
def check_openrouter_balance(api_key):
url = "https://openrouter.ai/api/v1/credits"
headers = {
"Authorization": f"Bearer {api_key}",
"Referer": "https://your-site.com",
"X-Title": "Balance Check Script"
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status() # 检查请求是否成功
data = response.json().get("data", {})
total_credits = data.get("total_credits", 0) # 总充值/赠送金额
total_usage = data.get("total_usage", 0) # 总消耗金额
# 计算剩余余额
balance = total_credits - total_usage
print(f"💰 总额度 (Total Credits): ${total_credits}")
print(f"📉 已使用 (Total Usage): ${total_usage}")
print(f"💵 剩余余额 (Balance): ${balance:.4f}")
return balance
except requests.exceptions.RequestException as e:
print(f"查询失败: {e}")
return None
# 替换你的 API Key
MY_API_KEY = ""
check_openrouter_balance(MY_API_KEY)