set -euo pipefail
KEY="sk-a2003052b2ac0fcf02b6140a4ff44be9617c72a63159efc5057ba071424288a3"
BASE="https://www.codebridge.cc"

echo "== models =="
curl -sS -o /tmp/t48_models.json -w "status=%{http_code} total=%{time_total}\n" "$BASE/v1/models" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json"
head -c 280 /tmp/t48_models.json; echo

echo "\n== responses gpt-4o-mini x5 =="
cat >/tmp/t48_resp.json <<'JSON'
{"model":"gpt-4o-mini","input":[{"role":"user","content":[{"type":"input_text","text":"reply with OK only"}]}],"max_output_tokens":16}
JSON
for i in 1 2 3 4 5; do
  code=$(curl -sS -o /tmp/t48_resp_out.json -w "%{http_code}" "$BASE/v1/responses" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" --data-binary @/tmp/t48_resp.json)
  printf "responses[%s] status=%s body=" "$i" "$code"
  head -c 220 /tmp/t48_resp_out.json
  echo
  sleep 1
done

echo "\n== chat.completions gpt-4o-mini x5 =="
cat >/tmp/t48_chat.json <<'JSON'
{"model":"gpt-4o-mini","messages":[{"role":"user","content":"reply with OK only"}],"max_tokens":16}
JSON
for i in 1 2 3 4 5; do
  code=$(curl -sS -o /tmp/t48_chat_out.json -w "%{http_code}" "$BASE/v1/chat/completions" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" --data-binary @/tmp/t48_chat.json)
  printf "chat[%s] status=%s body=" "$i" "$code"
  head -c 220 /tmp/t48_chat_out.json
  echo
  sleep 1
done
