| 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-2-1", |
| "runwayml/stable-diffusion-v1-5", |
| "prompthero/openjourney", |
| "OniNoHant/Anything-v3.0", |
| "Linaqruf/anything-v3.0", |
| "dreamlike-art/dreamlike-diffusion-1.0" |
| ] |
|
|
| 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}") |
|
|