File size: 714 Bytes
ce9cdc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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