"""Test Viostudio API."""
import urllib.request
import json

API_KEY = "vio_sk_vA8llIYm51J3oyXtfevrM92yUBJ8-3IS1sIn6xydF8o"
BASE = "https://api.viostudio.id"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
    "User-Agent": "OpenMontage/1.0"
}

endpoints = ["/v1/models", "/v1/balance", "/v1/user", "/v1/images/generations", "/v1/video/generations"]

for ep in endpoints:
    url = BASE + ep
    print(f"\n=== {ep} ===")
    try:
        req = urllib.request.Request(url, headers=headers)
        resp = urllib.request.urlopen(req, timeout=10)
        data = json.loads(resp.read().decode())
        print(json.dumps(data, indent=2)[:2000])
    except urllib.error.HTTPError as e:
        print(f"HTTP {e.code}: {e.read().decode()[:500]}")
    except Exception as e:
        print(f"Error: {e}")
