MySafeCode's picture
Create test.py
9304c05 verified
import os
import requests
# Get the API key
api_key = os.environ.get("key", "")
print(f"1. API Key loaded: {'Yes' if api_key else 'No'}")
print(f"2. Key length: {len(api_key)}")
print(f"3. First 4 chars: {api_key[:4] if api_key else 'None'}")
# Try a simple request
url = "https://ark.ap-southeast.bytepluses.com/api/v3/contents/generations/tasks"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
# Minimal test data
data = {
"model": "seedance-1-5-pro-251215",
"content": [
{
"type": "text",
"text": "test"
}
]
}
print("\n4. Sending test request...")
try:
response = requests.post(url, headers=headers, json=data)
print(f"5. Status code: {response.status_code}")
print(f"6. Response: {response.text[:200]}") # First 200 chars
except Exception as e:
print(f"5. Error: {e}")
print("\n7. Test complete")