import gradio as gr import requests import os # Your API key from Hugging Face secret "key" API_KEY = os.environ.get("key", "") def test_connection(): """Test each part separately""" results = [] # Test 1: Is API key loaded? results.append(f"Step 1 - API Key loaded: {'✅' if API_KEY else '❌'}") if API_KEY: results.append(f" Length: {len(API_KEY)}") results.append(f" First 4 chars: {API_KEY[:4]}") # Test 2: Can we reach the API? 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