Create test.py
Browse files
test.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# Get the API key
|
| 5 |
+
api_key = os.environ.get("key", "")
|
| 6 |
+
print(f"1. API Key loaded: {'Yes' if api_key else 'No'}")
|
| 7 |
+
print(f"2. Key length: {len(api_key)}")
|
| 8 |
+
print(f"3. First 4 chars: {api_key[:4] if api_key else 'None'}")
|
| 9 |
+
|
| 10 |
+
# Try a simple request
|
| 11 |
+
url = "https://ark.ap-southeast.bytepluses.com/api/v3/contents/generations/tasks"
|
| 12 |
+
headers = {
|
| 13 |
+
"Content-Type": "application/json",
|
| 14 |
+
"Authorization": f"Bearer {api_key}"
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
# Minimal test data
|
| 18 |
+
data = {
|
| 19 |
+
"model": "seedance-1-5-pro-251215",
|
| 20 |
+
"content": [
|
| 21 |
+
{
|
| 22 |
+
"type": "text",
|
| 23 |
+
"text": "test"
|
| 24 |
+
}
|
| 25 |
+
]
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
print("\n4. Sending test request...")
|
| 29 |
+
try:
|
| 30 |
+
response = requests.post(url, headers=headers, json=data)
|
| 31 |
+
print(f"5. Status code: {response.status_code}")
|
| 32 |
+
print(f"6. Response: {response.text[:200]}") # First 200 chars
|
| 33 |
+
except Exception as e:
|
| 34 |
+
print(f"5. Error: {e}")
|
| 35 |
+
|
| 36 |
+
print("\n7. Test complete")
|