Server-Sent Events
当你在 /v1/chat/completions 设定 stream: true,Gateway 会把上游供应商回应以 OpenAI 格式的 SSE chunk 串流出来。
请求#
加上 "stream": true。curl 要加 -N,输出才不会被缓冲。
curl -N https://api.atptoken.ai/v1/chat/completions \
-H "Authorization: Bearer $ATP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"messages": [{"role": "user", "content": "hi"}],
"stream": true
}'用量与串流结束#
最后一个 chunk 含 usage 物件;串流以 data: [DONE] 结束。
这页有帮助吗?