#!/usr/bin/env bash
set -euo pipefail
BASE="$1"
KEY="$2"
MODEL="deepseek-v4-flash"
BODY1=$(mktemp)
C1=$(curl -sS -o "$BODY1" -w '%{http_code}' "$BASE/v1/responses" -H 'content-type: application/json' -H "authorization: Bearer $KEY" --data '{"model":"deepseek-v4-flash","input":"reply with exactly: prod-nonstream-ok","stream":false}')
echo "nonstream_http=$C1"
python3 - <<'PY' "$BODY1"
import json,sys
b=open(sys.argv[1]).read()
try:
 d=json.loads(b)
 txt=''
 for item in d.get('output',[]) or []:
  if isinstance(item,dict):
   for c in item.get('content',[]) or []:
    if isinstance(c,dict) and c.get('type')=='output_text': txt += c.get('text','')
 print(json.dumps({'status':d.get('status'),'model':d.get('model'),'text':txt[:200],'error':d.get('error')},ensure_ascii=False))
except Exception:
 print(b[:1000])
PY
BODY2=$(mktemp)
C2=$(curl -sS -N -o "$BODY2" -w '%{http_code}' "$BASE/v1/responses" -H 'content-type: application/json' -H 'accept: text/event-stream' -H "authorization: Bearer $KEY" --data '{"model":"deepseek-v4-flash","input":"reply with exactly: prod-stream-ok","stream":true}')
echo "stream_http=$C2"
python3 - <<'PY' "$BODY2"
import sys
text=open(sys.argv[1]).read()
print('has_completed=' + str('response.completed' in text).lower())
print('has_text=' + str('prod-stream-ok' in text).lower())
PY
