Spaces:
Sleeping
Sleeping
Create test_token.py
Browse files- test_token.py +15 -0
test_token.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
|
4 |
+
# Retrieve token from environment variable
|
5 |
+
token = os.getenv("HF_TOKEN")
|
6 |
+
headers = {"Authorization": f"Bearer {token}"}
|
7 |
+
|
8 |
+
# Test URL with the model you're trying to access
|
9 |
+
response = requests.get("https://api-inference.huggingface.co/models/Qwen/Qwen2.5-72B-Instruct", headers=headers)
|
10 |
+
|
11 |
+
# Check response status
|
12 |
+
if response.status_code == 200:
|
13 |
+
print("Token is valid and authorized.")
|
14 |
+
else:
|
15 |
+
print(f"Error: {response.status_code} - {response.text}")
|