#!/bin/bash
echo "=== GENERATING 512x512 8 STEPS ==="
START=$(date +%s%N)

curl -s -X POST http://localhost:8080/txt2img \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a beautiful mountain landscape at sunset, photorealistic, 8k",
    "negative_prompt": "",
    "width": 512,
    "height": 512,
    "steps": 8,
    "cfg_scale": 1.0,
    "sampling_method": "euler",
    "seed": 42
  }' -o /tmp/gen_response.json

END=$(date +%s%N)
ELAPSED=$(( (END - START) / 1000000 ))
echo "Generation took ${ELAPSED}ms ($(( ELAPSED / 1000 ))s)"
echo "=== RESPONSE ==="
python3 -c "
import json
with open('/tmp/gen_response.json') as f:
    d = json.load(f)
for k,v in d.items():
    if k == 'images':
        print(f'images: {len(v)} images, first {len(v[0]) if v else 0} bytes base64')
    elif k == 'data':
        print(f'data: {len(str(v))} chars')
    else:
        print(f'{k}: {v}')
" 2>/dev/null || python3 -m json.tool /tmp/gen_response.json 2>/dev/null | head -30 || head -200 /tmp/gen_response.json
