cora / test_api.py
tokgae's picture
Upload folder using huggingface_hub
15a9a47 verified
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}")