文件
串流請求
更新於 2026-07-21
Chat Completions 串流
在請求中設定 "stream": true:
curl https://api.rokoapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-N \
-d '{
"model": "deepseek-v4-flash",
"stream": true,
"messages": [{"role":"user","content":"請講一個短篇故事"}]
}'
用戶端依 SSE data: 行解析 choices[0].delta。
Responses 串流
Responses 使用語意化事件(如 response.output_text.delta),詳見 Responses API。
用戶端注意事項
- 中間代理請勿緩衝整段 SSE
- 連線中斷後,依業務需求決定是否重試
- 逾時與限流,請參閱 速率限制