Потоковые ответы
Потоковый вывод RouteAPI использует Server-Sent Events (SSE). Установите stream: true, чтобы получать контент постепенно.
Пример
Section titled “Пример”curl https://www.routeapi.ai/v1/chat/completions \ -H "Authorization: Bearer $ROUTEAPI_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o","stream":true,"messages":[{"role":"user","content":"Explain streaming"}]}'SSE chunk example
Section titled “SSE chunk example”data: {"choices":[{"delta":{"content":"RouteAPI"}}]}
data: {"choices":[{"delta":{"content":" supports"}}]}
data: [DONE]Read data: line by line and stop after [DONE].
{"stream":true,"stream_options":{"include_usage":true}}Support depends on model capability.
Mid-stream errors
Section titled “Mid-stream errors”- Model service timeout
- Insufficient quota
- Network interruption
- Client disconnect
- Tool call parameter generation failure
Рекомендации:
- Record request id.
- Use limited retries for network interruption.
- Avoid retrying operations with side effects.
- Check console usage logs.