mimifuel2018 commited on
Commit
b56c3a2
·
verified ·
1 Parent(s): 8b0b7cc

Create test_token.py

Browse files
Files changed (1) hide show
  1. 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}")