File size: 1,005 Bytes
15a9a47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
import os
from dotenv import load_dotenv
import requests

load_dotenv()
token = os.environ.get("HF_API_TOKEN") or os.environ.get("HF_TOKEN")
headers = {"Authorization": f"Bearer {token}"}

models_to_test = [
    "Lykon/dreamshaper-xl-1.0",
    "stabilityai/stable-diffusion-xl-base-1.0",
    "prompthero/openjourney",
    "black-forest-labs/FLUX.1-schnell",
    "SG161222/Realistic_Vision_V5.1_noVAE",
    "stabilityai/stable-diffusion-2-1"
]

for model in models_to_test:
    url = f"https://api-inference.huggingface.co/models/{model}"
    print(f"Testing {model}...")
    try:
        response = requests.post(url, headers=headers, json={"inputs": "A beautiful landscape oil painting"}, timeout=30)
        print(f"[{response.status_code}] TYPE: {response.headers.get('content-type')}")
        if response.status_code != 200:
            print(f"   -> {response.text}")
        else:
            print(f"   -> Success! (Image received)")
    except Exception as e:
        print(f"   -> Failed: {e}")