#!/usr/bin/env bash # # AOCore streaming chat-completion via curl (SSE). # # Usage: # export AOSENTRY_KEY="sk-..." # bash streaming.sh # # CRITICAL: curl's -N flag disables output buffering. Without -N, curl waits # until the full response is received before printing anything, which defeats # the entire point of SSE. Always pass -N for streaming endpoints. # # AOCore stamps the six X-AOCore-* quota headers BEFORE the first SSE # chunk is emitted (proven by TestStreamWriter_StampsHeadersBeforeWriteHeader # in go/internal/llm/streaming_quota_headers_test.go), so the quota state is # visible in the response headers — see ../../rate-limits.md. set -euo pipefail : "${AOSENTRY_KEY:?Set AOSENTRY_KEY to your minted API key (sk-...).}" BASE_URL="${AOSENTRY_BASE_URL:-https://gateway.core.aocyber.ai}" curl -N "${BASE_URL}/v1/chat/completions" \ -H "Authorization: Bearer ${AOSENTRY_KEY}" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [ {"role": "user", "content": "Count from 1 to 5, one number per line."} ], "stream": true }'