File size: 1,111 Bytes
001e827
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
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 = [
    "stabilityai/stable-diffusion-xl-base-1.0",
    "stabilityai/stable-diffusion-2-1",
    "black-forest-labs/FLUX.1-schnell",
    "runwayml/stable-diffusion-v1-5"
]

for model in models_to_test:
    url = f"https://api-inference.huggingface.co/models/{model}"
    print(f"\n--- Testing {model} ---")
    try:
        response = requests.post(url, headers=headers, json={"inputs": "A simple red apple"}, timeout=30)
        print(f"Status: {response.status_code}")
        print(f"Content-Type: {response.headers.get('Content-Type')}")
        if response.status_code != 200:
            print(f"Error: {response.text}")
        elif "application/json" in response.headers.get('Content-Type', ''):
            print(f"JSON Payload: {response.text}")
        else:
            print(f"Success: Image received ({len(response.content)} bytes)")
    except Exception as e:
        print(f"Exception: {e}")