#!/bin/bash
export LC_ALL=C
U=https://opencode.ai/zen/v1/chat/completions
echo "=== 6 attempts via proxy, 2 models ==="
for m in mimo-v2.6-flash-free big-pickle; do
  printf '  %-24s ' "$m"
  for i in 1 2 3; do
    c=$(curl -s -o /tmp/b -w '%{http_code}' --max-time 30 -x http://172.19.0.1:20808 -X POST "$U" \
      -H 'content-type: application/json' -H 'accept: text/event-stream' \
      -H 'x-opencode-client: desktop' \
      -d "{\"model\":\"$m\",\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}],\"stream\":true}" 2>/dev/null)
    printf '%s ' "$c"
  done
  echo
done

echo
echo "=== what the model list says is free ==="
curl -s --max-time 15 -x http://172.19.0.1:20808 https://opencode.ai/zen/v1/models \
  -H 'x-opencode-client: desktop' \
  | python3 -c 'import sys,json;d=json.load(sys.stdin);ids=[m["id"] for m in d.get("data",[])];print("  total:",len(ids));print("  free-looking:",[i for i in ids if "free" in i][:12]);print("  first:",ids[:10])' 2>/dev/null
