SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
969 B · 18 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2# STATUS: LIVE_VERIFIED — executed 2026-09-19 (exit 0 in 1.8s)3# Chat Completions SSE: reasoning_content deltas, content deltas, finish chunk, usage chunk (stream_options), [DONE].4set -euo pipefail5cd "$(dirname "$0")/../../.."6source scripts/lib.sh7T=$(mktemp); trap 'rm -f "$T"' EXIT8xai POST /v1/chat/completions -d '{"model":"grok-4.3","messages":[{"role":"user","content":"What is 17*23? Reply with the number only."}],"max_completion_tokens":32,"stream":true,"stream_options":{"include_usage":true}}' > "$T"9log_request xai POST /v1/chat/completions "$XAI_STATUS" 0.0005 "example xai/streaming/chat_stream.sh"10mask < "$T" | grep '^data:' | python3 -c '11import json,sys12for l in sys.stdin:13    d=l[5:].strip()14    if d=="[DONE]": print("[DONE]"); continue15    j=json.loads(d); ch=j["choices"]16    print("usage chunk" if not ch else ("delta="+json.dumps(ch[0]["delta"])+" finish="+str(ch[0].get("finish_reason"))))'17[ "$XAI_STATUS" = "200" ]18